Implemented audit.delete notification

In this changeset, I implemented the audit.delete notification.

Partially Implements: blueprint audit-versioned-notifications-api

Change-Id: I8aeb73f4b8d3273d6de7dc9c44674e3041b005ea
This commit is contained in:
Vincent Françoise
2016-11-04 10:09:46 +01:00
parent 0c0a9c84d6
commit 6f9f67cacc
6 changed files with 232 additions and 5 deletions

View File

@@ -111,6 +111,19 @@ class AuditUpdatePayload(AuditPayload):
strategy=strategy)
@base.WatcherObjectRegistry.register_notification
class AuditDeletePayload(AuditPayload):
# Version 1.0: Initial version
VERSION = '1.0'
fields = {}
def __init__(self, audit, goal, strategy):
super(AuditDeletePayload, self).__init__(
audit=audit,
goal=goal,
strategy=strategy)
# @notificationbase.notification_sample('audit-create.json')
# @notificationbase.notification_sample('audit-delete.json')
# @base.WatcherObjectRegistry.register_notification
@@ -145,6 +158,17 @@ class AuditUpdateNotification(notificationbase.NotificationBase):
}
@notificationbase.notification_sample('audit-delete.json')
@base.WatcherObjectRegistry.register_notification
class AuditDeleteNotification(notificationbase.NotificationBase):
# Version 1.0: Initial version
VERSION = '1.0'
fields = {
'payload': wfields.ObjectField('AuditDeletePayload')
}
def _get_common_payload(audit):
goal = None
strategy = None
@@ -215,3 +239,25 @@ def send_update(context, audit, service='infra-optim',
payload=versioned_payload)
notification.emit(context)
def send_delete(context, audit, service='infra-optim', host=None):
goal_payload, strategy_payload = _get_common_payload(audit)
versioned_payload = AuditDeletePayload(
audit=audit,
goal=goal_payload,
strategy=strategy_payload,
)
notification = AuditDeleteNotification(
priority=wfields.NotificationPriority.INFO,
event_type=notificationbase.EventType(
object='audit',
action=wfields.NotificationAction.DELETE),
publisher=notificationbase.NotificationPublisher(
host=host or CONF.host,
binary=service),
payload=versioned_payload)
notification.emit(context)