Merge "Add Action Notification"

This commit is contained in:
Jenkins
2017-03-08 09:58:46 +00:00
committed by Gerrit Code Review
22 changed files with 1188 additions and 120 deletions

View File

@@ -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)

View File

@@ -292,7 +292,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:

View File

@@ -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):