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
This commit is contained in:
Ihar Hrachyshka 2014-06-09 16:09:26 +02:00
parent 46ec452dfe
commit c14cf3266f
9 changed files with 21 additions and 21 deletions

View File

@ -24,7 +24,7 @@ from oslo import messaging
import six import six
from neutron.common import exceptions 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 import context as ctx
from neutron.openstack.common import lockutils from neutron.openstack.common import lockutils
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
@ -150,7 +150,7 @@ def find_available_csrs_from_config(config_files):
return csrs_found return csrs_found
class CiscoCsrIPsecVpnDriverApi(rpc_compat.RpcProxy): class CiscoCsrIPsecVpnDriverApi(n_rpc.RpcProxy):
"""RPC API for agent to plugin messaging.""" """RPC API for agent to plugin messaging."""
def get_vpn_services_on_host(self, context, host): def get_vpn_services_on_host(self, context, host):
@ -192,7 +192,7 @@ class CiscoCsrIPsecDriver(device_drivers.DeviceDriver):
def __init__(self, agent, host): def __init__(self, agent, host):
self.host = 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() context = ctx.get_admin_context_without_session()
node_topic = '%s.%s' % (topics.CISCO_IPSEC_AGENT_TOPIC, self.host) node_topic = '%s.%s' % (topics.CISCO_IPSEC_AGENT_TOPIC, self.host)

View File

@ -26,7 +26,7 @@ import six
from neutron.agent.linux import ip_lib from neutron.agent.linux import ip_lib
from neutron.agent.linux import utils 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 import context
from neutron.openstack.common import lockutils from neutron.openstack.common import lockutils
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
@ -441,7 +441,7 @@ class OpenSwanProcess(BaseSwanProcess):
self.connection_status = {} self.connection_status = {}
class IPsecVpnDriverApi(rpc_compat.RpcProxy): class IPsecVpnDriverApi(n_rpc.RpcProxy):
"""IPSecVpnDriver RPC api.""" """IPSecVpnDriver RPC api."""
IPSEC_PLUGIN_VERSION = '1.0' IPSEC_PLUGIN_VERSION = '1.0'
@ -494,7 +494,7 @@ class IPsecDriver(device_drivers.DeviceDriver):
self.conf = self.agent.conf self.conf = self.agent.conf
self.root_helper = self.agent.root_helper self.root_helper = self.agent.root_helper
self.host = host 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.context = context.get_admin_context_without_session()
self.topic = topics.IPSEC_AGENT_TOPIC self.topic = topics.IPSEC_AGENT_TOPIC
node_topic = '%s.%s' % (self.topic, self.host) node_topic = '%s.%s' % (self.topic, self.host)

View File

@ -17,7 +17,7 @@ import abc
import six import six
from neutron.common import rpc_compat from neutron.common import rpc as n_rpc
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.common import constants from neutron.plugins.common import constants
@ -49,7 +49,7 @@ class VpnDriver(object):
pass pass
class BaseIPsecVpnAgentApi(rpc_compat.RpcProxy): class BaseIPsecVpnAgentApi(n_rpc.RpcProxy):
"""Base class for IPSec API to agent.""" """Base class for IPSec API to agent."""
def __init__(self, to_agent_topic, topic, default_version): def __init__(self, to_agent_topic, topic, default_version):

View File

@ -16,7 +16,7 @@ import netaddr
from netaddr import core as net_exc from netaddr import core as net_exc
from neutron.common import exceptions 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 excutils
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.common import constants from neutron.plugins.common import constants
@ -40,7 +40,7 @@ class CsrValidationFailure(exceptions.BadRequest):
"with value '%(value)s'") "with value '%(value)s'")
class CiscoCsrIPsecVpnDriverCallBack(rpc_compat.RpcCallback): class CiscoCsrIPsecVpnDriverCallBack(n_rpc.RpcCallback):
"""Handler for agent to plugin RPC messaging.""" """Handler for agent to plugin RPC messaging."""
@ -68,7 +68,7 @@ class CiscoCsrIPsecVpnDriverCallBack(rpc_compat.RpcCallback):
class CiscoCsrIPsecVpnAgentApi(service_drivers.BaseIPsecVpnAgentApi, class CiscoCsrIPsecVpnAgentApi(service_drivers.BaseIPsecVpnAgentApi,
rpc_compat.RpcCallback): 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."""
@ -86,7 +86,7 @@ class CiscoCsrIPsecVPNDriver(service_drivers.VpnDriver):
def __init__(self, service_plugin): def __init__(self, service_plugin):
super(CiscoCsrIPsecVPNDriver, self).__init__(service_plugin) super(CiscoCsrIPsecVPNDriver, self).__init__(service_plugin)
self.endpoints = [CiscoCsrIPsecVpnDriverCallBack(self)] self.endpoints = [CiscoCsrIPsecVpnDriverCallBack(self)]
self.conn = rpc_compat.create_connection(new=True) self.conn = n_rpc.create_connection(new=True)
self.conn.create_consumer( self.conn.create_consumer(
topics.CISCO_IPSEC_DRIVER_TOPIC, self.endpoints, fanout=False) topics.CISCO_IPSEC_DRIVER_TOPIC, self.endpoints, fanout=False)
self.conn.consume_in_threads() self.conn.consume_in_threads()

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
import netaddr 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.openstack.common import log as logging
from neutron.services.vpn.common import topics from neutron.services.vpn.common import topics
from neutron.services.vpn import service_drivers from neutron.services.vpn import service_drivers
@ -26,7 +26,7 @@ IPSEC = 'ipsec'
BASE_IPSEC_VERSION = '1.0' BASE_IPSEC_VERSION = '1.0'
class IPsecVpnDriverCallBack(rpc_compat.RpcCallback): class IPsecVpnDriverCallBack(n_rpc.RpcCallback):
"""Callback for IPSecVpnDriver rpc.""" """Callback for IPSecVpnDriver rpc."""
# history # history
@ -53,7 +53,7 @@ class IPsecVpnDriverCallBack(rpc_compat.RpcCallback):
class IPsecVpnAgentApi(service_drivers.BaseIPsecVpnAgentApi, class IPsecVpnAgentApi(service_drivers.BaseIPsecVpnAgentApi,
rpc_compat.RpcCallback): n_rpc.RpcCallback):
"""Agent RPC API for IPsecVPNAgent.""" """Agent RPC API for IPsecVPNAgent."""
RPC_API_VERSION = BASE_IPSEC_VERSION RPC_API_VERSION = BASE_IPSEC_VERSION
@ -69,7 +69,7 @@ class IPsecVPNDriver(service_drivers.VpnDriver):
def __init__(self, service_plugin): def __init__(self, service_plugin):
super(IPsecVPNDriver, self).__init__(service_plugin) super(IPsecVPNDriver, self).__init__(service_plugin)
self.endpoints = [IPsecVpnDriverCallBack(self)] self.endpoints = [IPsecVpnDriverCallBack(self)]
self.conn = rpc_compat.create_connection(new=True) self.conn = n_rpc.create_connection(new=True)
self.conn.create_consumer( self.conn.create_consumer(
topics.IPSEC_DRIVER_TOPIC, self.endpoints, fanout=False) topics.IPSEC_DRIVER_TOPIC, self.endpoints, fanout=False)
self.conn.consume_in_threads() self.conn.consume_in_threads()

View File

@ -399,7 +399,7 @@ class TestCiscoCsrIPsecDeviceDriverSyncStatuses(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestCiscoCsrIPsecDeviceDriverSyncStatuses, self).setUp() 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.context.get_admin_context_without_session',
'neutron.openstack.common.' 'neutron.openstack.common.'
'loopingcall.FixedIntervalLoopingCall']: 'loopingcall.FixedIntervalLoopingCall']:

View File

@ -45,7 +45,7 @@ class TestIPsecDeviceDriver(base.BaseTestCase):
'os.makedirs', 'os.makedirs',
'os.path.isdir', 'os.path.isdir',
'neutron.agent.linux.utils.replace_file', 'neutron.agent.linux.utils.replace_file',
'neutron.common.rpc_compat.create_connection', 'neutron.common.rpc.create_connection',
'neutron.services.vpn.device_drivers.ipsec.' 'neutron.services.vpn.device_drivers.ipsec.'
'OpenSwanProcess._gen_config_content', 'OpenSwanProcess._gen_config_content',
'shutil.rmtree', 'shutil.rmtree',

View File

@ -44,7 +44,7 @@ class TestCiscoIPsecDriverValidation(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestCiscoIPsecDriverValidation, self).setUp() 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.service_plugin = mock.Mock()
self.driver = ipsec_driver.CiscoCsrIPsecVPNDriver(self.service_plugin) self.driver = ipsec_driver.CiscoCsrIPsecVPNDriver(self.service_plugin)
self.context = n_ctx.Context('some_user', 'some_tenant') self.context = n_ctx.Context('some_user', 'some_tenant')
@ -284,7 +284,7 @@ class TestCiscoIPsecDriver(base.BaseTestCase):
super(TestCiscoIPsecDriver, self).setUp() super(TestCiscoIPsecDriver, self).setUp()
dbapi.configure_db() dbapi.configure_db()
self.addCleanup(dbapi.clear_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 = mock.Mock()
l3_agent.host = FAKE_HOST l3_agent.host = FAKE_HOST

View File

@ -35,7 +35,7 @@ FAKE_HOST = 'fake_host'
class TestIPsecDriver(base.BaseTestCase): class TestIPsecDriver(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestIPsecDriver, self).setUp() 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 = mock.Mock()
l3_agent.host = FAKE_HOST l3_agent.host = FAKE_HOST