]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Scope state reporting rpc api using a messaging namespace
authorRussell Bryant <rbryant@redhat.com>
Tue, 10 Feb 2015 21:15:59 +0000 (16:15 -0500)
committerRussell Bryant <rbryant@redhat.com>
Tue, 10 Feb 2015 21:15:59 +0000 (16:15 -0500)
This patch does a couple of things.  First it adds docstrings to the
client/server pair of the rpc interface used by an agent to report
state back to the plugin.  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: I832db5c81780d98157a68d4abaf9787ba00adbeb

neutron/agent/rpc.py
neutron/common/constants.py
neutron/db/agents_db.py

index 9909856e0f3ae959e6c86ff72f8d01de4de4e948..297b88c2c5aa0477c211c67e4f0aaf16ba5243d4 100644 (file)
@@ -17,6 +17,7 @@ import itertools
 import oslo_messaging
 from oslo_utils import timeutils
 
+from neutron.common import constants
 from neutron.common import rpc as n_rpc
 from neutron.common import topics
 from neutron.i18n import _LW
@@ -57,8 +58,15 @@ def create_consumers(endpoints, prefix, topic_details, start_listening=True):
 
 
 class PluginReportStateAPI(object):
+    """RPC client used to report state back to plugin.
+
+    This class implements the client side of an rpc interface.  The server side
+    can be found in neutron.db.agents_db.AgentExtRpcCallback.  For more
+    information on changing rpc interfaces, see doc/source/devref/rpc_api.rst.
+    """
     def __init__(self, topic):
-        target = oslo_messaging.Target(topic=topic, version='1.0')
+        target = oslo_messaging.Target(topic=topic, version='1.0',
+                                       namespace=constants.RPC_NAMESPACE_STATE)
         self.client = n_rpc.get_client(target)
 
     def report_state(self, context, agent_state, use_call=False):
index 26d6724bd784a5b5d08e34a6d3ae7154efb723d5..4b16165a07436ea8e8fcc8a0e581993886229954 100644 (file)
@@ -153,3 +153,5 @@ RPC_NAMESPACE_METADATA = 'metadata'
 RPC_NAMESPACE_SECGROUP = 'secgroup'
 # RPC interface for agent to plugin DVR api
 RPC_NAMESPACE_DVR = 'dvr'
+# RPC interface for reporting state back to the plugin
+RPC_NAMESPACE_STATE = 'report_state'
index 545039ef2243848413668b37ee36a4b476fc37ab..6cae2084be171290413327db49b55a87382e7020 100644 (file)
@@ -25,6 +25,7 @@ from sqlalchemy.orm import exc
 from sqlalchemy import sql
 
 from neutron.api.v2 import attributes
+from neutron.common import constants
 from neutron.db import model_base
 from neutron.db import models_v2
 from neutron.extensions import agent as ext_agent
@@ -220,9 +221,15 @@ class AgentDbMixin(ext_agent.AgentPluginBase):
 
 
 class AgentExtRpcCallback(object):
-    """Processes the rpc report in plugin implementations."""
+    """Processes the rpc report in plugin implementations.
 
-    target = oslo_messaging.Target(version='1.0')
+    This class implements the server side of an rpc interface.  The client side
+    can be found in neutron.agent.rpc.PluginReportStateAPI.  For more
+    information on changing rpc interfaces, see doc/source/devref/rpc_api.rst.
+    """
+
+    target = oslo_messaging.Target(version='1.0',
+                                   namespace=constants.RPC_NAMESPACE_STATE)
     START_TIME = timeutils.utcnow()
 
     def __init__(self, plugin=None):