From db0a268f414e963d73ded7449662385f8e5435c1 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Fri, 12 Oct 2012 10:49:13 +0100 Subject: [PATCH] heat : db API add watch_rule_update DB API action Add watch_rule_update DB API call, needed for WatchRule refactor/rework Ref #217 Signed-off-by: Steven Hardy Change-Id: Ie8321d390ab96e987bfa4c97c26f1e0305f6bd48 --- heat/db/api.py | 4 ++++ heat/db/sqlalchemy/api.py | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/heat/db/api.py b/heat/db/api.py index bd6c065f..e00dc71e 100644 --- a/heat/db/api.py +++ b/heat/db/api.py @@ -155,6 +155,10 @@ def watch_rule_create(context, values): return IMPL.watch_rule_create(context, values) +def watch_rule_update(context, watch_id, values): + return IMPL.watch_rule_update(context, watch_id, values) + + def watch_rule_delete(context, watch_rule_name): return IMPL.watch_rule_delete(context, watch_rule_name) diff --git a/heat/db/sqlalchemy/api.py b/heat/db/sqlalchemy/api.py index e6f106a4..c0249b39 100644 --- a/heat/db/sqlalchemy/api.py +++ b/heat/db/sqlalchemy/api.py @@ -276,6 +276,17 @@ def watch_rule_create(context, values): return obj_ref +def watch_rule_update(context, watch_id, values): + wr = watch_rule_get(context, watch_id) + + if not wr: + raise NotFound('Attempt to update a watch with id: %s %s' % + (watch_id, 'that does not exist')) + + wr.update(values) + wr.save() + + def watch_rule_delete(context, watch_name): wr = model_query(context, models.WatchRule).\ filter_by(name=watch_name).first() -- 2.45.2