Merge "Log methods using rpc communcation"
This commit is contained in:
commit
23fa27dfe4
@ -16,9 +16,12 @@
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
from oslo import messaging
|
from oslo import messaging
|
||||||
|
from oslo.messaging.rpc import dispatcher as rpc_dispatcher
|
||||||
from oslo.messaging import serializer as om_serializer
|
from oslo.messaging import serializer as om_serializer
|
||||||
|
from oslo.messaging import server as msg_server
|
||||||
|
|
||||||
from neutron.common import exceptions
|
from neutron.common import exceptions
|
||||||
|
from neutron.common import log
|
||||||
from neutron import context
|
from neutron import context
|
||||||
from neutron.openstack.common import log as logging
|
from neutron.openstack.common import log as logging
|
||||||
from neutron.openstack.common import service
|
from neutron.openstack.common import service
|
||||||
@ -90,11 +93,8 @@ def get_client(target, version_cap=None, serializer=None):
|
|||||||
def get_server(target, endpoints, serializer=None):
|
def get_server(target, endpoints, serializer=None):
|
||||||
assert TRANSPORT is not None
|
assert TRANSPORT is not None
|
||||||
serializer = RequestContextSerializer(serializer)
|
serializer = RequestContextSerializer(serializer)
|
||||||
return messaging.get_rpc_server(TRANSPORT,
|
dispatcher = RPCDispatcher(target, endpoints, serializer)
|
||||||
target,
|
return msg_server.MessageHandlingServer(TRANSPORT, dispatcher, 'eventlet')
|
||||||
endpoints,
|
|
||||||
executor='eventlet',
|
|
||||||
serializer=serializer)
|
|
||||||
|
|
||||||
|
|
||||||
def get_notifier(service=None, host=None, publisher_id=None):
|
def get_notifier(service=None, host=None, publisher_id=None):
|
||||||
@ -104,6 +104,13 @@ def get_notifier(service=None, host=None, publisher_id=None):
|
|||||||
return NOTIFIER.prepare(publisher_id=publisher_id)
|
return NOTIFIER.prepare(publisher_id=publisher_id)
|
||||||
|
|
||||||
|
|
||||||
|
class RPCDispatcher(rpc_dispatcher.RPCDispatcher):
|
||||||
|
def __call__(self, incoming):
|
||||||
|
LOG.debug('Incoming RPC: ctxt:%s message:%s', incoming.ctxt,
|
||||||
|
incoming.message)
|
||||||
|
return super(RPCDispatcher, self).__call__(incoming)
|
||||||
|
|
||||||
|
|
||||||
class RequestContextSerializer(om_serializer.Serializer):
|
class RequestContextSerializer(om_serializer.Serializer):
|
||||||
"""This serializer is used to convert RPC common context into
|
"""This serializer is used to convert RPC common context into
|
||||||
Neutron Context.
|
Neutron Context.
|
||||||
@ -157,13 +164,16 @@ class RpcProxy(object):
|
|||||||
'namespace': self.RPC_API_NAMESPACE,
|
'namespace': self.RPC_API_NAMESPACE,
|
||||||
'args': kwargs}
|
'args': kwargs}
|
||||||
|
|
||||||
|
@log.log
|
||||||
def call(self, context, msg, **kwargs):
|
def call(self, context, msg, **kwargs):
|
||||||
return self.__call_rpc_method(
|
return self.__call_rpc_method(
|
||||||
context, msg, rpc_method='call', **kwargs)
|
context, msg, rpc_method='call', **kwargs)
|
||||||
|
|
||||||
|
@log.log
|
||||||
def cast(self, context, msg, **kwargs):
|
def cast(self, context, msg, **kwargs):
|
||||||
self.__call_rpc_method(context, msg, rpc_method='cast', **kwargs)
|
self.__call_rpc_method(context, msg, rpc_method='cast', **kwargs)
|
||||||
|
|
||||||
|
@log.log
|
||||||
def fanout_cast(self, context, msg, **kwargs):
|
def fanout_cast(self, context, msg, **kwargs):
|
||||||
kwargs['fanout'] = True
|
kwargs['fanout'] = True
|
||||||
self.__call_rpc_method(context, msg, rpc_method='cast', **kwargs)
|
self.__call_rpc_method(context, msg, rpc_method='cast', **kwargs)
|
||||||
|
Loading…
Reference in New Issue
Block a user