From: Steven Hardy Date: Fri, 12 Oct 2012 09:49:13 +0000 (+0100) Subject: heat : db API add watch_rule_update DB API action X-Git-Tag: 2014.1~1321 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=db0a268f414e963d73ded7449662385f8e5435c1;p=openstack-build%2Fheat-build.git 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 --- 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()