Merge "Pass serializer to oslo.messaging Notifier"

This commit is contained in:
Jenkins 2014-06-23 09:50:56 +00:00 committed by Gerrit Code Review
commit 50fbd21a8d
2 changed files with 10 additions and 7 deletions

View File

@ -52,7 +52,8 @@ def init(conf):
TRANSPORT = messaging.get_transport(conf,
allowed_remote_exmods=exmods,
aliases=TRANSPORT_ALIASES)
NOTIFIER = messaging.Notifier(TRANSPORT)
serializer = RequestContextSerializer()
NOTIFIER = messaging.Notifier(TRANSPORT, serializer=serializer)
def cleanup():
@ -77,7 +78,7 @@ def get_allowed_exmods():
def get_client(target, version_cap=None, serializer=None):
assert TRANSPORT is not None
serializer = PluginRpcSerializer(serializer)
serializer = RequestContextSerializer(serializer)
return messaging.RPCClient(TRANSPORT,
target,
version_cap=version_cap,
@ -86,7 +87,7 @@ def get_client(target, version_cap=None, serializer=None):
def get_server(target, endpoints, serializer=None):
assert TRANSPORT is not None
serializer = PluginRpcSerializer(serializer)
serializer = RequestContextSerializer(serializer)
return messaging.get_rpc_server(TRANSPORT,
target,
endpoints,
@ -101,12 +102,12 @@ def get_notifier(service=None, host=None, publisher_id=None):
return NOTIFIER.prepare(publisher_id=publisher_id)
class PluginRpcSerializer(om_serializer.Serializer):
class RequestContextSerializer(om_serializer.Serializer):
"""This serializer is used to convert RPC common context into
Neutron Context.
"""
def __init__(self, base):
super(PluginRpcSerializer, self).__init__()
def __init__(self, base=None):
super(RequestContextSerializer, self).__init__()
self._base = base
def serialize_entity(self, ctxt, entity):

View File

@ -30,7 +30,9 @@ FakeMessage = collections.namedtuple('Message',
class FakeNotifier(object):
def __init__(self, transport, publisher_id=None):
def __init__(self, transport, publisher_id=None,
driver=None, topic=None,
serializer=None, retry=None):
self.transport = transport
self.publisher_id = publisher_id
for priority in ('debug', 'info', 'warn', 'error', 'critical'):