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
Needed by the L3 service when dealing with DVR
"""
RPC_API_VERSION = '1.2'
target = messaging.Target(version='1.2')
OPTS = [
cfg.StrOpt('agent_mode', default='legacy',

View File

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

View File

@ -16,9 +16,9 @@
import weakref
from oslo.config import cfg
from oslo import messaging
from oslo.utils import importutils
from neutron.common import rpc as n_rpc
from neutron.common import utils
from neutron.openstack.common import log as logging
from neutron.openstack.common import periodic_task
@ -30,10 +30,10 @@ from stevedore import driver
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.
RPC_API_VERSION = '1.0'
target = messaging.Target(version='1.0')
def __init__(self, host=None):
if not host:

View File

@ -23,6 +23,7 @@ import eventlet
eventlet.monkey_patch()
from oslo.config import cfg
from oslo import messaging
from oslo.utils import excutils
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 securitygroups_rpc as sg_rpc
from neutron.common import config
from neutron.common import rpc as n_rpc
from neutron.common import topics
from neutron import context as q_context
from neutron.extensions import securitygroup as ext_sg
@ -84,10 +84,9 @@ class SecurityGroupAgent(sg_rpc.SecurityGroupAgentRpcMixin):
self.init_firewall()
class RestProxyAgent(n_rpc.RpcCallback,
sg_rpc.SecurityGroupAgentRpcCallbackMixin):
class RestProxyAgent(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'):
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
`_backlog_task()` .
"""
RPC_API_VERSION = '1.1'
target = messaging.Target(version='1.1')
OPTS = [
cfg.IntOpt('rpc_loop_interval', default=10,

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo import messaging
from neutron.common import rpc as n_rpc
from neutron.common import topics
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
class CiscoRouterPluginRpcCallbacks(n_rpc.RpcCallback,
l3_router_rpc.L3RouterCfgRpcCallbackMixin,
class CiscoRouterPluginRpcCallbacks(l3_router_rpc.L3RouterCfgRpcCallbackMixin,
devices_rpc.DeviceCfgRpcCallbackMixin):
RPC_API_VERSION = '1.1'
target = messaging.Target(version='1.1')
def __init__(self, l3plugin):
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.common import config as common_config
from neutron.common import constants as n_const
from neutron.common import rpc as n_rpc
from neutron.common import topics
from neutron import context
from neutron.i18n import _LE, _LI
@ -79,10 +78,9 @@ CONF.register_opts(agent_opts, "AGENT")
config.register_agent_state_opts_helper(cfg.CONF)
class HyperVSecurityAgent(n_rpc.RpcCallback,
sg_rpc.SecurityGroupAgentRpcMixin):
# Set RPC API version to 1.1 by default.
RPC_API_VERSION = '1.1'
class HyperVSecurityAgent(sg_rpc.SecurityGroupAgentRpcMixin):
target = messaging.Target(version='1.1')
def __init__(self, context, plugin_rpc):
super(HyperVSecurityAgent, self).__init__()
@ -103,10 +101,9 @@ class HyperVSecurityAgent(n_rpc.RpcCallback,
consumers)
class HyperVSecurityCallbackMixin(n_rpc.RpcCallback,
sg_rpc.SecurityGroupAgentRpcCallbackMixin):
# Set RPC API version to 1.1 by default.
RPC_API_VERSION = '1.1'
class HyperVSecurityCallbackMixin(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
target = messaging.Target(version='1.1')
def __init__(self, sg_agent):
super(HyperVSecurityCallbackMixin, self).__init__()

View File

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

View File

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

View File

@ -35,10 +35,8 @@ from neutron.plugins.ml2.drivers import type_tunnel
LOG = log.getLogger(__name__)
class RpcCallbacks(n_rpc.RpcCallback,
type_tunnel.TunnelRpcCallbackMixin):
class RpcCallbacks(type_tunnel.TunnelRpcCallbackMixin):
RPC_API_VERSION = '1.3'
# history
# 1.0 Initial version (from openvswitch/linuxbridge)
# 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
# return value to include fixed_ips and device_owner for
# the device port
target = messaging.Target(version='1.3')
def __init__(self, notifier, type_manager):
self.setup_tunnel_callback_mixin(notifier, type_manager)

View File

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

View File

@ -12,10 +12,11 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo.config import cfg
from oslo import messaging
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 import manager
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__)
class MlnxRpcCallbacks(n_rpc.RpcCallback):
class MlnxRpcCallbacks(object):
# History
# 1.1 Support Security Group RPC
# 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):
"""Agent requests device details."""

View File

@ -60,9 +60,9 @@ class NECPluginApi(agent_rpc.PluginApi):
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):
super(NECAgentRpcCallback, self).__init__()
@ -90,11 +90,9 @@ class SecurityGroupServerRpcApi(sg_rpc.SecurityGroupServerRpcApiMixin):
self.client = n_rpc.get_client(target)
class SecurityGroupAgentRpcCallback(
n_rpc.RpcCallback,
sg_rpc.SecurityGroupAgentRpcCallbackMixin):
class SecurityGroupAgentRpcCallback(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):
super(SecurityGroupAgentRpcCallback, self).__init__()

View File

@ -688,9 +688,9 @@ class NECPluginV2AgentNotifierApi(sg_rpc.SecurityGroupAgentRpcApiMixin):
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):
super(NECPluginV2RPCCallbacks, self).__init__()

View File

@ -24,6 +24,7 @@ import time
import netaddr
from oslo.config import cfg
from oslo import messaging
from ryu.app.ofctl import api as ryu_api
from ryu.base import app_manager
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.common import constants as n_const
from neutron.common import log
from neutron.common import rpc as n_rpc
from neutron.common import topics
from neutron.common import utils as n_utils
from neutron import context
@ -175,8 +175,7 @@ class OFANeutronAgentRyuApp(app_manager.RyuApp):
self.arplib.del_arp_table_entry(network, ip)
class OFANeutronAgent(n_rpc.RpcCallback,
sg_rpc.SecurityGroupAgentRpcCallbackMixin,
class OFANeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
l2population_rpc.L2populationRpcCallBackTunnelMixin):
"""A agent for OpenFlow Agent ML2 mechanism driver.
@ -191,7 +190,7 @@ class OFANeutronAgent(n_rpc.RpcCallback,
# history
# 1.0 Initial version
# 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,
bridge_mappings, interface_mappings, root_helper,

View File

@ -37,9 +37,9 @@ from neutron.plugins.oneconvergence.lib import config
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):
super(NVSDAgentRpcCallback, self).__init__()
@ -67,11 +67,9 @@ class SecurityGroupServerRpcApi(sg_rpc.SecurityGroupServerRpcApiMixin):
self.client = n_rpc.get_client(target)
class SecurityGroupAgentRpcCallback(
n_rpc.RpcCallback,
sg_rpc.SecurityGroupAgentRpcCallbackMixin):
class SecurityGroupAgentRpcCallback(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):
super(SecurityGroupAgentRpcCallback, self).__init__()
@ -89,11 +87,11 @@ class SecurityGroupAgentRpc(sg_rpc.SecurityGroupAgentRpcMixin):
self.init_firewall()
class NVSDNeutronAgent(n_rpc.RpcCallback):
class NVSDNeutronAgent(object):
# history
# 1.0 Initial version
# 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):
super(NVSDNeutronAgent, self).__init__()

View File

@ -25,6 +25,7 @@ eventlet.monkey_patch()
import netaddr
from neutron.plugins.openvswitch.agent import ovs_dvr_neutron_agent
from oslo.config import cfg
from oslo import messaging
from six import moves
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 constants as q_const
from neutron.common import exceptions
from neutron.common import rpc as n_rpc
from neutron.common import topics
from neutron.common import utils as q_utils
from neutron import context
@ -96,8 +96,7 @@ class OVSSecurityGroupAgent(sg_rpc.SecurityGroupAgentRpcMixin):
self.init_firewall(defer_refresh_firewall=True)
class OVSNeutronAgent(n_rpc.RpcCallback,
sg_rpc.SecurityGroupAgentRpcCallbackMixin,
class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
l2population_rpc.L2populationRpcCallBackTunnelMixin,
dvr_rpc.DVRAgentRpcCallbackMixin):
'''Implements OVS-based tunneling, VLANs and flat networks.
@ -130,7 +129,7 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
# 1.0 Initial version
# 1.1 Support Security Group 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,
bridge_mappings, root_helper,

View File

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

View File

@ -13,12 +13,12 @@
# under the License.
from oslo.config import cfg
from oslo import messaging
from oslo.utils import importutils
from neutron.agent import rpc as agent_rpc
from neutron.common import constants as n_const
from neutron.common import exceptions as n_exc
from neutron.common import rpc as n_rpc
from neutron.common import topics
from neutron import context
from neutron.i18n import _LE, _LI
@ -44,9 +44,8 @@ class DeviceNotFoundOnAgent(n_exc.NotFound):
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
# 1.0 Initial version
# 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;
# - added methods to handle create/update/delete for every lbaas
# object individually;
target = messaging.Target(version='2.0')
def __init__(self, conf):
super(LbaasAgentManager, self).__init__()

View File

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

View File

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

View File

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

View File

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

View File

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