Enable notification support
Change-Id: I6ccd2a2779ebffa02b4947465d5bfeb6158d414a
This commit is contained in:
parent
a4feb466da
commit
0388587a78
|
@ -72,6 +72,9 @@ function configure_glare {
|
|||
iniset $GLARE_CONF_FILE oslo_messaging_rabbit rabbit_userid $RABBIT_USERID
|
||||
iniset $GLARE_CONF_FILE oslo_messaging_rabbit rabbit_password $RABBIT_PASSWORD
|
||||
|
||||
# Enable notifications support
|
||||
iniset $GLARE_CONF_FILE oslo_messaging_notifications driver messaging
|
||||
|
||||
# Configure the database.
|
||||
iniset $GLARE_CONF_FILE database connection `database_connection_url glare`
|
||||
iniset $GLARE_CONF_FILE database max_overflow -1
|
||||
|
|
|
@ -70,6 +70,7 @@ def main():
|
|||
config.parse_args()
|
||||
wsgi.set_eventlet_hub()
|
||||
logging.setup(CONF, 'glare')
|
||||
notification.set_defaults()
|
||||
|
||||
if cfg.CONF.profiler.enabled:
|
||||
_notifier = osprofiler.notifier.create(
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
from oslo_messaging import serializer
|
||||
|
||||
CONF = cfg.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -31,19 +30,8 @@ def get_transport():
|
|||
return oslo_messaging.get_notification_transport(CONF)
|
||||
|
||||
|
||||
class RequestSerializer(serializer.Serializer):
|
||||
|
||||
def serialize_entity(self, context, entity):
|
||||
return entity.to_notification()
|
||||
|
||||
def deserialize_entity(self, context, entity):
|
||||
return entity
|
||||
|
||||
def serialize_context(self, context):
|
||||
return context.to_dict()
|
||||
|
||||
def deserialize_context(self, context):
|
||||
return context.from_dict(context)
|
||||
def set_defaults(control_exchange='glare'):
|
||||
oslo_messaging.set_transport_defaults(control_exchange)
|
||||
|
||||
|
||||
class Notifier(object):
|
||||
|
@ -59,8 +47,7 @@ class Notifier(object):
|
|||
if cls.GLARE_NOTIFIER is None:
|
||||
cls.GLARE_NOTIFIER = oslo_messaging.Notifier(
|
||||
get_transport(),
|
||||
publisher_id=CONF.glare_publisher_id,
|
||||
serializer=RequestSerializer())
|
||||
publisher_id=CONF.glare_publisher_id)
|
||||
return cls.GLARE_NOTIFIER
|
||||
|
||||
@classmethod
|
||||
|
@ -74,7 +61,8 @@ class Notifier(object):
|
|||
"""
|
||||
af_notifier = cls._get_notifier()
|
||||
method = getattr(af_notifier, level.lower())
|
||||
method(context, "%s.%s" % (cls.SERVICE_NAME, event_type), body)
|
||||
method({}, "%s.%s" % (cls.SERVICE_NAME, event_type),
|
||||
body.to_notification())
|
||||
LOG.debug('Notification event %(event)s send successfully for '
|
||||
'request %(request)s', {'event': event_type,
|
||||
'request': context.request_id})
|
||||
|
|
Loading…
Reference in New Issue