Rename context to ctxt in notify API
ctxt is the name we've used in the rest of oslo.messaging, so ...
This commit is contained in:
parent
eb94be8834
commit
fcfe15af04
oslo/messaging/notify
@ -27,7 +27,7 @@ class LogDriver(notifier._Driver):
|
||||
|
||||
LOGGER_BASE = 'oslo.messaging.notification'
|
||||
|
||||
def notify(self, context, message, priority):
|
||||
def notify(self, ctxt, message, priority):
|
||||
logger = logging.getLogger('%s.%s' % (self.LOGGER_BASE,
|
||||
message['event_type']))
|
||||
getattr(logger, priority)(jsonutils.dumps(message))
|
||||
|
@ -38,11 +38,11 @@ class MessagingDriver(notifier._Driver):
|
||||
super(MessagingDriver, self).__init__(conf, topics, transport)
|
||||
self.envelope = envelope
|
||||
|
||||
def notify(self, context, message, priority):
|
||||
def notify(self, ctxt, message, priority):
|
||||
for topic in self.topics:
|
||||
target = messaging.Target(topic='%s.%s' % (topic, priority))
|
||||
try:
|
||||
self.transport._send(target, context, message,
|
||||
self.transport._send(target, ctxt, message,
|
||||
envelope=self.envelope)
|
||||
except Exception:
|
||||
LOG.exception("Could not send notification to %(topic)s. "
|
||||
|
@ -20,5 +20,5 @@ from oslo.messaging.notify import notifier
|
||||
|
||||
class NoOpDriver(notifier._Driver):
|
||||
|
||||
def notify(self, context, message, priority):
|
||||
def notify(self, ctxt, message, priority):
|
||||
pass
|
||||
|
@ -26,5 +26,5 @@ class TestDriver(notifier._Driver):
|
||||
super(TestDriver, self).__init__(conf, **kwargs)
|
||||
self.notifications = []
|
||||
|
||||
def notify(self, context, message, priority):
|
||||
def notify(self, ctxt, message, priority):
|
||||
self.notifications.append(message)
|
||||
|
@ -49,7 +49,7 @@ class _Driver(object):
|
||||
self.transport = transport
|
||||
|
||||
@abc.abstractmethod
|
||||
def notify(self, context, msg, priority):
|
||||
def notify(self, ctxt, msg, priority):
|
||||
pass
|
||||
|
||||
|
||||
@ -126,7 +126,7 @@ class Notifier(object):
|
||||
},
|
||||
)
|
||||
|
||||
def _notify(self, context, event_type, payload, priority):
|
||||
def _notify(self, ctxt, event_type, payload, priority):
|
||||
msg = dict(message_id=uuidutils.generate_uuid(),
|
||||
publisher_id=self.publisher_id,
|
||||
event_type=event_type,
|
||||
@ -136,69 +136,69 @@ class Notifier(object):
|
||||
|
||||
def do_notify(ext):
|
||||
try:
|
||||
ext.obj.notify(context, msg, priority)
|
||||
ext.obj.notify(ctxt, msg, priority)
|
||||
except Exception as e:
|
||||
LOG.exception("Problem '%(e)s' attempting to send to "
|
||||
"notification system. Payload=%(payload)s",
|
||||
dict(e=e, payload=payload))
|
||||
self._driver_mgr.map(do_notify)
|
||||
|
||||
def debug(self, context, event_type, payload):
|
||||
def debug(self, ctxt, event_type, payload):
|
||||
"""Send a notification at debug level.
|
||||
|
||||
:param context: a request context dict
|
||||
:type context: dict
|
||||
:param ctxt: a request context dict
|
||||
:type ctxt: dict
|
||||
:param event_type: describes the event, e.g. 'compute.create_instance'
|
||||
:type event_type: str
|
||||
:param payload: the notification payload
|
||||
:type payload: dict
|
||||
"""
|
||||
self._notify(context, event_type, payload, 'DEBUG')
|
||||
self._notify(ctxt, event_type, payload, 'DEBUG')
|
||||
|
||||
def info(self, context, event_type, payload):
|
||||
def info(self, ctxt, event_type, payload):
|
||||
"""Send a notification at info level.
|
||||
|
||||
:param context: a request context dict
|
||||
:type context: dict
|
||||
:param ctxt: a request context dict
|
||||
:type ctxt: dict
|
||||
:param event_type: describes the event, e.g. 'compute.create_instance'
|
||||
:type event_type: str
|
||||
:param payload: the notification payload
|
||||
:type payload: dict
|
||||
"""
|
||||
self._notify(context, event_type, payload, 'INFO')
|
||||
self._notify(ctxt, event_type, payload, 'INFO')
|
||||
|
||||
def warn(self, context, event_type, payload):
|
||||
def warn(self, ctxt, event_type, payload):
|
||||
"""Send a notification at warning level.
|
||||
|
||||
:param context: a request context dict
|
||||
:type context: dict
|
||||
:param ctxt: a request context dict
|
||||
:type ctxt: dict
|
||||
:param event_type: describes the event, e.g. 'compute.create_instance'
|
||||
:type event_type: str
|
||||
:param payload: the notification payload
|
||||
:type payload: dict
|
||||
"""
|
||||
self._notify(context, event_type, payload, 'WARN')
|
||||
self._notify(ctxt, event_type, payload, 'WARN')
|
||||
|
||||
def error(self, context, event_type, payload):
|
||||
def error(self, ctxt, event_type, payload):
|
||||
"""Send a notification at error level.
|
||||
|
||||
:param context: a request context dict
|
||||
:type context: dict
|
||||
:param ctxt: a request context dict
|
||||
:type ctxt: dict
|
||||
:param event_type: describes the event, e.g. 'compute.create_instance'
|
||||
:type event_type: str
|
||||
:param payload: the notification payload
|
||||
:type payload: dict
|
||||
"""
|
||||
self._notify(context, event_type, payload, 'ERROR')
|
||||
self._notify(ctxt, event_type, payload, 'ERROR')
|
||||
|
||||
def critical(self, context, event_type, payload):
|
||||
def critical(self, ctxt, event_type, payload):
|
||||
"""Send a notification at critical level.
|
||||
|
||||
:param context: a request context dict
|
||||
:type context: dict
|
||||
:param ctxt: a request context dict
|
||||
:type ctxt: dict
|
||||
:param event_type: describes the event, e.g. 'compute.create_instance'
|
||||
:type event_type: str
|
||||
:param payload: the notification payload
|
||||
:type payload: dict
|
||||
"""
|
||||
self._notify(context, event_type, payload, 'CRITICAL')
|
||||
self._notify(ctxt, event_type, payload, 'CRITICAL')
|
||||
|
Loading…
x
Reference in New Issue
Block a user