Send notification messages.
The Notifier class is used for sending notification messages over a messaging transport or other means.
Notification messages follow the following format:
{'message_id': str(uuid.uuid4()),
'publisher_id': 'compute.host1',
'timestamp': timeutils.utcnow(),
'priority': 'WARN',
'event_type': 'compute.create_instance',
'payload': {'instance_id': 12, ... }}
A Notifier object can be instantiated with a transport object and a publisher ID:
notifier = notifier.Notifier(get_transport(CONF), ‘compute’)
and notifications are sent via drivers chosen with the notification_driver config option and on the topics consen with the notification_topics config option.
Alternatively, a Notifier object can be instantiated with a specific driver or topic:
notifier = notifier.Notifier(RPC_TRANSPORT,
'compute.host',
driver='messaging',
topic='notifications')
Notifier objects are relatively expensive to instantiate (mostly the cost of loading notification drivers), so it is possible to specialize a given Notifier object with a different publisher id using the prepare() method:
notifier = notifier.prepare(publisher_id='compute')
notifier.info(ctxt, event_type, payload)
Send a notification at audit level.
Parameters: |
---|
Send a notification at critical level.
Parameters: |
---|
Send a notification at debug level.
Parameters: |
---|
Send a notification at error level.
Parameters: |
---|
Send a notification at info level.
Parameters: |
---|
Return a specialized Notifier instance.
Returns a new Notifier instance with the supplied publisher_id. Allows sending notifications from multiple publisher_ids without the overhead of notification driver loading.
Parameters: | publisher_id (str) – field in notifications sent, e.g. ‘compute.host1’ |
---|
Send a notification at sample level.
Sample notifications are for high-frequency events that typically contain small payloads. eg: “CPU = 70%”
Not all drivers support the sample level (log, for example) so these could be dropped.
Parameters: |
---|
Send a notification at warning level.
Parameters: |
---|
Handler for logging to the messaging notification system.
Each time the application logs a message using the logging module, it will be sent as a notification. The severity used for the notification will be the same as the one used for the log record.
This can be used into a Python logging configuration this way:
[handler_notifier]
class=oslo.messaging.LoggingNotificationHandler
level=ERROR
args=('qpid:///')
Default configuration object used, subclass this class if you want to use another one.
Emit the log record to the messaging notification system.
Parameters: | record – A log record to emit. |
---|