From 4a69b69e58cddddf8ab8ef607b12eb9e1c0709ab Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Tue, 9 Dec 2014 17:30:53 +0000 Subject: [PATCH] Scope dhcp rpc api using a messaging namespace 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 | 10 +++++++++- neutron/api/rpc/handlers/dhcp_rpc.py | 11 +++++++++-- neutron/common/constants.py | 3 +++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/neutron/agent/dhcp_agent.py b/neutron/agent/dhcp_agent.py index 1fb29a396..b849e3570 100644 --- a/neutron/agent/dhcp_agent.py +++ b/neutron/agent/dhcp_agent.py @@ -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): diff --git a/neutron/api/rpc/handlers/dhcp_rpc.py b/neutron/api/rpc/handlers/dhcp_rpc.py index 9673a65d5..4f42264d0 100644 --- a/neutron/api/rpc/handlers/dhcp_rpc.py +++ b/neutron/api/rpc/handlers/dhcp_rpc.py @@ -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.""" diff --git a/neutron/common/constants.py b/neutron/common/constants.py index f787d68f9..687bf500b 100644 --- a/neutron/common/constants.py +++ b/neutron/common/constants.py @@ -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' -- 2.45.2