remove rpc create_connection
The neutron.common.rpc.create_connection function is just a reference to the Connection class constructor. This patch removes create_connection and replaces all uses with Connection instead. NeutronLibImpact Change-Id: I2f4b24ba732be47fc9911be1e24406fb1ffe821e
This commit is contained in:
parent
40496c6d07
commit
81f7347b53
|
@ -172,7 +172,7 @@ class FipQosAgentExtension(l3_extension.L3AgentExtension):
|
|||
def _register_rpc_consumers(self):
|
||||
registry.register(self._handle_notification, resources.QOS_POLICY)
|
||||
|
||||
self._connection = n_rpc.create_connection()
|
||||
self._connection = n_rpc.Connection()
|
||||
endpoints = [resources_rpc.ResourcesPushRpcCallback()]
|
||||
topic = resources_rpc.resource_type_versioned_topic(
|
||||
resources.QOS_POLICY)
|
||||
|
|
|
@ -238,7 +238,7 @@ class RemoteResourceWatcher(object):
|
|||
|
||||
def _init_rpc_listeners(self):
|
||||
endpoints = [resources_rpc.ResourcesPushRpcCallback()]
|
||||
self._connection = n_rpc.create_connection()
|
||||
self._connection = n_rpc.Connection()
|
||||
for rtype in self.rcache.resource_types:
|
||||
registry_rpc.register(self.resource_change_handler, rtype)
|
||||
topic = resources_rpc.resource_type_versioned_topic(rtype)
|
||||
|
|
|
@ -47,7 +47,7 @@ def create_consumers(endpoints, prefix, topic_details, start_listening=True):
|
|||
:returns: A common Connection.
|
||||
"""
|
||||
|
||||
connection = n_rpc.create_connection()
|
||||
connection = n_rpc.Connection()
|
||||
for details in topic_details:
|
||||
topic, operation, node_name = itertools.islice(
|
||||
itertools.chain(details, [None]), 3)
|
||||
|
|
|
@ -279,7 +279,7 @@ class Service(service.Service):
|
|||
def start(self):
|
||||
super(Service, self).start()
|
||||
|
||||
self.conn = create_connection()
|
||||
self.conn = Connection()
|
||||
LOG.debug("Creating Consumer connection for Service %s",
|
||||
self.topic)
|
||||
|
||||
|
@ -327,7 +327,3 @@ class Connection(object):
|
|||
server.stop()
|
||||
for server in self.servers:
|
||||
server.wait()
|
||||
|
||||
|
||||
# TODO(boden): remove create_connection
|
||||
create_connection = Connection
|
||||
|
|
|
@ -279,7 +279,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||
"""Start the RPC loop to let the plugin communicate with agents."""
|
||||
self._setup_rpc()
|
||||
self.topic = topics.PLUGIN
|
||||
self.conn = n_rpc.create_connection()
|
||||
self.conn = n_rpc.Connection()
|
||||
self.conn.create_consumer(self.topic, self.endpoints, fanout=False)
|
||||
self.conn.create_consumer(
|
||||
topics.SERVER_RESOURCE_VERSIONS,
|
||||
|
@ -292,7 +292,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||
return self.conn.consume_in_threads()
|
||||
|
||||
def start_rpc_state_reports_listener(self):
|
||||
self.conn_reports = n_rpc.create_connection()
|
||||
self.conn_reports = n_rpc.Connection()
|
||||
self.conn_reports.create_consumer(topics.REPORTS,
|
||||
[agents_db.AgentExtRpcCallback()],
|
||||
fanout=False)
|
||||
|
|
|
@ -118,7 +118,7 @@ class L3RouterPlugin(service_base.ServicePluginBase,
|
|||
def start_rpc_listeners(self):
|
||||
# RPC support
|
||||
self.topic = topics.L3PLUGIN
|
||||
self.conn = n_rpc.create_connection()
|
||||
self.conn = n_rpc.Connection()
|
||||
self.endpoints = [l3_rpc.L3RpcCallback()]
|
||||
self.conn.create_consumer(self.topic, self.endpoints,
|
||||
fanout=False)
|
||||
|
|
|
@ -33,7 +33,7 @@ class LoggingApiSkeleton(object):
|
|||
version='1.0', namespace=log_const.RPC_NAMESPACE_LOGGING)
|
||||
|
||||
def __init__(self):
|
||||
self.conn = n_rpc.create_connection()
|
||||
self.conn = n_rpc.Connection()
|
||||
self.conn.create_consumer(log_const.LOGGING_PLUGIN, [self],
|
||||
fanout=False)
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class MeteringPlugin(metering_db.MeteringDbMixin):
|
|||
|
||||
def start_rpc_listeners(self):
|
||||
self.endpoints = [metering_rpc.MeteringRpcCallbacks(self)]
|
||||
self.conn = n_rpc.create_connection()
|
||||
self.conn = n_rpc.Connection()
|
||||
self.conn.create_consumer(
|
||||
topics.METERING_PLUGIN, self.endpoints, fanout=False)
|
||||
return self.conn.consume_in_threads()
|
||||
|
|
|
@ -45,7 +45,7 @@ class TrunkSkeleton(object):
|
|||
registry.register(self.handle_trunks, resources.TRUNK)
|
||||
registry.register(self.handle_subports, resources.SUBPORT)
|
||||
|
||||
self._connection = n_rpc.create_connection()
|
||||
self._connection = n_rpc.Connection()
|
||||
endpoints = [resources_rpc.ResourcesPushRpcCallback()]
|
||||
topic = resources_rpc.resource_type_versioned_topic(resources.SUBPORT)
|
||||
self._connection.create_consumer(topic, endpoints, fanout=True)
|
||||
|
|
|
@ -67,7 +67,7 @@ class TrunkSkeleton(object):
|
|||
def __init__(self):
|
||||
# Used to provide trunk lookups for the agent.
|
||||
registry.provide(trunk_by_port_provider, resources.TRUNK)
|
||||
self._connection = n_rpc.create_connection()
|
||||
self._connection = n_rpc.Connection()
|
||||
self._connection.create_consumer(
|
||||
constants.TRUNK_BASE_TOPIC, [self], fanout=False)
|
||||
self._connection.consume_in_threads()
|
||||
|
|
|
@ -141,7 +141,7 @@ class FipQosExtensionInitializeTestCase(QosExtensionBaseTestCase):
|
|||
@mock.patch.object(registry, 'register')
|
||||
@mock.patch.object(resources_rpc, 'ResourcesPushRpcCallback')
|
||||
def test_initialize_subscribed_to_rpc(self, rpc_mock, subscribe_mock):
|
||||
call_to_patch = 'neutron.common.rpc.create_connection'
|
||||
call_to_patch = 'neutron.common.rpc.Connection'
|
||||
with mock.patch(call_to_patch,
|
||||
return_value=self.connection) as create_connection:
|
||||
self.fip_qos_ext.initialize(
|
||||
|
|
|
@ -116,7 +116,7 @@ class AgentRPCMethods(base.BaseTestCase):
|
|||
|
||||
def _test_create_consumers(
|
||||
self, endpoints, method, expected, topics, listen):
|
||||
call_to_patch = 'neutron.common.rpc.create_connection'
|
||||
call_to_patch = 'neutron.common.rpc.Connection'
|
||||
with mock.patch(call_to_patch) as create_connection:
|
||||
rpc.create_consumers(
|
||||
endpoints, method, topics, start_listening=listen)
|
||||
|
@ -158,7 +158,7 @@ class AgentRPCMethods(base.BaseTestCase):
|
|||
mock.call().consume_in_threads()
|
||||
]
|
||||
|
||||
call_to_patch = 'neutron.common.rpc.create_connection'
|
||||
call_to_patch = 'neutron.common.rpc.Connection'
|
||||
with mock.patch(call_to_patch) as create_connection:
|
||||
rpc.create_consumers(endpoints, 'foo', [('topic', 'op', 'node1')])
|
||||
create_connection.assert_has_calls(expected)
|
||||
|
|
Loading…
Reference in New Issue