From: Russell Bryant Date: Thu, 18 Dec 2014 20:11:07 +0000 (+0000) Subject: Scope metadata rpc api using a messaging namespace X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=caedc3ee059fd3c76306fe0bf5d5e4c9c95dcb31;p=openstack-build%2Fneutron-build.git Scope metadata rpc api using a messaging namespace This patch does a couple of things. First it adds docstrings to the client/server pair of the rpc interface used by the metadata service to make calls back into the Neutron server. The docs tell you where the other side of the interface is found in the code, and where docs are that give more info on the rules for changing them. The second thing done in this patch is to scope this interface using a messaging namespace. Right now some plugins expose several interfaces via the default namespace. This effectively means they are a single API and should be managed with a single version stream. It's much more managable to just treat these as separate interfaces and this change makes that explicit and functionally true. Now when a method is invoked, the only classes considered for handling that request will be ones marked with the right namespace. Part of blueprint rpc-docs-and-namespaces. Change-Id: I3330229bf85b01d50c90e9ca064ae5e0fae83509 --- diff --git a/neutron/agent/metadata/agent.py b/neutron/agent/metadata/agent.py index fef96e92d..06c68ac74 100644 --- a/neutron/agent/metadata/agent.py +++ b/neutron/agent/metadata/agent.py @@ -47,14 +47,23 @@ LOG = logging.getLogger(__name__) class MetadataPluginAPI(object): - """Agent-side RPC (stub) for agent-to-plugin interaction. + """Agent-side RPC for metadata agent-to-plugin interaction. + + This class implements the client side of an rpc interface used by the + metadata service to make calls back into the Neutron plugin. The server + side is defined in + neutron.api.rpc.handlers.metadata_rpc.MetadataRpcCallback. For more + information about changing rpc interfaces, see + doc/source/devref/rpc_api.rst. API version history: 1.0 - Initial version. """ def __init__(self, topic): - target = messaging.Target(topic=topic, version='1.0') + target = messaging.Target(topic=topic, + namespace=n_const.RPC_NAMESPACE_METADATA, + version='1.0') self.client = n_rpc.get_client(target) def get_ports(self, context, filters): diff --git a/neutron/api/rpc/handlers/metadata_rpc.py b/neutron/api/rpc/handlers/metadata_rpc.py index acd59610c..c8533b652 100644 --- a/neutron/api/rpc/handlers/metadata_rpc.py +++ b/neutron/api/rpc/handlers/metadata_rpc.py @@ -15,14 +15,23 @@ from oslo import messaging +from neutron.common import constants from neutron import manager class MetadataRpcCallback(object): - """Metadata agent RPC callback in plugin implementations.""" + """Metadata agent RPC callback in plugin implementations. + + This class implements the server side of an rpc interface used by the + metadata service to make calls back into the Neutron plugin. The client + side is defined in neutron.agent.metadata.agent.MetadataPluginAPI. For + more information about changing rpc interfaces, see + doc/source/devref/rpc_api.rst. + """ # 1.0 MetadataPluginAPI BASE_RPC_API_VERSION - target = messaging.Target(version='1.0') + target = messaging.Target(version='1.0', + namespace=constants.RPC_NAMESPACE_METADATA) @property def plugin(self): diff --git a/neutron/common/constants.py b/neutron/common/constants.py index bdaac61a0..c70773b85 100644 --- a/neutron/common/constants.py +++ b/neutron/common/constants.py @@ -145,3 +145,5 @@ 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' +# RPC interface for the metadata service to get info from the plugin side +RPC_NAMESPACE_METADATA = 'metadata'