Convert several uses of RpcCallback

Convert several places in the code that were using the RpcCallback
compatibility class.  This class eased the transition to
oslo.messaging.  This patch drops the usage of this class in favor of
direct usage of the appropriate oslo.messaging API.

Part of blueprint drop-rpc-compat.

Change-Id: I955958e836635d43dabc7b39d050c1418b18cf8f
This commit is contained in:
Russell Bryant 2014-12-02 21:16:19 +00:00
parent 9af3457fb2
commit f76110be99
25 changed files with 73 additions and 93 deletions

View File

@ -441,7 +441,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback,
- del_arp_entry - del_arp_entry
Needed by the L3 service when dealing with DVR Needed by the L3 service when dealing with DVR
""" """
RPC_API_VERSION = '1.2' target = messaging.Target(version='1.2')
OPTS = [ OPTS = [
cfg.StrOpt('agent_mode', default='legacy', cfg.StrOpt('agent_mode', default='legacy',

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo import messaging
from neutron.common import constants as consts from neutron.common import constants as consts
from neutron.common import utils from neutron.common import utils
from neutron.i18n import _LE from neutron.i18n import _LE
@ -24,7 +26,7 @@ LOG = logging.getLogger(__name__)
class MeteringRpcCallbacks(object): class MeteringRpcCallbacks(object):
RPC_API_VERSION = '1.0' target = messaging.Target(version='1.0')
def __init__(self, meter_plugin): def __init__(self, meter_plugin):
self.meter_plugin = meter_plugin self.meter_plugin = meter_plugin

View File

@ -16,9 +16,9 @@
import weakref import weakref
from oslo.config import cfg from oslo.config import cfg
from oslo import messaging
from oslo.utils import importutils from oslo.utils import importutils
from neutron.common import rpc as n_rpc
from neutron.common import utils from neutron.common import utils
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.openstack.common import periodic_task from neutron.openstack.common import periodic_task
@ -30,10 +30,10 @@ from stevedore import driver
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class Manager(n_rpc.RpcCallback, periodic_task.PeriodicTasks): class Manager(periodic_task.PeriodicTasks):
# Set RPC API version to 1.0 by default. # Set RPC API version to 1.0 by default.
RPC_API_VERSION = '1.0' target = messaging.Target(version='1.0')
def __init__(self, host=None): def __init__(self, host=None):
if not host: if not host:

View File

@ -23,6 +23,7 @@ import eventlet
eventlet.monkey_patch() eventlet.monkey_patch()
from oslo.config import cfg from oslo.config import cfg
from oslo import messaging
from oslo.utils import excutils from oslo.utils import excutils
from neutron.agent.linux import ovs_lib from neutron.agent.linux import ovs_lib
@ -30,7 +31,6 @@ from neutron.agent.linux import utils
from neutron.agent import rpc as agent_rpc from neutron.agent import rpc as agent_rpc
from neutron.agent import securitygroups_rpc as sg_rpc from neutron.agent import securitygroups_rpc as sg_rpc
from neutron.common import config from neutron.common import config
from neutron.common import rpc as n_rpc
from neutron.common import topics from neutron.common import topics
from neutron import context as q_context from neutron import context as q_context
from neutron.extensions import securitygroup as ext_sg from neutron.extensions import securitygroup as ext_sg
@ -84,10 +84,9 @@ class SecurityGroupAgent(sg_rpc.SecurityGroupAgentRpcMixin):
self.init_firewall() self.init_firewall()
class RestProxyAgent(n_rpc.RpcCallback, class RestProxyAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
sg_rpc.SecurityGroupAgentRpcCallbackMixin):
RPC_API_VERSION = '1.1' target = messaging.Target(version='1.1')
def __init__(self, integ_br, polling_interval, root_helper, vs='ovs'): def __init__(self, integ_br, polling_interval, root_helper, vs='ovs'):
super(RestProxyAgent, self).__init__() super(RestProxyAgent, self).__init__()

View File

@ -94,7 +94,7 @@ class CiscoCfgAgent(manager.Manager):
The main entry points in this class are the `process_services()` and The main entry points in this class are the `process_services()` and
`_backlog_task()` . `_backlog_task()` .
""" """
RPC_API_VERSION = '1.1' target = messaging.Target(version='1.1')
OPTS = [ OPTS = [
cfg.IntOpt('rpc_loop_interval', default=10, cfg.IntOpt('rpc_loop_interval', default=10,

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo import messaging
from neutron.common import rpc as n_rpc from neutron.common import rpc as n_rpc
from neutron.common import topics from neutron.common import topics
from neutron.db import agents_db from neutron.db import agents_db
@ -25,10 +27,10 @@ from neutron.plugins.cisco.l3.rpc import devices_cfgagent_rpc_cb as devices_rpc
from neutron.plugins.common import constants from neutron.plugins.common import constants
class CiscoRouterPluginRpcCallbacks(n_rpc.RpcCallback, class CiscoRouterPluginRpcCallbacks(l3_router_rpc.L3RouterCfgRpcCallbackMixin,
l3_router_rpc.L3RouterCfgRpcCallbackMixin,
devices_rpc.DeviceCfgRpcCallbackMixin): devices_rpc.DeviceCfgRpcCallbackMixin):
RPC_API_VERSION = '1.1'
target = messaging.Target(version='1.1')
def __init__(self, l3plugin): def __init__(self, l3plugin):
super(CiscoRouterPluginRpcCallbacks, self).__init__() super(CiscoRouterPluginRpcCallbacks, self).__init__()

View File

@ -30,7 +30,6 @@ from neutron.agent import rpc as agent_rpc
from neutron.agent import securitygroups_rpc as sg_rpc from neutron.agent import securitygroups_rpc as sg_rpc
from neutron.common import config as common_config from neutron.common import config as common_config
from neutron.common import constants as n_const from neutron.common import constants as n_const
from neutron.common import rpc as n_rpc
from neutron.common import topics from neutron.common import topics
from neutron import context from neutron import context
from neutron.i18n import _LE, _LI from neutron.i18n import _LE, _LI
@ -79,10 +78,9 @@ CONF.register_opts(agent_opts, "AGENT")
config.register_agent_state_opts_helper(cfg.CONF) config.register_agent_state_opts_helper(cfg.CONF)
class HyperVSecurityAgent(n_rpc.RpcCallback, class HyperVSecurityAgent(sg_rpc.SecurityGroupAgentRpcMixin):
sg_rpc.SecurityGroupAgentRpcMixin):
# Set RPC API version to 1.1 by default. target = messaging.Target(version='1.1')
RPC_API_VERSION = '1.1'
def __init__(self, context, plugin_rpc): def __init__(self, context, plugin_rpc):
super(HyperVSecurityAgent, self).__init__() super(HyperVSecurityAgent, self).__init__()
@ -103,10 +101,9 @@ class HyperVSecurityAgent(n_rpc.RpcCallback,
consumers) consumers)
class HyperVSecurityCallbackMixin(n_rpc.RpcCallback, class HyperVSecurityCallbackMixin(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
sg_rpc.SecurityGroupAgentRpcCallbackMixin):
# Set RPC API version to 1.1 by default. target = messaging.Target(version='1.1')
RPC_API_VERSION = '1.1'
def __init__(self, sg_agent): def __init__(self, sg_agent):
super(HyperVSecurityCallbackMixin, self).__init__() super(HyperVSecurityCallbackMixin, self).__init__()

View File

@ -27,6 +27,7 @@ import eventlet
eventlet.monkey_patch() eventlet.monkey_patch()
from oslo.config import cfg from oslo.config import cfg
from oslo import messaging
from six import moves from six import moves
from neutron.agent import l2population_rpc as l2pop_rpc from neutron.agent import l2population_rpc as l2pop_rpc
@ -37,7 +38,6 @@ from neutron.agent import securitygroups_rpc as sg_rpc
from neutron.common import config as common_config from neutron.common import config as common_config
from neutron.common import constants from neutron.common import constants
from neutron.common import exceptions from neutron.common import exceptions
from neutron.common import rpc as n_rpc
from neutron.common import topics from neutron.common import topics
from neutron.common import utils as q_utils from neutron.common import utils as q_utils
from neutron import context from neutron import context
@ -643,14 +643,13 @@ class LinuxBridgeManager:
self.remove_fdb_bridge_entry(mac, agent_ip, interface) self.remove_fdb_bridge_entry(mac, agent_ip, interface)
class LinuxBridgeRpcCallbacks(n_rpc.RpcCallback, class LinuxBridgeRpcCallbacks(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
sg_rpc.SecurityGroupAgentRpcCallbackMixin,
l2pop_rpc.L2populationRpcCallBackMixin): l2pop_rpc.L2populationRpcCallBackMixin):
# Set RPC API version to 1.0 by default. # Set RPC API version to 1.0 by default.
# history # history
# 1.1 Support Security Group RPC # 1.1 Support Security Group RPC
RPC_API_VERSION = '1.1' target = messaging.Target(version='1.1')
def __init__(self, context, agent): def __init__(self, context, agent):
super(LinuxBridgeRpcCallbacks, self).__init__() super(LinuxBridgeRpcCallbacks, self).__init__()

View File

@ -58,7 +58,7 @@ LOG = logging.getLogger(__name__)
class ApicTopologyService(manager.Manager): class ApicTopologyService(manager.Manager):
RPC_API_VERSION = '1.1' target = messaging.Target(version='1.1')
def __init__(self, host=None): def __init__(self, host=None):
if host is None: if host is None:

View File

@ -35,10 +35,8 @@ from neutron.plugins.ml2.drivers import type_tunnel
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
class RpcCallbacks(n_rpc.RpcCallback, class RpcCallbacks(type_tunnel.TunnelRpcCallbackMixin):
type_tunnel.TunnelRpcCallbackMixin):
RPC_API_VERSION = '1.3'
# history # history
# 1.0 Initial version (from openvswitch/linuxbridge) # 1.0 Initial version (from openvswitch/linuxbridge)
# 1.1 Support Security Group RPC # 1.1 Support Security Group RPC
@ -46,6 +44,7 @@ class RpcCallbacks(n_rpc.RpcCallback,
# 1.3 get_device_details rpc signature upgrade to obtain 'host' and # 1.3 get_device_details rpc signature upgrade to obtain 'host' and
# return value to include fixed_ips and device_owner for # return value to include fixed_ips and device_owner for
# the device port # the device port
target = messaging.Target(version='1.3')
def __init__(self, notifier, type_manager): def __init__(self, notifier, type_manager):
self.setup_tunnel_callback_mixin(notifier, type_manager) self.setup_tunnel_callback_mixin(notifier, type_manager)

View File

@ -22,12 +22,12 @@ import eventlet
eventlet.monkey_patch() eventlet.monkey_patch()
from oslo.config import cfg from oslo.config import cfg
from oslo import messaging
from neutron.agent import rpc as agent_rpc from neutron.agent import rpc as agent_rpc
from neutron.agent import securitygroups_rpc as sg_rpc from neutron.agent import securitygroups_rpc as sg_rpc
from neutron.common import config as common_config from neutron.common import config as common_config
from neutron.common import constants as q_constants from neutron.common import constants as q_constants
from neutron.common import rpc as n_rpc
from neutron.common import topics from neutron.common import topics
from neutron.common import utils as q_utils from neutron.common import utils as q_utils
from neutron import context from neutron import context
@ -144,13 +144,12 @@ class EswitchManager(object):
self.network_map[network_id] = data self.network_map[network_id] = data
class MlnxEswitchRpcCallbacks(n_rpc.RpcCallback, class MlnxEswitchRpcCallbacks(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
sg_rpc.SecurityGroupAgentRpcCallbackMixin):
# Set RPC API version to 1.0 by default. # Set RPC API version to 1.0 by default.
# history # history
# 1.1 Support Security Group RPC # 1.1 Support Security Group RPC
RPC_API_VERSION = '1.1' target = messaging.Target(version='1.1')
def __init__(self, context, agent): def __init__(self, context, agent):
super(MlnxEswitchRpcCallbacks, self).__init__() super(MlnxEswitchRpcCallbacks, self).__init__()
@ -181,8 +180,6 @@ class MlnxEswitchPluginApi(agent_rpc.PluginApi,
class MlnxEswitchNeutronAgent(sg_rpc.SecurityGroupAgentRpcMixin): class MlnxEswitchNeutronAgent(sg_rpc.SecurityGroupAgentRpcMixin):
# Set RPC API version to 1.0 by default.
#RPC_API_VERSION = '1.0'
def __init__(self, interface_mapping): def __init__(self, interface_mapping):
self._polling_interval = cfg.CONF.AGENT.polling_interval self._polling_interval = cfg.CONF.AGENT.polling_interval

View File

@ -12,10 +12,11 @@
# implied. # implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from oslo.config import cfg from oslo.config import cfg
from oslo import messaging
from neutron.common import constants as q_const from neutron.common import constants as q_const
from neutron.common import rpc as n_rpc
from neutron.db import api as db_api from neutron.db import api as db_api
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
@ -24,11 +25,11 @@ from neutron.plugins.mlnx.db import mlnx_db_v2 as db
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class MlnxRpcCallbacks(n_rpc.RpcCallback): class MlnxRpcCallbacks(object):
# History # History
# 1.1 Support Security Group RPC # 1.1 Support Security Group RPC
# 1.2 Support get_devices_details_list # 1.2 Support get_devices_details_list
RPC_API_VERSION = '1.2' target = messaging.Target(version='1.2')
def get_device_details(self, rpc_context, **kwargs): def get_device_details(self, rpc_context, **kwargs):
"""Agent requests device details.""" """Agent requests device details."""

View File

@ -60,9 +60,9 @@ class NECPluginApi(agent_rpc.PluginApi):
port_removed=port_removed) port_removed=port_removed)
class NECAgentRpcCallback(n_rpc.RpcCallback): class NECAgentRpcCallback(object):
RPC_API_VERSION = '1.0' target = messaging.Target(version='1.0')
def __init__(self, context, agent, sg_agent): def __init__(self, context, agent, sg_agent):
super(NECAgentRpcCallback, self).__init__() super(NECAgentRpcCallback, self).__init__()
@ -90,11 +90,9 @@ class SecurityGroupServerRpcApi(sg_rpc.SecurityGroupServerRpcApiMixin):
self.client = n_rpc.get_client(target) self.client = n_rpc.get_client(target)
class SecurityGroupAgentRpcCallback( class SecurityGroupAgentRpcCallback(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
n_rpc.RpcCallback,
sg_rpc.SecurityGroupAgentRpcCallbackMixin):
RPC_API_VERSION = sg_rpc.SG_RPC_VERSION target = messaging.Target(version=sg_rpc.SG_RPC_VERSION)
def __init__(self, context, sg_agent): def __init__(self, context, sg_agent):
super(SecurityGroupAgentRpcCallback, self).__init__() super(SecurityGroupAgentRpcCallback, self).__init__()

View File

@ -688,9 +688,9 @@ class NECPluginV2AgentNotifierApi(sg_rpc.SecurityGroupAgentRpcApiMixin):
cctxt.cast(context, 'port_update', port=port) cctxt.cast(context, 'port_update', port=port)
class NECPluginV2RPCCallbacks(n_rpc.RpcCallback): class NECPluginV2RPCCallbacks(object):
RPC_API_VERSION = '1.0' target = messaging.Target(version='1.0')
def __init__(self, plugin): def __init__(self, plugin):
super(NECPluginV2RPCCallbacks, self).__init__() super(NECPluginV2RPCCallbacks, self).__init__()

View File

@ -24,6 +24,7 @@ import time
import netaddr import netaddr
from oslo.config import cfg from oslo.config import cfg
from oslo import messaging
from ryu.app.ofctl import api as ryu_api from ryu.app.ofctl import api as ryu_api
from ryu.base import app_manager from ryu.base import app_manager
from ryu.controller import handler from ryu.controller import handler
@ -38,7 +39,6 @@ from neutron.agent import rpc as agent_rpc
from neutron.agent import securitygroups_rpc as sg_rpc from neutron.agent import securitygroups_rpc as sg_rpc
from neutron.common import constants as n_const from neutron.common import constants as n_const
from neutron.common import log from neutron.common import log
from neutron.common import rpc as n_rpc
from neutron.common import topics from neutron.common import topics
from neutron.common import utils as n_utils from neutron.common import utils as n_utils
from neutron import context from neutron import context
@ -175,8 +175,7 @@ class OFANeutronAgentRyuApp(app_manager.RyuApp):
self.arplib.del_arp_table_entry(network, ip) self.arplib.del_arp_table_entry(network, ip)
class OFANeutronAgent(n_rpc.RpcCallback, class OFANeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
sg_rpc.SecurityGroupAgentRpcCallbackMixin,
l2population_rpc.L2populationRpcCallBackTunnelMixin): l2population_rpc.L2populationRpcCallBackTunnelMixin):
"""A agent for OpenFlow Agent ML2 mechanism driver. """A agent for OpenFlow Agent ML2 mechanism driver.
@ -191,7 +190,7 @@ class OFANeutronAgent(n_rpc.RpcCallback,
# history # history
# 1.0 Initial version # 1.0 Initial version
# 1.1 Support Security Group RPC # 1.1 Support Security Group RPC
RPC_API_VERSION = '1.1' target = messaging.Target(version='1.1')
def __init__(self, ryuapp, integ_br, local_ip, def __init__(self, ryuapp, integ_br, local_ip,
bridge_mappings, interface_mappings, root_helper, bridge_mappings, interface_mappings, root_helper,

View File

@ -37,9 +37,9 @@ from neutron.plugins.oneconvergence.lib import config
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class NVSDAgentRpcCallback(n_rpc.RpcCallback): class NVSDAgentRpcCallback(object):
RPC_API_VERSION = '1.0' target = messaging.Target(version='1.0')
def __init__(self, context, agent, sg_agent): def __init__(self, context, agent, sg_agent):
super(NVSDAgentRpcCallback, self).__init__() super(NVSDAgentRpcCallback, self).__init__()
@ -67,11 +67,9 @@ class SecurityGroupServerRpcApi(sg_rpc.SecurityGroupServerRpcApiMixin):
self.client = n_rpc.get_client(target) self.client = n_rpc.get_client(target)
class SecurityGroupAgentRpcCallback( class SecurityGroupAgentRpcCallback(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
n_rpc.RpcCallback,
sg_rpc.SecurityGroupAgentRpcCallbackMixin):
RPC_API_VERSION = sg_rpc.SG_RPC_VERSION target = messaging.Target(version=sg_rpc.SG_RPC_VERSION)
def __init__(self, context, sg_agent): def __init__(self, context, sg_agent):
super(SecurityGroupAgentRpcCallback, self).__init__() super(SecurityGroupAgentRpcCallback, self).__init__()
@ -89,11 +87,11 @@ class SecurityGroupAgentRpc(sg_rpc.SecurityGroupAgentRpcMixin):
self.init_firewall() self.init_firewall()
class NVSDNeutronAgent(n_rpc.RpcCallback): class NVSDNeutronAgent(object):
# history # history
# 1.0 Initial version # 1.0 Initial version
# 1.1 Support Security Group RPC # 1.1 Support Security Group RPC
RPC_API_VERSION = '1.1' target = messaging.Target(version='1.1')
def __init__(self, integ_br, root_helper, polling_interval): def __init__(self, integ_br, root_helper, polling_interval):
super(NVSDNeutronAgent, self).__init__() super(NVSDNeutronAgent, self).__init__()

View File

@ -25,6 +25,7 @@ eventlet.monkey_patch()
import netaddr import netaddr
from neutron.plugins.openvswitch.agent import ovs_dvr_neutron_agent from neutron.plugins.openvswitch.agent import ovs_dvr_neutron_agent
from oslo.config import cfg from oslo.config import cfg
from oslo import messaging
from six import moves from six import moves
from neutron.agent import l2population_rpc from neutron.agent import l2population_rpc
@ -38,7 +39,6 @@ from neutron.api.rpc.handlers import dvr_rpc
from neutron.common import config as common_config from neutron.common import config as common_config
from neutron.common import constants as q_const from neutron.common import constants as q_const
from neutron.common import exceptions from neutron.common import exceptions
from neutron.common import rpc as n_rpc
from neutron.common import topics from neutron.common import topics
from neutron.common import utils as q_utils from neutron.common import utils as q_utils
from neutron import context from neutron import context
@ -96,8 +96,7 @@ class OVSSecurityGroupAgent(sg_rpc.SecurityGroupAgentRpcMixin):
self.init_firewall(defer_refresh_firewall=True) self.init_firewall(defer_refresh_firewall=True)
class OVSNeutronAgent(n_rpc.RpcCallback, class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
sg_rpc.SecurityGroupAgentRpcCallbackMixin,
l2population_rpc.L2populationRpcCallBackTunnelMixin, l2population_rpc.L2populationRpcCallBackTunnelMixin,
dvr_rpc.DVRAgentRpcCallbackMixin): dvr_rpc.DVRAgentRpcCallbackMixin):
'''Implements OVS-based tunneling, VLANs and flat networks. '''Implements OVS-based tunneling, VLANs and flat networks.
@ -130,7 +129,7 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
# 1.0 Initial version # 1.0 Initial version
# 1.1 Support Security Group RPC # 1.1 Support Security Group RPC
# 1.2 Support DVR (Distributed Virtual Router) RPC # 1.2 Support DVR (Distributed Virtual Router) RPC
RPC_API_VERSION = '1.2' target = messaging.Target(version='1.2')
def __init__(self, integ_br, tun_br, local_ip, def __init__(self, integ_br, tun_br, local_ip,
bridge_mappings, root_helper, bridge_mappings, root_helper,

View File

@ -22,12 +22,12 @@ import eventlet
eventlet.monkey_patch() eventlet.monkey_patch()
from oslo.config import cfg from oslo.config import cfg
from oslo import messaging
from neutron.agent import rpc as agent_rpc from neutron.agent import rpc as agent_rpc
from neutron.agent import securitygroups_rpc as sg_rpc from neutron.agent import securitygroups_rpc as sg_rpc
from neutron.common import config as common_config from neutron.common import config as common_config
from neutron.common import constants as q_constants from neutron.common import constants as q_constants
from neutron.common import rpc as n_rpc
from neutron.common import topics from neutron.common import topics
from neutron.common import utils as q_utils from neutron.common import utils as q_utils
from neutron import context from neutron import context
@ -42,13 +42,12 @@ from neutron.plugins.sriovnicagent import eswitch_manager as esm
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class SriovNicSwitchRpcCallbacks(n_rpc.RpcCallback, class SriovNicSwitchRpcCallbacks(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
sg_rpc.SecurityGroupAgentRpcCallbackMixin):
# Set RPC API version to 1.0 by default. # Set RPC API version to 1.0 by default.
# history # history
# 1.1 Support Security Group RPC # 1.1 Support Security Group RPC
RPC_API_VERSION = '1.1' target = messaging.Target(version='1.1')
def __init__(self, context, agent): def __init__(self, context, agent):
super(SriovNicSwitchRpcCallbacks, self).__init__() super(SriovNicSwitchRpcCallbacks, self).__init__()

View File

@ -13,12 +13,12 @@
# under the License. # under the License.
from oslo.config import cfg from oslo.config import cfg
from oslo import messaging
from oslo.utils import importutils from oslo.utils import importutils
from neutron.agent import rpc as agent_rpc from neutron.agent import rpc as agent_rpc
from neutron.common import constants as n_const from neutron.common import constants as n_const
from neutron.common import exceptions as n_exc from neutron.common import exceptions as n_exc
from neutron.common import rpc as n_rpc
from neutron.common import topics from neutron.common import topics
from neutron import context from neutron import context
from neutron.i18n import _LE, _LI from neutron.i18n import _LE, _LI
@ -44,9 +44,8 @@ class DeviceNotFoundOnAgent(n_exc.NotFound):
msg = _('Unknown device with pool_id %(pool_id)s') msg = _('Unknown device with pool_id %(pool_id)s')
class LbaasAgentManager(n_rpc.RpcCallback, periodic_task.PeriodicTasks): class LbaasAgentManager(periodic_task.PeriodicTasks):
RPC_API_VERSION = '2.0'
# history # history
# 1.0 Initial version # 1.0 Initial version
# 1.1 Support agent_updated call # 1.1 Support agent_updated call
@ -54,6 +53,7 @@ class LbaasAgentManager(n_rpc.RpcCallback, periodic_task.PeriodicTasks):
# - modify/reload/destroy_pool methods were removed; # - modify/reload/destroy_pool methods were removed;
# - added methods to handle create/update/delete for every lbaas # - added methods to handle create/update/delete for every lbaas
# object individually; # object individually;
target = messaging.Target(version='2.0')
def __init__(self, conf): def __init__(self, conf):
super(LbaasAgentManager, self).__init__() super(LbaasAgentManager, self).__init__()

View File

@ -49,14 +49,14 @@ class DriverNotSpecified(n_exc.NeutronException):
"in plugin driver.") "in plugin driver.")
class LoadBalancerCallbacks(n_rpc.RpcCallback): class LoadBalancerCallbacks(object):
RPC_API_VERSION = '2.0'
# history # history
# 1.0 Initial version # 1.0 Initial version
# 2.0 Generic API for agent based drivers # 2.0 Generic API for agent based drivers
# - get_logical_device() handling changed; # - get_logical_device() handling changed;
# - pool_deployed() and update_status() methods added; # - pool_deployed() and update_status() methods added;
target = messaging.Target(version='2.0')
def __init__(self, plugin): def __init__(self, plugin):
super(LoadBalancerCallbacks, self).__init__() super(LoadBalancerCallbacks, self).__init__()

View File

@ -101,11 +101,7 @@ class CiscoCsrIPsecDriver(device_drivers.DeviceDriver):
# history # history
# 1.0 Initial version # 1.0 Initial version
RPC_API_VERSION = '1.0' target = messaging.Target(version='1.0')
# TODO(ihrachys): we can't use RpcCallback here due to inheritance
# issues
target = messaging.Target(version=RPC_API_VERSION)
def __init__(self, agent, host): def __init__(self, agent, host):
self.host = host self.host = host

View File

@ -480,12 +480,7 @@ class IPsecDriver(device_drivers.DeviceDriver):
# history # history
# 1.0 Initial version # 1.0 Initial version
target = messaging.Target(version='1.0')
RPC_API_VERSION = '1.0'
# TODO(ihrachys): we can't use RpcCallback here due to inheritance
# issues
target = messaging.Target(version=RPC_API_VERSION)
def __init__(self, agent, host): def __init__(self, agent, host):
self.agent = agent self.agent = agent

View File

@ -90,7 +90,7 @@ class BaseIPsecVpnAgentApi(object):
""" """
admin_context = context if context.is_admin else context.elevated() admin_context = context if context.is_admin else context.elevated()
if not version: if not version:
version = self.RPC_API_VERSION version = self.target.version
l3_agents = self.driver.l3_plugin.get_l3_agents_hosting_routers( l3_agents = self.driver.l3_plugin.get_l3_agents_hosting_routers(
admin_context, [router_id], admin_context, [router_id],
admin_state_up=True, admin_state_up=True,

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo import messaging
from neutron.common import rpc as n_rpc from neutron.common import rpc as n_rpc
from neutron.db.vpn import vpn_db from neutron.db.vpn import vpn_db
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
@ -33,14 +35,14 @@ MAX_CSR_MTU = 9192
VRF_SUFFIX_LEN = 6 VRF_SUFFIX_LEN = 6
class CiscoCsrIPsecVpnDriverCallBack(n_rpc.RpcCallback): class CiscoCsrIPsecVpnDriverCallBack(object):
"""Handler for agent to plugin RPC messaging.""" """Handler for agent to plugin RPC messaging."""
# history # history
# 1.0 Initial version # 1.0 Initial version
RPC_API_VERSION = BASE_IPSEC_VERSION target = messaging.Target(version=BASE_IPSEC_VERSION)
def __init__(self, driver): def __init__(self, driver):
super(CiscoCsrIPsecVpnDriverCallBack, self).__init__() super(CiscoCsrIPsecVpnDriverCallBack, self).__init__()
@ -77,12 +79,11 @@ class CiscoCsrIPsecVpnDriverCallBack(n_rpc.RpcCallback):
plugin.update_status_by_agent(context, status) plugin.update_status_by_agent(context, status)
class CiscoCsrIPsecVpnAgentApi(service_drivers.BaseIPsecVpnAgentApi, class CiscoCsrIPsecVpnAgentApi(service_drivers.BaseIPsecVpnAgentApi):
n_rpc.RpcCallback):
"""API and handler for Cisco IPSec plugin to agent RPC messaging.""" """API and handler for Cisco IPSec plugin to agent RPC messaging."""
RPC_API_VERSION = BASE_IPSEC_VERSION target = messaging.Target(version=BASE_IPSEC_VERSION)
def __init__(self, topic, default_version, driver): def __init__(self, topic, default_version, driver):
super(CiscoCsrIPsecVpnAgentApi, self).__init__( super(CiscoCsrIPsecVpnAgentApi, self).__init__(
@ -97,7 +98,7 @@ class CiscoCsrIPsecVpnAgentApi(service_drivers.BaseIPsecVpnAgentApi,
""" """
admin_context = context if context.is_admin else context.elevated() admin_context = context if context.is_admin else context.elevated()
if not version: if not version:
version = self.RPC_API_VERSION version = self.target.version
host = self.driver.l3_plugin.get_host_for_router(admin_context, host = self.driver.l3_plugin.get_host_for_router(admin_context,
router_id) router_id)
LOG.debug('Notify agent at %(topic)s.%(host)s the message ' LOG.debug('Notify agent at %(topic)s.%(host)s the message '

View File

@ -54,11 +54,10 @@ class IPsecVpnDriverCallBack(object):
plugin.update_status_by_agent(context, status) plugin.update_status_by_agent(context, status)
class IPsecVpnAgentApi(service_drivers.BaseIPsecVpnAgentApi, class IPsecVpnAgentApi(service_drivers.BaseIPsecVpnAgentApi):
n_rpc.RpcCallback):
"""Agent RPC API for IPsecVPNAgent.""" """Agent RPC API for IPsecVPNAgent."""
RPC_API_VERSION = BASE_IPSEC_VERSION target = messaging.Target(version=BASE_IPSEC_VERSION)
def __init__(self, topic, default_version, driver): def __init__(self, topic, default_version, driver):
super(IPsecVpnAgentApi, self).__init__( super(IPsecVpnAgentApi, self).__init__(