]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat : db API add watch_rule_update DB API action
authorSteven Hardy <shardy@redhat.com>
Fri, 12 Oct 2012 09:49:13 +0000 (10:49 +0100)
committerSteven Hardy <shardy@redhat.com>
Fri, 12 Oct 2012 16:20:16 +0000 (17:20 +0100)
Add watch_rule_update DB API call, needed for WatchRule
refactor/rework

Ref #217

Signed-off-by: Steven Hardy <shardy@redhat.com>
Change-Id: Ie8321d390ab96e987bfa4c97c26f1e0305f6bd48

heat/db/api.py
heat/db/sqlalchemy/api.py

index bd6c065f720ce8fd20c0d8111f1e7f9aceeb6aad..e00dc71e99bf40df1013625461ee41b03ba78247 100644 (file)
@@ -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)
 
index e6f106a41c07816a6b28396aa08267aca09a8c43..c0249b390f8970fa47c03eab07d0da6fbb10385a 100644 (file)
@@ -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()