return IMPL.event_create(context, values)
-def watch_rule_get(context, watch_rule_name):
- return IMPL.watch_rule_get(context, watch_rule_name)
+def watch_rule_get(context, watch_rule_id):
+ return IMPL.watch_rule_get(context, watch_rule_id)
+
+
+def watch_rule_get_by_name(context, watch_rule_name):
+ return IMPL.watch_rule_get_by_name(context, watch_rule_name)
def watch_rule_get_all(context):
return event_ref
-def watch_rule_get(context, watch_rule_name):
+def watch_rule_get(context, watch_rule_id):
+ result = model_query(context, models.WatchRule).\
+ filter_by(id=watch_rule_id).first()
+ return result
+
+
+def watch_rule_get_by_name(context, watch_rule_name):
result = model_query(context, models.WatchRule).\
filter_by(name=watch_rule_name).first()
return result
This could be used by CloudWatch and WaitConditions
and treat HA service events like any other CloudWatch.
'''
- wr = db_api.watch_rule_get(None, watch_name)
+ wr = db_api.watch_rule_get_by_name(None, watch_name)
if wr is None:
logger.warn('NoSuch watch:%s' % (watch_name))
return ['NoSuch Watch Rule', None]
'''
if watch_name:
try:
- wr = db_api.watch_rule_get(context, watch_name)
+ wr = db_api.watch_rule_get_by_name(context, watch_name)
except Exception as ex:
logger.warn('show_watch (%s) db error %s' %
(watch_name, str(ex)))
if watch_name:
try:
- wr = db_api.watch_rule_get(context, watch_name)
+ wr = db_api.watch_rule_get_by_name(context, watch_name)
except Exception as ex:
logger.warn('show_watch (%s) db error %s' %
(watch_name, str(ex)))
def test_show_watch_metric(self):
# Get one of the watch rules created in test_show_watch
# And add a metric datapoint
- watch = db_api.watch_rule_get(self.ctx, "HttpFailureAlarm")
+ watch = db_api.watch_rule_get_by_name(self.ctx, "HttpFailureAlarm")
self.assertNotEqual(watch, None)
values = {'watch_rule_id': watch.id,
'data': {