Merge "Use messaging notifications transport instead of default"

This commit is contained in:
Jenkins 2016-04-22 13:47:26 +00:00 committed by Gerrit Code Review
commit 68398b0a3a

View File

@ -42,6 +42,7 @@ from cinder.objects import base
CONF = cfg.CONF CONF = cfg.CONF
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
TRANSPORT = None TRANSPORT = None
NOTIFICATION_TRANSPORT = None
NOTIFIER = None NOTIFIER = None
ALLOWED_EXMODS = [ ALLOWED_EXMODS = [
@ -63,14 +64,19 @@ TRANSPORT_ALIASES = {
def init(conf): def init(conf):
global TRANSPORT, NOTIFIER global TRANSPORT, NOTIFICATION_TRANSPORT, NOTIFIER
exmods = get_allowed_exmods() exmods = get_allowed_exmods()
TRANSPORT = messaging.get_transport(conf, TRANSPORT = messaging.get_transport(conf,
allowed_remote_exmods=exmods, allowed_remote_exmods=exmods,
aliases=TRANSPORT_ALIASES) aliases=TRANSPORT_ALIASES)
NOTIFICATION_TRANSPORT = messaging.get_notification_transport(
conf,
allowed_remote_exmods=exmods,
aliases=TRANSPORT_ALIASES)
serializer = RequestContextSerializer(JsonPayloadSerializer()) serializer = RequestContextSerializer(JsonPayloadSerializer())
NOTIFIER = messaging.Notifier(TRANSPORT, serializer=serializer) NOTIFIER = messaging.Notifier(NOTIFICATION_TRANSPORT,
serializer=serializer)
def initialized(): def initialized():
@ -78,11 +84,13 @@ def initialized():
def cleanup(): def cleanup():
global TRANSPORT, NOTIFIER global TRANSPORT, NOTIFICATION_TRANSPORT, NOTIFIER
assert TRANSPORT is not None assert TRANSPORT is not None
assert NOTIFICATION_TRANSPORT is not None
assert NOTIFIER is not None assert NOTIFIER is not None
TRANSPORT.cleanup() TRANSPORT.cleanup()
TRANSPORT = NOTIFIER = None NOTIFICATION_TRANSPORT.cleanup()
TRANSPORT = NOTIFICATION_TRANSPORT = NOTIFIER = None
def set_defaults(control_exchange): def set_defaults(control_exchange):