Add Action Notification
This patch set adds the following action notifications: - action.create - action.update - action.delete - action.execution.start - action.execution.end - action.execution.error Partially Implements: blueprint action-versioned-notifications-api Change-Id: If0bc25bfb7cb1bff3bfa2c5d5fb9ad48b0794168
This commit is contained in:
committed by
alexchadin
parent
62cb8a8d29
commit
25789c9c5a
@@ -17,6 +17,7 @@
|
||||
from watcher.common import exception
|
||||
from watcher.common import utils
|
||||
from watcher.db import api as db_api
|
||||
from watcher import notifications
|
||||
from watcher import objects
|
||||
from watcher.objects import base
|
||||
from watcher.objects import fields as wfields
|
||||
@@ -134,6 +135,8 @@ class Action(base.WatcherPersistentObject, base.WatcherObject,
|
||||
# notifications containing information about the related relationships
|
||||
self._from_db_object(self, db_action, eager=True)
|
||||
|
||||
notifications.action.send_create(self.obj_context, self)
|
||||
|
||||
def destroy(self):
|
||||
"""Delete the Action from the DB"""
|
||||
self.dbapi.destroy_action(self.uuid)
|
||||
@@ -150,6 +153,7 @@ class Action(base.WatcherPersistentObject, base.WatcherObject,
|
||||
db_obj = self.dbapi.update_action(self.uuid, updates)
|
||||
obj = self._from_db_object(self, db_obj, eager=False)
|
||||
self.obj_refresh(obj)
|
||||
notifications.action.send_update(self.obj_context, self)
|
||||
self.obj_reset_changes()
|
||||
|
||||
@base.remotable
|
||||
@@ -173,3 +177,5 @@ class Action(base.WatcherPersistentObject, base.WatcherObject,
|
||||
obj = self._from_db_object(
|
||||
self.__class__(self._context), db_obj, eager=False)
|
||||
self.obj_refresh(obj)
|
||||
|
||||
notifications.action.send_delete(self.obj_context, self)
|
||||
|
||||
@@ -289,7 +289,8 @@ class ActionPlan(base.WatcherPersistentObject, base.WatcherObject,
|
||||
"""Soft Delete the Action plan from the DB"""
|
||||
related_actions = objects.Action.list(
|
||||
context=self._context,
|
||||
filters={"action_plan_uuid": self.uuid})
|
||||
filters={"action_plan_uuid": self.uuid},
|
||||
eager=True)
|
||||
|
||||
# Cascade soft_delete of related actions
|
||||
for related_action in related_actions:
|
||||
|
||||
@@ -52,6 +52,10 @@ class DictField(fields.AutoTypedField):
|
||||
AUTO_TYPE = fields.Dict(fields.FieldType())
|
||||
|
||||
|
||||
class ListOfUUIDsField(fields.AutoTypedField):
|
||||
AUTO_TYPE = fields.List(fields.UUID())
|
||||
|
||||
|
||||
class FlexibleDict(fields.FieldType):
|
||||
@staticmethod
|
||||
def coerce(obj, attr, value):
|
||||
|
||||
Reference in New Issue
Block a user