From c14cf3266f1b6fdbffb53d8534da322e1df62867 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Mon, 9 Jun 2014 16:09:26 +0200 Subject: [PATCH] Moved rpc_compat.py code back into rpc.py Most of this code will probably stay with us for quite some time, so let's make things easier and consider them as our way of doing RPC. blueprint oslo-messaging Change-Id: Iaf353b23f9c54b82d1e02a6bd5a5960cec827c88 --- neutron/services/vpn/device_drivers/cisco_ipsec.py | 6 +++--- neutron/services/vpn/device_drivers/ipsec.py | 6 +++--- neutron/services/vpn/service_drivers/__init__.py | 4 ++-- neutron/services/vpn/service_drivers/cisco_ipsec.py | 8 ++++---- neutron/services/vpn/service_drivers/ipsec.py | 8 ++++---- .../unit/services/vpn/device_drivers/test_cisco_ipsec.py | 2 +- .../tests/unit/services/vpn/device_drivers/test_ipsec.py | 2 +- .../unit/services/vpn/service_drivers/test_cisco_ipsec.py | 4 ++-- .../tests/unit/services/vpn/service_drivers/test_ipsec.py | 2 +- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/neutron/services/vpn/device_drivers/cisco_ipsec.py b/neutron/services/vpn/device_drivers/cisco_ipsec.py index 7d73735c1..33a806d4b 100644 --- a/neutron/services/vpn/device_drivers/cisco_ipsec.py +++ b/neutron/services/vpn/device_drivers/cisco_ipsec.py @@ -24,7 +24,7 @@ from oslo import messaging import six from neutron.common import exceptions -from neutron.common import rpc_compat +from neutron.common import rpc as n_rpc from neutron import context as ctx from neutron.openstack.common import lockutils from neutron.openstack.common import log as logging @@ -150,7 +150,7 @@ def find_available_csrs_from_config(config_files): return csrs_found -class CiscoCsrIPsecVpnDriverApi(rpc_compat.RpcProxy): +class CiscoCsrIPsecVpnDriverApi(n_rpc.RpcProxy): """RPC API for agent to plugin messaging.""" def get_vpn_services_on_host(self, context, host): @@ -192,7 +192,7 @@ class CiscoCsrIPsecDriver(device_drivers.DeviceDriver): def __init__(self, agent, host): self.host = host - self.conn = rpc_compat.create_connection(new=True) + self.conn = n_rpc.create_connection(new=True) context = ctx.get_admin_context_without_session() node_topic = '%s.%s' % (topics.CISCO_IPSEC_AGENT_TOPIC, self.host) diff --git a/neutron/services/vpn/device_drivers/ipsec.py b/neutron/services/vpn/device_drivers/ipsec.py index 1c9bad879..6d2188fde 100644 --- a/neutron/services/vpn/device_drivers/ipsec.py +++ b/neutron/services/vpn/device_drivers/ipsec.py @@ -26,7 +26,7 @@ import six from neutron.agent.linux import ip_lib from neutron.agent.linux import utils -from neutron.common import rpc_compat +from neutron.common import rpc as n_rpc from neutron import context from neutron.openstack.common import lockutils from neutron.openstack.common import log as logging @@ -441,7 +441,7 @@ class OpenSwanProcess(BaseSwanProcess): self.connection_status = {} -class IPsecVpnDriverApi(rpc_compat.RpcProxy): +class IPsecVpnDriverApi(n_rpc.RpcProxy): """IPSecVpnDriver RPC api.""" IPSEC_PLUGIN_VERSION = '1.0' @@ -494,7 +494,7 @@ class IPsecDriver(device_drivers.DeviceDriver): self.conf = self.agent.conf self.root_helper = self.agent.root_helper self.host = host - self.conn = rpc_compat.create_connection(new=True) + self.conn = n_rpc.create_connection(new=True) self.context = context.get_admin_context_without_session() self.topic = topics.IPSEC_AGENT_TOPIC node_topic = '%s.%s' % (self.topic, self.host) diff --git a/neutron/services/vpn/service_drivers/__init__.py b/neutron/services/vpn/service_drivers/__init__.py index 3bd45670f..17db33384 100644 --- a/neutron/services/vpn/service_drivers/__init__.py +++ b/neutron/services/vpn/service_drivers/__init__.py @@ -17,7 +17,7 @@ import abc import six -from neutron.common import rpc_compat +from neutron.common import rpc as n_rpc from neutron import manager from neutron.openstack.common import log as logging from neutron.plugins.common import constants @@ -49,7 +49,7 @@ class VpnDriver(object): pass -class BaseIPsecVpnAgentApi(rpc_compat.RpcProxy): +class BaseIPsecVpnAgentApi(n_rpc.RpcProxy): """Base class for IPSec API to agent.""" def __init__(self, to_agent_topic, topic, default_version): diff --git a/neutron/services/vpn/service_drivers/cisco_ipsec.py b/neutron/services/vpn/service_drivers/cisco_ipsec.py index ed34f41ff..93ce79232 100644 --- a/neutron/services/vpn/service_drivers/cisco_ipsec.py +++ b/neutron/services/vpn/service_drivers/cisco_ipsec.py @@ -16,7 +16,7 @@ import netaddr from netaddr import core as net_exc from neutron.common import exceptions -from neutron.common import rpc_compat +from neutron.common import rpc as n_rpc from neutron.openstack.common import excutils from neutron.openstack.common import log as logging from neutron.plugins.common import constants @@ -40,7 +40,7 @@ class CsrValidationFailure(exceptions.BadRequest): "with value '%(value)s'") -class CiscoCsrIPsecVpnDriverCallBack(rpc_compat.RpcCallback): +class CiscoCsrIPsecVpnDriverCallBack(n_rpc.RpcCallback): """Handler for agent to plugin RPC messaging.""" @@ -68,7 +68,7 @@ class CiscoCsrIPsecVpnDriverCallBack(rpc_compat.RpcCallback): class CiscoCsrIPsecVpnAgentApi(service_drivers.BaseIPsecVpnAgentApi, - rpc_compat.RpcCallback): + n_rpc.RpcCallback): """API and handler for Cisco IPSec plugin to agent RPC messaging.""" @@ -86,7 +86,7 @@ class CiscoCsrIPsecVPNDriver(service_drivers.VpnDriver): def __init__(self, service_plugin): super(CiscoCsrIPsecVPNDriver, self).__init__(service_plugin) self.endpoints = [CiscoCsrIPsecVpnDriverCallBack(self)] - self.conn = rpc_compat.create_connection(new=True) + self.conn = n_rpc.create_connection(new=True) self.conn.create_consumer( topics.CISCO_IPSEC_DRIVER_TOPIC, self.endpoints, fanout=False) self.conn.consume_in_threads() diff --git a/neutron/services/vpn/service_drivers/ipsec.py b/neutron/services/vpn/service_drivers/ipsec.py index 7a7886df7..e3c2ee231 100644 --- a/neutron/services/vpn/service_drivers/ipsec.py +++ b/neutron/services/vpn/service_drivers/ipsec.py @@ -14,7 +14,7 @@ # under the License. import netaddr -from neutron.common import rpc_compat +from neutron.common import rpc as n_rpc from neutron.openstack.common import log as logging from neutron.services.vpn.common import topics from neutron.services.vpn import service_drivers @@ -26,7 +26,7 @@ IPSEC = 'ipsec' BASE_IPSEC_VERSION = '1.0' -class IPsecVpnDriverCallBack(rpc_compat.RpcCallback): +class IPsecVpnDriverCallBack(n_rpc.RpcCallback): """Callback for IPSecVpnDriver rpc.""" # history @@ -53,7 +53,7 @@ class IPsecVpnDriverCallBack(rpc_compat.RpcCallback): class IPsecVpnAgentApi(service_drivers.BaseIPsecVpnAgentApi, - rpc_compat.RpcCallback): + n_rpc.RpcCallback): """Agent RPC API for IPsecVPNAgent.""" RPC_API_VERSION = BASE_IPSEC_VERSION @@ -69,7 +69,7 @@ class IPsecVPNDriver(service_drivers.VpnDriver): def __init__(self, service_plugin): super(IPsecVPNDriver, self).__init__(service_plugin) self.endpoints = [IPsecVpnDriverCallBack(self)] - self.conn = rpc_compat.create_connection(new=True) + self.conn = n_rpc.create_connection(new=True) self.conn.create_consumer( topics.IPSEC_DRIVER_TOPIC, self.endpoints, fanout=False) self.conn.consume_in_threads() diff --git a/neutron/tests/unit/services/vpn/device_drivers/test_cisco_ipsec.py b/neutron/tests/unit/services/vpn/device_drivers/test_cisco_ipsec.py index 3c29e7551..b92b77cff 100644 --- a/neutron/tests/unit/services/vpn/device_drivers/test_cisco_ipsec.py +++ b/neutron/tests/unit/services/vpn/device_drivers/test_cisco_ipsec.py @@ -399,7 +399,7 @@ class TestCiscoCsrIPsecDeviceDriverSyncStatuses(base.BaseTestCase): def setUp(self): super(TestCiscoCsrIPsecDeviceDriverSyncStatuses, self).setUp() - for klass in ['neutron.common.rpc_compat.create_connection', + for klass in ['neutron.common.rpc.create_connection', 'neutron.context.get_admin_context_without_session', 'neutron.openstack.common.' 'loopingcall.FixedIntervalLoopingCall']: diff --git a/neutron/tests/unit/services/vpn/device_drivers/test_ipsec.py b/neutron/tests/unit/services/vpn/device_drivers/test_ipsec.py index d10ae3d5b..bec8b78ce 100644 --- a/neutron/tests/unit/services/vpn/device_drivers/test_ipsec.py +++ b/neutron/tests/unit/services/vpn/device_drivers/test_ipsec.py @@ -45,7 +45,7 @@ class TestIPsecDeviceDriver(base.BaseTestCase): 'os.makedirs', 'os.path.isdir', 'neutron.agent.linux.utils.replace_file', - 'neutron.common.rpc_compat.create_connection', + 'neutron.common.rpc.create_connection', 'neutron.services.vpn.device_drivers.ipsec.' 'OpenSwanProcess._gen_config_content', 'shutil.rmtree', diff --git a/neutron/tests/unit/services/vpn/service_drivers/test_cisco_ipsec.py b/neutron/tests/unit/services/vpn/service_drivers/test_cisco_ipsec.py index f78d8b16c..7a59acedc 100644 --- a/neutron/tests/unit/services/vpn/service_drivers/test_cisco_ipsec.py +++ b/neutron/tests/unit/services/vpn/service_drivers/test_cisco_ipsec.py @@ -44,7 +44,7 @@ class TestCiscoIPsecDriverValidation(base.BaseTestCase): def setUp(self): super(TestCiscoIPsecDriverValidation, self).setUp() - mock.patch('neutron.common.rpc_compat.create_connection').start() + mock.patch('neutron.common.rpc.create_connection').start() self.service_plugin = mock.Mock() self.driver = ipsec_driver.CiscoCsrIPsecVPNDriver(self.service_plugin) self.context = n_ctx.Context('some_user', 'some_tenant') @@ -284,7 +284,7 @@ class TestCiscoIPsecDriver(base.BaseTestCase): super(TestCiscoIPsecDriver, self).setUp() dbapi.configure_db() self.addCleanup(dbapi.clear_db) - mock.patch('neutron.common.rpc_compat.create_connection').start() + mock.patch('neutron.common.rpc.create_connection').start() l3_agent = mock.Mock() l3_agent.host = FAKE_HOST diff --git a/neutron/tests/unit/services/vpn/service_drivers/test_ipsec.py b/neutron/tests/unit/services/vpn/service_drivers/test_ipsec.py index 713f8d846..646827e0e 100644 --- a/neutron/tests/unit/services/vpn/service_drivers/test_ipsec.py +++ b/neutron/tests/unit/services/vpn/service_drivers/test_ipsec.py @@ -35,7 +35,7 @@ FAKE_HOST = 'fake_host' class TestIPsecDriver(base.BaseTestCase): def setUp(self): super(TestIPsecDriver, self).setUp() - mock.patch('neutron.common.rpc_compat.create_connection').start() + mock.patch('neutron.common.rpc.create_connection').start() l3_agent = mock.Mock() l3_agent.host = FAKE_HOST