]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Scope dhcp rpc api using a messaging namespace
authorRussell Bryant <rbryant@redhat.com>
Tue, 9 Dec 2014 17:30:53 +0000 (17:30 +0000)
committerRussell Bryant <rbryant@redhat.com>
Fri, 19 Dec 2014 13:33:48 +0000 (13:33 +0000)
This patch updates the rpc API used by the DHCP agent to make calls
back into the neutron plugin to use the 'dhcp' namespace instead of
the default namespace.  The reason is that this API is exposed over
the 'q-plugin' topic along with several other interfaces.  Without the
use of namespaces, all of the interfaces are effectively treated as
one by oslo.messaging.  When a namespace is used, the interface can be
versioned independently and when a method is called, the only class
considered for fulfilling the request is the one that claims to
implement the 'dhcp' namespace.

While we're here, add documentation to both the client and server side
of this interface that indicates where the other side is located.

Part of blueprint rpc-docs-and-namespaces.

Change-Id: I9e56aa34fc560ae3fc749c51788436e32179d0a1

neutron/agent/dhcp_agent.py
neutron/api/rpc/handlers/dhcp_rpc.py
neutron/common/constants.py

index 1fb29a396459654fd1e267720efe95b3c3b11900..b849e357048ca04061833cff4124b0d78bdc4430 100644 (file)
@@ -404,6 +404,11 @@ class DhcpAgent(manager.Manager):
 class DhcpPluginApi(object):
     """Agent side of the dhcp rpc API.
 
+    This class implements the client side of an rpc interface.  The server side
+    of this interface can be found in
+    neutron.api.rpc.handlers.dhcp_rpc.DhcpRpcCallback.  For more information
+    about changing rpc interfaces, see doc/source/devref/rpc_api.rst.
+
     API version history:
         1.0 - Initial version.
         1.1 - Added get_active_networks_info, create_dhcp_port,
@@ -415,7 +420,10 @@ class DhcpPluginApi(object):
         self.context = context
         self.host = cfg.CONF.host
         self.use_namespaces = use_namespaces
-        target = messaging.Target(topic=topic, version='1.0')
+        target = messaging.Target(
+                topic=topic,
+                namespace=constants.RPC_NAMESPACE_DHCP_PLUGIN,
+                version='1.0')
         self.client = n_rpc.get_client(target)
 
     def get_active_networks_info(self):
index 9673a65d5af58490ec55559f62b11b441f561db5..4f42264d06d8f78f60c115fb1d85c04da38aac84 100644 (file)
@@ -32,13 +32,20 @@ LOG = logging.getLogger(__name__)
 
 
 class DhcpRpcCallback(object):
-    """DHCP agent RPC callback in plugin implementations."""
+    """DHCP agent RPC callback in plugin implementations.
+
+    This class implements the server side of an rpc interface.  The client
+    side of this interface can be found in
+    neutron.agent.dhcp_agent.DhcpPluginApi.  For more information about
+    changing rpc interfaces, see doc/source/devref/rpc_api.rst.
+    """
 
     # API version history:
     #     1.0 - Initial version.
     #     1.1 - Added get_active_networks_info, create_dhcp_port,
     #           and update_dhcp_port methods.
-    target = messaging.Target(version='1.1')
+    target = messaging.Target(namespace=constants.RPC_NAMESPACE_DHCP_PLUGIN,
+                              version='1.1')
 
     def _get_active_networks(self, context, **kwargs):
         """Retrieve and return a list of the active networks."""
index f787d68f9a6bb34e7f35bf5e17c0d5707ed0ec79..687bf500b86cbf8932c75a6e6d1a7526fa14bf05 100644 (file)
@@ -137,3 +137,6 @@ ATTRIBUTES_TO_UPDATE = 'attributes_to_update'
 # In SQLite integer can be stored in 1, 2, 3, 4, 6, or 8 bytes,
 # but here it will be limited by this value for consistency.
 DB_INTEGER_MAX_VALUE = 2 ** 31 - 1
+
+# RPC Interface for agents to call DHCP API implemented on the plugin side
+RPC_NAMESPACE_DHCP_PLUGIN = 'dhcp'