def _send_notification(operation, resource_type, resource_id, host=None): """Send notification to inform observers about the affected resource. This method doesn't raise an exception when sending the notification fails. :param operation: operation being performed (created, updated, or deleted) :param resource_type: type of resource being operated on :param resource_id: ID of resource being operated on :param host: resource host """ context = {} payload = {'resource_info': resource_id} service = 'identity' publisher_id = notifier_api.publisher_id(service, host=host) event_type = '%(service)s.%(resource_type)s.%(operation)s' % { 'service': service, 'resource_type': resource_type, 'operation': operation} try: notifier_api.notify( context, publisher_id, event_type, notifier_api.INFO, payload) except Exception: LOG.exception( _('Failed to send %(res_id)s %(event_type)s notification'), {'res_id': resource_id, 'event_type': event_type})
def _send_notification(operation, resource_type, resource_id, host=None): """Send notification to inform observers about the affected resource. This method doesn't raise an exception when sending the notification fails. :param operation: operation being performed (created, updated, or deleted) :param resource_type: type of resource being operated on :param resource_id: ID of resource being operated on :param host: resource host """ context = {} payload = {"resource_info": resource_id} service = "identity" publisher_id = notifier_api.publisher_id(service, host=host) event_type = "%(service)s.%(resource_type)s.%(operation)s" % { "service": service, "resource_type": resource_type, "operation": operation, } notify_event_callbacks(service, resource_type, operation, payload) try: notifier_api.notify(context, publisher_id, event_type, notifier_api.INFO, payload) except Exception: LOG.exception( _("Failed to send %(res_id)s %(event_type)s notification"), {"res_id": resource_id, "event_type": event_type}, )
def send_notification(operation, resource_type, resource_id, public=True): """Send notification to inform observers about the affected resource. This method doesn't raise an exception when sending the notification fails. :param operation: operation being performed (created, updated, or deleted) :param resource_type: type of resource being operated on :param resource_id: ID of resource being operated on :param public: if True (default), the event will be sent to the notifier API. if False, the event will only be sent via notify_event_callbacks to in process listeners. """ context = {} payload = {'resource_info': resource_id} service = 'identity' publisher_id = notifier_api.publisher_id(service) event_type = '%(service)s.%(resource_type)s.%(operation)s' % { 'service': service, 'resource_type': resource_type, 'operation': operation} notify_event_callbacks(service, resource_type, operation, payload) if public: try: notifier_api.notify( context, publisher_id, event_type, notifier_api.INFO, payload) except Exception: LOG.exception( _('Failed to send %(res_id)s %(event_type)s notification'), {'res_id': resource_id, 'event_type': event_type})
def _send_notification(operation, resource_type, resource_id): """Send notification to inform observers about the affected resource. This method doesn't raise an exception when sending the notification fails. :param operation: operation being performed (created, updated, or deleted) :param resource_type: type of resource being operated on :param resource_id: ID of resource being operated on """ context = {} payload = {'resource_info': resource_id} service = 'identity' publisher_id = notifier_api.publisher_id(service) event_type = '%(service)s.%(resource_type)s.%(operation)s' % { 'service': service, 'resource_type': resource_type, 'operation': operation } notify_event_callbacks(service, resource_type, operation, payload) try: notifier_api.notify(context, publisher_id, event_type, notifier_api.INFO, payload) except Exception: LOG.exception( _('Failed to send %(res_id)s %(event_type)s notification'), { 'res_id': resource_id, 'event_type': event_type })