]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Log methods using rpc communcation
authorJakub Libosvar <libosvar@redhat.com>
Fri, 11 Jul 2014 14:09:08 +0000 (16:09 +0200)
committerJakub Libosvar <libosvar@redhat.com>
Wed, 16 Jul 2014 10:37:00 +0000 (12:37 +0200)
In Icehouse was used rpc library from oslo-incubator. Because the code
wasn't mature enough it was running in DEBUG mode. After migrating to
oslo.messaging we don't need to have debug level in oslo.messaging but
it's good to have communication logged.

Closes-Bug: #1340696
Change-Id: I4f68545053912f96affc1bbcd64fcd7efe8d18c0

neutron/common/rpc.py

index 3800a683dfe0625e338edf7ef30f1e0eb4139b09..ea7e5689713de2ae22ab4104f0fbfec8f90d4d3d 100644 (file)
 
 from oslo.config import cfg
 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 server as msg_server
 
 from neutron.common import exceptions
+from neutron.common import log
 from neutron import context
 from neutron.openstack.common import log as logging
 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):
     assert TRANSPORT is not None
     serializer = RequestContextSerializer(serializer)
-    return messaging.get_rpc_server(TRANSPORT,
-                                    target,
-                                    endpoints,
-                                    executor='eventlet',
-                                    serializer=serializer)
+    dispatcher = RPCDispatcher(target, endpoints, serializer)
+    return msg_server.MessageHandlingServer(TRANSPORT, dispatcher, 'eventlet')
 
 
 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)
 
 
+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):
     """This serializer is used to convert RPC common context into
     Neutron Context.
@@ -156,13 +163,16 @@ class RpcProxy(object):
                 'namespace': self.RPC_API_NAMESPACE,
                 'args': kwargs}
 
+    @log.log
     def call(self, context, msg, **kwargs):
         return self.__call_rpc_method(
             context, msg, rpc_method='call', **kwargs)
 
+    @log.log
     def cast(self, context, msg, **kwargs):
         self.__call_rpc_method(context, msg, rpc_method='cast', **kwargs)
 
+    @log.log
     def fanout_cast(self, context, msg, **kwargs):
         kwargs['fanout'] = True
         self.__call_rpc_method(context, msg, rpc_method='cast', **kwargs)