def send_update(context, audit, service='infra-optim', host=None, old_state=None): """Emit an audit.update notification.""" goal_payload, strategy_payload = _get_common_payload(audit) state_update = AuditStateUpdatePayload( old_state=old_state, state=audit.state if old_state else None) versioned_payload = AuditUpdatePayload( audit=audit, state_update=state_update, goal=goal_payload, strategy=strategy_payload, ) notification = AuditUpdateNotification( priority=wfields.NotificationPriority.INFO, event_type=notificationbase.EventType( object='audit', action=wfields.NotificationAction.UPDATE), publisher=notificationbase.NotificationPublisher( host=host or CONF.host, binary=service), 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)