Scope state reporting 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 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
This commit is contained in:
Russell Bryant 2015-02-10 16:15:59 -05:00
parent 8c2423c984
commit 566be7bd25
3 changed files with 20 additions and 3 deletions

View 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):

View 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'

View 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):