From 13b4fed39ce30e2e44e6684c25ffeae1fa2ae27c Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Fri, 30 May 2014 17:03:00 +0200 Subject: [PATCH] Introduce RpcCallback class This class will be used to create proper self.target with appropriate API version once we migrate to oslo.messaging. blueprint oslo-messaging Change-Id: I1fb5eb0aaac0d115fd84630e58b333e695ad4f5f --- neutron/common/rpc_compat.py | 9 +++++++++ neutron/db/agents_db.py | 4 +++- neutron/manager.py | 3 ++- neutron/plugins/bigswitch/agent/restproxy_agent.py | 4 +++- neutron/plugins/bigswitch/plugin.py | 3 ++- neutron/plugins/brocade/NeutronPlugin.py | 3 ++- neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py | 4 +++- neutron/plugins/hyperv/agent/hyperv_neutron_agent.py | 12 +++++++++--- neutron/plugins/hyperv/rpc_callbacks.py | 3 +++ neutron/plugins/ibm/agent/sdnve_neutron_agent.py | 4 +++- .../linuxbridge/agent/linuxbridge_neutron_agent.py | 4 +++- neutron/plugins/linuxbridge/lb_neutron_plugin.py | 3 ++- neutron/plugins/midonet/plugin.py | 4 +++- neutron/plugins/ml2/rpc.py | 2 ++ neutron/plugins/mlnx/agent/eswitch_neutron_agent.py | 4 +++- neutron/plugins/mlnx/rpc_callbacks.py | 7 +++---- neutron/plugins/nec/agent/nec_neutron_agent.py | 5 ++++- neutron/plugins/nec/nec_plugin.py | 9 ++++++--- neutron/plugins/ofagent/agent/ofa_neutron_agent.py | 5 ++++- .../oneconvergence/agent/nvsd_neutron_agent.py | 9 ++++++--- neutron/plugins/oneconvergence/plugin.py | 3 ++- .../plugins/openvswitch/agent/ovs_neutron_agent.py | 5 ++++- neutron/plugins/openvswitch/ovs_neutron_plugin.py | 4 +++- neutron/plugins/ryu/agent/ryu_neutron_agent.py | 4 +++- neutron/plugins/ryu/ryu_neutron_plugin.py | 4 +++- neutron/plugins/vmware/dhcp_meta/rpc.py | 4 +++- neutron/services/firewall/fwaas_plugin.py | 3 ++- neutron/services/l3_router/l3_router_plugin.py | 4 +++- neutron/services/loadbalancer/agent/agent_manager.py | 3 ++- .../loadbalancer/drivers/common/agent_driver_base.py | 3 ++- neutron/services/vpn/device_drivers/cisco_ipsec.py | 2 ++ neutron/services/vpn/device_drivers/ipsec.py | 2 ++ neutron/services/vpn/service_drivers/cisco_ipsec.py | 7 +++++-- neutron/services/vpn/service_drivers/ipsec.py | 7 +++++-- 34 files changed, 116 insertions(+), 40 deletions(-) diff --git a/neutron/common/rpc_compat.py b/neutron/common/rpc_compat.py index 6854f57284..2e95ee2bd5 100644 --- a/neutron/common/rpc_compat.py +++ b/neutron/common/rpc_compat.py @@ -26,6 +26,15 @@ class RpcProxy(proxy.RpcProxy): ''' +class RpcCallback(object): + ''' + This class is created to facilitate migration from oslo-incubator + RPC layer implementation to oslo.messaging and is intended to set + callback version using oslo.messaging API once the migration is + applied. + ''' + + # exceptions RPCException = rpc_common.RPCException RemoteError = rpc_common.RemoteError diff --git a/neutron/db/agents_db.py b/neutron/db/agents_db.py index 02abda02ab..57712066ad 100644 --- a/neutron/db/agents_db.py +++ b/neutron/db/agents_db.py @@ -19,6 +19,7 @@ from oslo.config import cfg import sqlalchemy as sa from sqlalchemy.orm import exc +from neutron.common import rpc_compat from neutron.db import model_base from neutron.db import models_v2 from neutron.extensions import agent as ext_agent @@ -195,13 +196,14 @@ class AgentDbMixin(ext_agent.AgentPluginBase): return self._create_or_update_agent(context, agent) -class AgentExtRpcCallback(object): +class AgentExtRpcCallback(rpc_compat.RpcCallback): """Processes the rpc report in plugin implementations.""" RPC_API_VERSION = '1.0' START_TIME = timeutils.utcnow() def __init__(self, plugin=None): + super(AgentExtRpcCallback, self).__init__() self.plugin = plugin def report_state(self, context, **kwargs): diff --git a/neutron/manager.py b/neutron/manager.py index 699af4e7a9..2c4e7f9945 100644 --- a/neutron/manager.py +++ b/neutron/manager.py @@ -17,6 +17,7 @@ import weakref from oslo.config import cfg +from neutron.common import rpc_compat from neutron.common import utils from neutron.openstack.common import importutils from neutron.openstack.common import log as logging @@ -29,7 +30,7 @@ from stevedore import driver LOG = logging.getLogger(__name__) -class Manager(periodic_task.PeriodicTasks): +class Manager(rpc_compat.RpcCallback, periodic_task.PeriodicTasks): # Set RPC API version to 1.0 by default. RPC_API_VERSION = '1.0' diff --git a/neutron/plugins/bigswitch/agent/restproxy_agent.py b/neutron/plugins/bigswitch/agent/restproxy_agent.py index 1d42c6df86..7b95f3554d 100644 --- a/neutron/plugins/bigswitch/agent/restproxy_agent.py +++ b/neutron/plugins/bigswitch/agent/restproxy_agent.py @@ -30,6 +30,7 @@ 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_compat from neutron.common import topics from neutron import context as q_context from neutron.extensions import securitygroup as ext_sg @@ -84,7 +85,8 @@ class SecurityGroupAgent(sg_rpc.SecurityGroupAgentRpcMixin): self.init_firewall() -class RestProxyAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin): +class RestProxyAgent(rpc_compat.RpcCallback, + sg_rpc.SecurityGroupAgentRpcCallbackMixin): RPC_API_VERSION = '1.1' diff --git a/neutron/plugins/bigswitch/plugin.py b/neutron/plugins/bigswitch/plugin.py index c0b6751dea..230098a2ca 100644 --- a/neutron/plugins/bigswitch/plugin.py +++ b/neutron/plugins/bigswitch/plugin.py @@ -115,7 +115,8 @@ class AgentNotifierApi(rpc_compat.RpcProxy, topic=self.topic_port_update) -class RestProxyCallbacks(sg_rpc_base.SecurityGroupServerRpcCallbackMixin, +class RestProxyCallbacks(rpc_compat.RpcCallback, + sg_rpc_base.SecurityGroupServerRpcCallbackMixin, dhcp_rpc_base.DhcpRpcCallbackMixin): RPC_API_VERSION = '1.1' diff --git a/neutron/plugins/brocade/NeutronPlugin.py b/neutron/plugins/brocade/NeutronPlugin.py index c62d8939e8..9eb4db2df5 100644 --- a/neutron/plugins/brocade/NeutronPlugin.py +++ b/neutron/plugins/brocade/NeutronPlugin.py @@ -81,7 +81,8 @@ cfg.CONF.register_opts(SWITCH_OPTS, "SWITCH") cfg.CONF.register_opts(PHYSICAL_INTERFACE_OPTS, "PHYSICAL_INTERFACE") -class BridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin, +class BridgeRpcCallbacks(rpc_compat.RpcCallback, + dhcp_rpc_base.DhcpRpcCallbackMixin, l3_rpc_base.L3RpcCallbackMixin, sg_db_rpc.SecurityGroupServerRpcCallbackMixin): """Agent callback.""" diff --git a/neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py b/neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py index 4e1f792fa5..2f60e17905 100644 --- a/neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py +++ b/neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py @@ -29,6 +29,7 @@ from neutron.api.v2 import attributes from neutron.common import constants from neutron.common import exceptions as n_exc from neutron.common import rpc as q_rpc +from neutron.common import rpc_compat from neutron.common import topics from neutron.common import utils from neutron.db import agents_db @@ -60,7 +61,8 @@ from neutron.plugins.common import constants as svc_constants LOG = logging.getLogger(__name__) -class N1kvRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin, +class N1kvRpcCallbacks(rpc_compat.RpcCallback, + dhcp_rpc_base.DhcpRpcCallbackMixin, l3_rpc_base.L3RpcCallbackMixin): """Class to handle agent RPC calls.""" diff --git a/neutron/plugins/hyperv/agent/hyperv_neutron_agent.py b/neutron/plugins/hyperv/agent/hyperv_neutron_agent.py index 032504d484..df9673cd77 100644 --- a/neutron/plugins/hyperv/agent/hyperv_neutron_agent.py +++ b/neutron/plugins/hyperv/agent/hyperv_neutron_agent.py @@ -32,6 +32,7 @@ from neutron.agent import rpc as agent_rpc from neutron.agent import securitygroups_rpc as sg_rpc from neutron.common import config as logging_config from neutron.common import constants as n_const +from neutron.common import rpc_compat from neutron.common import topics from neutron import context from neutron.openstack.common import log as logging @@ -80,11 +81,13 @@ CONF.register_opts(agent_opts, "AGENT") config.register_agent_state_opts_helper(cfg.CONF) -class HyperVSecurityAgent(sg_rpc.SecurityGroupAgentRpcMixin): +class HyperVSecurityAgent(rpc_compat.RpcCallback, + sg_rpc.SecurityGroupAgentRpcMixin): # Set RPC API version to 1.1 by default. RPC_API_VERSION = '1.1' def __init__(self, context, plugin_rpc): + super(HyperVSecurityAgent, self).__init__() self.context = context self.plugin_rpc = plugin_rpc @@ -106,11 +109,13 @@ class HyperVSecurityAgent(sg_rpc.SecurityGroupAgentRpcMixin): return dispatcher.RpcDispatcher([rpc_callback]) -class HyperVSecurityCallbackMixin(sg_rpc.SecurityGroupAgentRpcCallbackMixin): +class HyperVSecurityCallbackMixin(rpc_compat.RpcCallback, + sg_rpc.SecurityGroupAgentRpcCallbackMixin): # Set RPC API version to 1.1 by default. RPC_API_VERSION = '1.1' def __init__(self, sg_agent): + super(HyperVSecurityCallbackMixin, self).__init__() self.sg_agent = sg_agent @@ -119,11 +124,12 @@ class HyperVPluginApi(agent_rpc.PluginApi, pass -class HyperVNeutronAgent(object): +class HyperVNeutronAgent(rpc_compat.RpcCallback): # Set RPC API version to 1.0 by default. RPC_API_VERSION = '1.0' def __init__(self): + super(HyperVNeutronAgent, self).__init__() self._utils = utilsfactory.get_hypervutils() self._polling_interval = CONF.AGENT.polling_interval self._load_physical_network_mappings() diff --git a/neutron/plugins/hyperv/rpc_callbacks.py b/neutron/plugins/hyperv/rpc_callbacks.py index aa8b7c0b98..dafc160e75 100644 --- a/neutron/plugins/hyperv/rpc_callbacks.py +++ b/neutron/plugins/hyperv/rpc_callbacks.py @@ -18,6 +18,7 @@ from neutron.common import constants as q_const from neutron.common import rpc as q_rpc +from neutron.common import rpc_compat from neutron.db import agents_db from neutron.db import dhcp_rpc_base from neutron.db import l3_rpc_base @@ -29,6 +30,7 @@ LOG = logging.getLogger(__name__) class HyperVRpcCallbacks( + rpc_compat.RpcCallback, dhcp_rpc_base.DhcpRpcCallbackMixin, l3_rpc_base.L3RpcCallbackMixin): @@ -36,6 +38,7 @@ class HyperVRpcCallbacks( RPC_API_VERSION = '1.1' def __init__(self, notifier): + super(HyperVRpcCallbacks, self).__init__() self.notifier = notifier self._db = hyperv_db.HyperVPluginDB() diff --git a/neutron/plugins/ibm/agent/sdnve_neutron_agent.py b/neutron/plugins/ibm/agent/sdnve_neutron_agent.py index dea26bdbd5..e4f296fc4c 100644 --- a/neutron/plugins/ibm/agent/sdnve_neutron_agent.py +++ b/neutron/plugins/ibm/agent/sdnve_neutron_agent.py @@ -30,6 +30,7 @@ from neutron.agent.linux import ovs_lib from neutron.agent import rpc as agent_rpc from neutron.common import config as logging_config from neutron.common import constants as n_const +from neutron.common import rpc_compat from neutron.common import topics from neutron.common import utils as n_utils from neutron import context @@ -51,7 +52,7 @@ class SdnvePluginApi(agent_rpc.PluginApi): topic=self.topic) -class SdnveNeutronAgent(): +class SdnveNeutronAgent(rpc_compat.RpcCallback): RPC_API_VERSION = '1.1' @@ -70,6 +71,7 @@ class SdnveNeutronAgent(): :param controller_ip: Ip address of SDN-VE controller. ''' + super(SdnveNeutronAgent, self).__init__() self.root_helper = root_helper self.int_bridge_name = integ_br self.controller_ip = controller_ip diff --git a/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py b/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py index 5d215791a6..06357a493b 100755 --- a/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py +++ b/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py @@ -657,7 +657,8 @@ class LinuxBridgeManager: self.remove_fdb_bridge_entry(mac, agent_ip, interface) -class LinuxBridgeRpcCallbacks(sg_rpc.SecurityGroupAgentRpcCallbackMixin, +class LinuxBridgeRpcCallbacks(rpc_compat.RpcCallback, + sg_rpc.SecurityGroupAgentRpcCallbackMixin, l2pop_rpc.L2populationRpcCallBackMixin): # Set RPC API version to 1.0 by default. @@ -666,6 +667,7 @@ class LinuxBridgeRpcCallbacks(sg_rpc.SecurityGroupAgentRpcCallbackMixin, RPC_API_VERSION = '1.1' def __init__(self, context, agent): + super(LinuxBridgeRpcCallbacks, self).__init__() self.context = context self.agent = agent self.sg_agent = agent diff --git a/neutron/plugins/linuxbridge/lb_neutron_plugin.py b/neutron/plugins/linuxbridge/lb_neutron_plugin.py index ec05535524..fdf3f00bca 100644 --- a/neutron/plugins/linuxbridge/lb_neutron_plugin.py +++ b/neutron/plugins/linuxbridge/lb_neutron_plugin.py @@ -55,7 +55,8 @@ from neutron.plugins.linuxbridge.db import l2network_db_v2 as db LOG = logging.getLogger(__name__) -class LinuxBridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin, +class LinuxBridgeRpcCallbacks(rpc_compat.RpcCallback, + dhcp_rpc_base.DhcpRpcCallbackMixin, l3_rpc_base.L3RpcCallbackMixin, sg_db_rpc.SecurityGroupServerRpcCallbackMixin ): diff --git a/neutron/plugins/midonet/plugin.py b/neutron/plugins/midonet/plugin.py index cbf6ce4ede..10f5af3616 100644 --- a/neutron/plugins/midonet/plugin.py +++ b/neutron/plugins/midonet/plugin.py @@ -30,6 +30,7 @@ from neutron.api.v2 import attributes from neutron.common import constants from neutron.common import exceptions as n_exc from neutron.common import rpc as n_rpc +from neutron.common import rpc_compat from neutron.common import topics from neutron.db import agents_db from neutron.db import agentschedulers_db @@ -177,7 +178,8 @@ def _check_resource_exists(func, id, name, raise_exc=False): raise MidonetPluginException(msg=exc) -class MidoRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin): +class MidoRpcCallbacks(rpc_compat.RpcCallback, + dhcp_rpc_base.DhcpRpcCallbackMixin): RPC_API_VERSION = '1.1' def create_rpc_dispatcher(self): diff --git a/neutron/plugins/ml2/rpc.py b/neutron/plugins/ml2/rpc.py index c4b599668f..ff4e6e7bce 100644 --- a/neutron/plugins/ml2/rpc.py +++ b/neutron/plugins/ml2/rpc.py @@ -51,6 +51,8 @@ class RpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin, # not having their own __init__ functions. If an __init__() is added # to one, this could break. Fix this and add a unit test to cover this # test in H3. + # FIXME(ihrachys): we can't use rpc_compat.RpcCallback here due + # to inheritance problems super(RpcCallbacks, self).__init__(notifier, type_manager) def create_rpc_dispatcher(self): diff --git a/neutron/plugins/mlnx/agent/eswitch_neutron_agent.py b/neutron/plugins/mlnx/agent/eswitch_neutron_agent.py index 00ffdd6fdb..56366724d9 100644 --- a/neutron/plugins/mlnx/agent/eswitch_neutron_agent.py +++ b/neutron/plugins/mlnx/agent/eswitch_neutron_agent.py @@ -146,7 +146,8 @@ class EswitchManager(object): self.network_map[network_id] = data -class MlnxEswitchRpcCallbacks(sg_rpc.SecurityGroupAgentRpcCallbackMixin): +class MlnxEswitchRpcCallbacks(rpc_compat.RpcCallback, + sg_rpc.SecurityGroupAgentRpcCallbackMixin): # Set RPC API version to 1.0 by default. # history @@ -154,6 +155,7 @@ class MlnxEswitchRpcCallbacks(sg_rpc.SecurityGroupAgentRpcCallbackMixin): RPC_API_VERSION = '1.1' def __init__(self, context, agent): + super(MlnxEswitchRpcCallbacks, self).__init__() self.context = context self.agent = agent self.eswitch = agent.eswitch diff --git a/neutron/plugins/mlnx/rpc_callbacks.py b/neutron/plugins/mlnx/rpc_callbacks.py index 6b9633635b..fff970c43a 100644 --- a/neutron/plugins/mlnx/rpc_callbacks.py +++ b/neutron/plugins/mlnx/rpc_callbacks.py @@ -18,6 +18,7 @@ from oslo.config import cfg from neutron.common import constants as q_const from neutron.common import rpc as q_rpc +from neutron.common import rpc_compat from neutron.db import agents_db from neutron.db import api as db_api from neutron.db import dhcp_rpc_base @@ -29,7 +30,8 @@ from neutron.plugins.mlnx.db import mlnx_db_v2 as db LOG = logging.getLogger(__name__) -class MlnxRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin, +class MlnxRpcCallbacks(rpc_compat.RpcCallback, + dhcp_rpc_base.DhcpRpcCallbackMixin, l3_rpc_base.L3RpcCallbackMixin, sg_db_rpc.SecurityGroupServerRpcCallbackMixin): # History @@ -39,9 +41,6 @@ class MlnxRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin, #to be compatible with Linux Bridge Agent on Network Node TAP_PREFIX_LEN = 3 - def __init__(self): - pass - def create_rpc_dispatcher(self): """Get the rpc dispatcher for this manager. diff --git a/neutron/plugins/nec/agent/nec_neutron_agent.py b/neutron/plugins/nec/agent/nec_neutron_agent.py index c2d70fbfe0..5a5faff7f9 100755 --- a/neutron/plugins/nec/agent/nec_neutron_agent.py +++ b/neutron/plugins/nec/agent/nec_neutron_agent.py @@ -62,11 +62,12 @@ class NECPluginApi(agent_rpc.PluginApi): port_removed=port_removed)) -class NECAgentRpcCallback(object): +class NECAgentRpcCallback(rpc_compat.RpcCallback): RPC_API_VERSION = '1.0' def __init__(self, context, agent, sg_agent): + super(NECAgentRpcCallback, self).__init__() self.context = context self.agent = agent self.sg_agent = sg_agent @@ -92,11 +93,13 @@ class SecurityGroupServerRpcApi(rpc_compat.RpcProxy, class SecurityGroupAgentRpcCallback( + rpc_compat.RpcCallback, sg_rpc.SecurityGroupAgentRpcCallbackMixin): RPC_API_VERSION = sg_rpc.SG_RPC_VERSION def __init__(self, context, sg_agent): + super(SecurityGroupAgentRpcCallback, self).__init__() self.context = context self.sg_agent = sg_agent diff --git a/neutron/plugins/nec/nec_plugin.py b/neutron/plugins/nec/nec_plugin.py index 67c8ed94ee..7fd5d82145 100644 --- a/neutron/plugins/nec/nec_plugin.py +++ b/neutron/plugins/nec/nec_plugin.py @@ -680,18 +680,20 @@ class NECPluginV2AgentNotifierApi(rpc_compat.RpcProxy, topic=self.topic_port_update) -class DhcpRpcCallback(dhcp_rpc_base.DhcpRpcCallbackMixin): +class DhcpRpcCallback(rpc_compat.RpcCallback, + dhcp_rpc_base.DhcpRpcCallbackMixin): # DhcpPluginApi BASE_RPC_API_VERSION RPC_API_VERSION = '1.1' -class L3RpcCallback(l3_rpc_base.L3RpcCallbackMixin): +class L3RpcCallback(rpc_compat.RpcCallback, l3_rpc_base.L3RpcCallbackMixin): # 1.0 L3PluginApi BASE_RPC_API_VERSION # 1.1 Support update_floatingip_statuses RPC_API_VERSION = '1.1' class SecurityGroupServerRpcCallback( + rpc_compat.RpcCallback, sg_db_rpc.SecurityGroupServerRpcCallbackMixin): RPC_API_VERSION = sg_rpc.SG_RPC_VERSION @@ -707,11 +709,12 @@ class SecurityGroupServerRpcCallback( return port -class NECPluginV2RPCCallbacks(object): +class NECPluginV2RPCCallbacks(rpc_compat.RpcCallback): RPC_API_VERSION = '1.0' def __init__(self, plugin): + super(NECPluginV2RPCCallbacks, self).__init__() self.plugin = plugin def create_rpc_dispatcher(self): diff --git a/neutron/plugins/ofagent/agent/ofa_neutron_agent.py b/neutron/plugins/ofagent/agent/ofa_neutron_agent.py index 1ea58a9763..7ff3040b06 100644 --- a/neutron/plugins/ofagent/agent/ofa_neutron_agent.py +++ b/neutron/plugins/ofagent/agent/ofa_neutron_agent.py @@ -33,6 +33,7 @@ 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 constants as n_const +from neutron.common import rpc_compat from neutron.common import topics from neutron.common import utils as n_utils from neutron import context @@ -159,7 +160,8 @@ class OFANeutronAgentRyuApp(app_manager.RyuApp): agent.daemon_loop() -class OFANeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin): +class OFANeutronAgent(rpc_compat.RpcCallback, + sg_rpc.SecurityGroupAgentRpcCallbackMixin): """A agent for OpenFlow Agent ML2 mechanism driver. OFANeutronAgent is a OpenFlow Agent agent for a ML2 plugin. @@ -199,6 +201,7 @@ class OFANeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin): minimization, the number of seconds to wait before respawning the ovsdb monitor. """ + super(OFANeutronAgent, self).__init__() self.ryuapp = ryuapp self.veth_mtu = veth_mtu self.root_helper = root_helper diff --git a/neutron/plugins/oneconvergence/agent/nvsd_neutron_agent.py b/neutron/plugins/oneconvergence/agent/nvsd_neutron_agent.py index f023a57870..d291df508d 100644 --- a/neutron/plugins/oneconvergence/agent/nvsd_neutron_agent.py +++ b/neutron/plugins/oneconvergence/agent/nvsd_neutron_agent.py @@ -37,11 +37,12 @@ from neutron.plugins.oneconvergence.lib import config LOG = logging.getLogger(__name__) -class NVSDAgentRpcCallback(object): +class NVSDAgentRpcCallback(rpc_compat.RpcCallback): RPC_API_VERSION = '1.0' def __init__(self, context, agent, sg_agent): + super(NVSDAgentRpcCallback, self).__init__() self.context = context self.agent = agent self.sg_agent = sg_agent @@ -66,11 +67,13 @@ class SecurityGroupServerRpcApi(rpc_compat.RpcProxy, class SecurityGroupAgentRpcCallback( + rpc_compat.RpcCallback, sg_rpc.SecurityGroupAgentRpcCallbackMixin): RPC_API_VERSION = sg_rpc.SG_RPC_VERSION def __init__(self, context, sg_agent): + super(SecurityGroupAgentRpcCallback, self).__init__() self.context = context self.sg_agent = sg_agent @@ -85,14 +88,14 @@ class SecurityGroupAgentRpc(sg_rpc.SecurityGroupAgentRpcMixin): self.init_firewall() -class NVSDNeutronAgent(object): +class NVSDNeutronAgent(rpc_compat.RpcCallback): # history # 1.0 Initial version # 1.1 Support Security Group RPC RPC_API_VERSION = '1.1' def __init__(self, integ_br, root_helper, polling_interval): - + super(NVSDNeutronAgent, self).__init__() self.int_br = ovs_lib.OVSBridge(integ_br, root_helper) self.polling_interval = polling_interval self.root_helper = root_helper diff --git a/neutron/plugins/oneconvergence/plugin.py b/neutron/plugins/oneconvergence/plugin.py index 5a86ff4619..7f28ec5cea 100644 --- a/neutron/plugins/oneconvergence/plugin.py +++ b/neutron/plugins/oneconvergence/plugin.py @@ -53,7 +53,8 @@ LOG = logging.getLogger(__name__) IPv6 = 6 -class NVSDPluginRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin, +class NVSDPluginRpcCallbacks(rpc_compat.RpcCallback, + dhcp_rpc_base.DhcpRpcCallbackMixin, l3_rpc_base.L3RpcCallbackMixin, sg_db_rpc.SecurityGroupServerRpcCallbackMixin): diff --git a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py index 6c5fb56bbc..d7a0058bfc 100644 --- a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py @@ -35,6 +35,7 @@ from neutron.agent import rpc as agent_rpc from neutron.agent import securitygroups_rpc as sg_rpc from neutron.common import config as logging_config from neutron.common import constants as q_const +from neutron.common import rpc_compat from neutron.common import topics from neutron.common import utils as q_utils from neutron import context @@ -86,7 +87,8 @@ class OVSSecurityGroupAgent(sg_rpc.SecurityGroupAgentRpcMixin): self.init_firewall(defer_refresh_firewall=True) -class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, +class OVSNeutronAgent(rpc_compat.RpcCallback, + sg_rpc.SecurityGroupAgentRpcCallbackMixin, l2population_rpc.L2populationRpcCallBackMixin): '''Implements OVS-based tunneling, VLANs and flat networks. @@ -147,6 +149,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, :param arp_responder: Optional, enable local ARP responder if it is supported. ''' + super(OVSNeutronAgent, self).__init__() self.veth_mtu = veth_mtu self.root_helper = root_helper self.available_local_vlans = set(moves.xrange(q_const.MIN_VLAN_TAG, diff --git a/neutron/plugins/openvswitch/ovs_neutron_plugin.py b/neutron/plugins/openvswitch/ovs_neutron_plugin.py index ee1e9dbfe9..f5f199db89 100644 --- a/neutron/plugins/openvswitch/ovs_neutron_plugin.py +++ b/neutron/plugins/openvswitch/ovs_neutron_plugin.py @@ -59,7 +59,8 @@ from neutron.plugins.openvswitch import ovs_db_v2 LOG = logging.getLogger(__name__) -class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin, +class OVSRpcCallbacks(rpc_compat.RpcCallback, + dhcp_rpc_base.DhcpRpcCallbackMixin, l3_rpc_base.L3RpcCallbackMixin, sg_db_rpc.SecurityGroupServerRpcCallbackMixin): @@ -70,6 +71,7 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin, RPC_API_VERSION = '1.1' def __init__(self, notifier, tunnel_type): + super(OVSRpcCallbacks, self).__init__() self.notifier = notifier self.tunnel_type = tunnel_type diff --git a/neutron/plugins/ryu/agent/ryu_neutron_agent.py b/neutron/plugins/ryu/agent/ryu_neutron_agent.py index 01a4fba5ea..092dc8702e 100755 --- a/neutron/plugins/ryu/agent/ryu_neutron_agent.py +++ b/neutron/plugins/ryu/agent/ryu_neutron_agent.py @@ -37,6 +37,7 @@ from neutron.agent import rpc as agent_rpc from neutron.agent import securitygroups_rpc as sg_rpc from neutron.common import config as logging_config from neutron.common import exceptions as n_exc +from neutron.common import rpc_compat from neutron.common import topics from neutron import context as q_context from neutron.extensions import securitygroup as ext_sg @@ -180,7 +181,8 @@ class RyuSecurityGroupAgent(sg_rpc.SecurityGroupAgentRpcMixin): self.init_firewall() -class OVSNeutronOFPRyuAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin): +class OVSNeutronOFPRyuAgent(rpc_compat.RpcCallback, + sg_rpc.SecurityGroupAgentRpcCallbackMixin): RPC_API_VERSION = '1.1' diff --git a/neutron/plugins/ryu/ryu_neutron_plugin.py b/neutron/plugins/ryu/ryu_neutron_plugin.py index ef29fb7b4e..e0b6e3792c 100644 --- a/neutron/plugins/ryu/ryu_neutron_plugin.py +++ b/neutron/plugins/ryu/ryu_neutron_plugin.py @@ -48,13 +48,15 @@ from neutron.plugins.ryu.db import api_v2 as db_api_v2 LOG = logging.getLogger(__name__) -class RyuRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin, +class RyuRpcCallbacks(rpc_compat.RpcCallback, + dhcp_rpc_base.DhcpRpcCallbackMixin, l3_rpc_base.L3RpcCallbackMixin, sg_db_rpc.SecurityGroupServerRpcCallbackMixin): RPC_API_VERSION = '1.1' def __init__(self, ofp_rest_api_addr): + super(RyuRpcCallbacks, self).__init__() self.ofp_rest_api_addr = ofp_rest_api_addr def create_rpc_dispatcher(self): diff --git a/neutron/plugins/vmware/dhcp_meta/rpc.py b/neutron/plugins/vmware/dhcp_meta/rpc.py index b3b960c7de..057e94d970 100644 --- a/neutron/plugins/vmware/dhcp_meta/rpc.py +++ b/neutron/plugins/vmware/dhcp_meta/rpc.py @@ -25,6 +25,7 @@ from neutron.api.v2 import attributes from neutron.common import constants as const from neutron.common import exceptions as ntn_exc from neutron.common import rpc as n_rpc +from neutron.common import rpc_compat from neutron.db import agents_db from neutron.db import db_base_plugin_v2 from neutron.db import dhcp_rpc_base @@ -43,7 +44,8 @@ METADATA_GATEWAY_IP = '169.254.169.253' METADATA_DHCP_ROUTE = '169.254.169.254/32' -class NSXRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin): +class NSXRpcCallbacks(rpc_compat.RpcCallback, + dhcp_rpc_base.DhcpRpcCallbackMixin): RPC_API_VERSION = '1.1' diff --git a/neutron/services/firewall/fwaas_plugin.py b/neutron/services/firewall/fwaas_plugin.py index b3c7d67f70..5ba4b93992 100644 --- a/neutron/services/firewall/fwaas_plugin.py +++ b/neutron/services/firewall/fwaas_plugin.py @@ -35,10 +35,11 @@ from neutron.plugins.common import constants as const LOG = logging.getLogger(__name__) -class FirewallCallbacks(object): +class FirewallCallbacks(rpc_compat.RpcCallback): RPC_API_VERSION = '1.0' def __init__(self, plugin): + super(FirewallCallbacks, self).__init__() self.plugin = plugin def create_rpc_dispatcher(self): diff --git a/neutron/services/l3_router/l3_router_plugin.py b/neutron/services/l3_router/l3_router_plugin.py index 33e1c4b521..5f3cc2031e 100644 --- a/neutron/services/l3_router/l3_router_plugin.py +++ b/neutron/services/l3_router/l3_router_plugin.py @@ -22,6 +22,7 @@ from oslo.config import cfg from neutron.api.rpc.agentnotifiers import l3_rpc_agent_api from neutron.common import constants as q_const from neutron.common import rpc as q_rpc +from neutron.common import rpc_compat from neutron.common import topics from neutron.db import api as qdbapi from neutron.db import db_base_plugin_v2 @@ -35,7 +36,8 @@ from neutron.openstack.common import rpc from neutron.plugins.common import constants -class L3RouterPluginRpcCallbacks(l3_rpc_base.L3RpcCallbackMixin): +class L3RouterPluginRpcCallbacks(rpc_compat.RpcCallback, + l3_rpc_base.L3RpcCallbackMixin): RPC_API_VERSION = '1.1' diff --git a/neutron/services/loadbalancer/agent/agent_manager.py b/neutron/services/loadbalancer/agent/agent_manager.py index 0e315554a6..1bbb53cb00 100644 --- a/neutron/services/loadbalancer/agent/agent_manager.py +++ b/neutron/services/loadbalancer/agent/agent_manager.py @@ -21,6 +21,7 @@ from oslo.config import cfg 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_compat from neutron.common import topics from neutron import context from neutron.openstack.common import importutils @@ -46,7 +47,7 @@ class DeviceNotFoundOnAgent(n_exc.NotFound): msg = _('Unknown device with pool_id %(pool_id)s') -class LbaasAgentManager(periodic_task.PeriodicTasks): +class LbaasAgentManager(rpc_compat.RpcCallback, periodic_task.PeriodicTasks): RPC_API_VERSION = '2.0' # history diff --git a/neutron/services/loadbalancer/drivers/common/agent_driver_base.py b/neutron/services/loadbalancer/drivers/common/agent_driver_base.py index 908a29d2b9..916ce886a6 100644 --- a/neutron/services/loadbalancer/drivers/common/agent_driver_base.py +++ b/neutron/services/loadbalancer/drivers/common/agent_driver_base.py @@ -53,7 +53,7 @@ class DriverNotSpecified(n_exc.NeutronException): "in plugin driver.") -class LoadBalancerCallbacks(object): +class LoadBalancerCallbacks(rpc_compat.RpcCallback): RPC_API_VERSION = '2.0' # history @@ -63,6 +63,7 @@ class LoadBalancerCallbacks(object): # - pool_deployed() and update_status() methods added; def __init__(self, plugin): + super(LoadBalancerCallbacks, self).__init__() self.plugin = plugin def create_rpc_dispatcher(self): diff --git a/neutron/services/vpn/device_drivers/cisco_ipsec.py b/neutron/services/vpn/device_drivers/cisco_ipsec.py index 93479eeeec..9a6288072b 100644 --- a/neutron/services/vpn/device_drivers/cisco_ipsec.py +++ b/neutron/services/vpn/device_drivers/cisco_ipsec.py @@ -189,6 +189,8 @@ class CiscoCsrIPsecDriver(device_drivers.DeviceDriver): RPC_API_VERSION = '1.0' def __init__(self, agent, host): + # TODO(ihrachys): we can't use RpcCallback here due to + # inheritance issues self.host = host self.conn = rpc.create_connection(new=True) context = ctx.get_admin_context_without_session() diff --git a/neutron/services/vpn/device_drivers/ipsec.py b/neutron/services/vpn/device_drivers/ipsec.py index 83ad5bf539..893ddc88fe 100644 --- a/neutron/services/vpn/device_drivers/ipsec.py +++ b/neutron/services/vpn/device_drivers/ipsec.py @@ -489,6 +489,8 @@ class IPsecDriver(device_drivers.DeviceDriver): RPC_API_VERSION = '1.0' def __init__(self, agent, host): + # TODO(ihrachys): we can't use RpcCallback here due to + # inheritance issues self.agent = agent self.conf = self.agent.conf self.root_helper = self.agent.root_helper diff --git a/neutron/services/vpn/service_drivers/cisco_ipsec.py b/neutron/services/vpn/service_drivers/cisco_ipsec.py index 76ca9a9685..1d33da50e9 100644 --- a/neutron/services/vpn/service_drivers/cisco_ipsec.py +++ b/neutron/services/vpn/service_drivers/cisco_ipsec.py @@ -17,6 +17,7 @@ from netaddr import core as net_exc from neutron.common import exceptions from neutron.common import rpc as n_rpc +from neutron.common import rpc_compat from neutron.openstack.common import excutils from neutron.openstack.common import log as logging from neutron.openstack.common import rpc @@ -41,7 +42,7 @@ class CsrValidationFailure(exceptions.BadRequest): "with value '%(value)s'") -class CiscoCsrIPsecVpnDriverCallBack(object): +class CiscoCsrIPsecVpnDriverCallBack(rpc_compat.RpcCallback): """Handler for agent to plugin RPC messaging.""" @@ -51,6 +52,7 @@ class CiscoCsrIPsecVpnDriverCallBack(object): RPC_API_VERSION = BASE_IPSEC_VERSION def __init__(self, driver): + super(CiscoCsrIPsecVpnDriverCallBack, self).__init__() self.driver = driver def create_rpc_dispatcher(self): @@ -70,7 +72,8 @@ class CiscoCsrIPsecVpnDriverCallBack(object): plugin.update_status_by_agent(context, status) -class CiscoCsrIPsecVpnAgentApi(service_drivers.BaseIPsecVpnAgentApi): +class CiscoCsrIPsecVpnAgentApi(service_drivers.BaseIPsecVpnAgentApi, + rpc_compat.RpcCallback): """API and handler for Cisco IPSec plugin to agent RPC messaging.""" diff --git a/neutron/services/vpn/service_drivers/ipsec.py b/neutron/services/vpn/service_drivers/ipsec.py index 552bda46f3..9e529fd097 100644 --- a/neutron/services/vpn/service_drivers/ipsec.py +++ b/neutron/services/vpn/service_drivers/ipsec.py @@ -17,6 +17,7 @@ import netaddr from neutron.common import rpc as n_rpc +from neutron.common import rpc_compat from neutron.openstack.common import log as logging from neutron.openstack.common import rpc from neutron.services.vpn.common import topics @@ -29,7 +30,7 @@ IPSEC = 'ipsec' BASE_IPSEC_VERSION = '1.0' -class IPsecVpnDriverCallBack(object): +class IPsecVpnDriverCallBack(rpc_compat.RpcCallback): """Callback for IPSecVpnDriver rpc.""" # history @@ -38,6 +39,7 @@ class IPsecVpnDriverCallBack(object): RPC_API_VERSION = BASE_IPSEC_VERSION def __init__(self, driver): + super(IPsecVpnDriverCallBack, self).__init__() self.driver = driver def create_rpc_dispatcher(self): @@ -57,7 +59,8 @@ class IPsecVpnDriverCallBack(object): plugin.update_status_by_agent(context, status) -class IPsecVpnAgentApi(service_drivers.BaseIPsecVpnAgentApi): +class IPsecVpnAgentApi(service_drivers.BaseIPsecVpnAgentApi, + rpc_compat.RpcCallback): """Agent RPC API for IPsecVPNAgent.""" RPC_API_VERSION = BASE_IPSEC_VERSION