]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Drop usage of RpcProxy from L3PluginApi
authorRussell Bryant <rbryant@redhat.com>
Fri, 7 Nov 2014 15:30:15 +0000 (16:30 +0100)
committerRussell Bryant <rbryant@redhat.com>
Tue, 18 Nov 2014 16:57:46 +0000 (16:57 +0000)
Drop the usage of the RpcProxy compatibility class from the
L3PluginApi.  The equivalent direct usage of the oslo.messaging APIs
are now being used instead.

Part of blueprint drop-rpc-compat.

Change-Id: I6639d1aa8acca8c0544020e28489e71f3d5d2955

neutron/agent/l3_agent.py
neutron/tests/functional/agent/test_l3_agent.py

index 4c36873c35869d73a487f2ce3c2a783e151432d1..3120f3c3c74176c64f354e2c6e7c39e7463fd223 100644 (file)
@@ -78,7 +78,7 @@ PRIORITY_SYNC_ROUTERS_TASK = 1
 DELETE_ROUTER = 1
 
 
-class L3PluginApi(n_rpc.RpcProxy):
+class L3PluginApi(object):
     """Agent side of the l3 agent RPC API.
 
     API version history:
@@ -92,18 +92,16 @@ class L3PluginApi(n_rpc.RpcProxy):
 
     """
 
-    BASE_RPC_API_VERSION = '1.0'
-
     def __init__(self, topic, host):
-        super(L3PluginApi, self).__init__(
-            topic=topic, default_version=self.BASE_RPC_API_VERSION)
         self.host = host
+        target = messaging.Target(topic=topic, version='1.0')
+        self.client = n_rpc.get_client(target)
 
     def get_routers(self, context, router_ids=None):
         """Make a remote process call to retrieve the sync data for routers."""
-        return self.call(context,
-                         self.make_msg('sync_routers', host=self.host,
-                                       router_ids=router_ids))
+        cctxt = self.client.prepare()
+        return cctxt.call(context, 'sync_routers', host=self.host,
+                          router_ids=router_ids)
 
     def get_external_network_id(self, context):
         """Make a remote process call to retrieve the external network id.
@@ -112,40 +110,31 @@ class L3PluginApi(n_rpc.RpcProxy):
                                       exc_type if there are more than one
                                       external network
         """
-        return self.call(context,
-                         self.make_msg('get_external_network_id',
-                                       host=self.host))
+        cctxt = self.client.prepare()
+        return cctxt.call(context, 'get_external_network_id', host=self.host)
 
     def update_floatingip_statuses(self, context, router_id, fip_statuses):
         """Call the plugin update floating IPs's operational status."""
-        return self.call(context,
-                         self.make_msg('update_floatingip_statuses',
-                                       router_id=router_id,
-                                       fip_statuses=fip_statuses),
-                         version='1.1')
+        cctxt = self.client.prepare(version='1.1')
+        return cctxt.call(context, 'update_floatingip_statuses',
+                          router_id=router_id, fip_statuses=fip_statuses)
 
     def get_ports_by_subnet(self, context, subnet_id):
         """Retrieve ports by subnet id."""
-        return self.call(context,
-                         self.make_msg('get_ports_by_subnet', host=self.host,
-                                       subnet_id=subnet_id),
-                         topic=self.topic,
-                         version='1.2')
+        cctxt = self.client.prepare(version='1.2')
+        return cctxt.call(context, 'get_ports_by_subnet', host=self.host,
+                          subnet_id=subnet_id)
 
     def get_agent_gateway_port(self, context, fip_net):
         """Get or create an agent_gateway_port."""
-        return self.call(context,
-                         self.make_msg('get_agent_gateway_port',
-                                       network_id=fip_net, host=self.host),
-                         topic=self.topic,
-                         version='1.2')
+        cctxt = self.client.prepare(version='1.2')
+        return cctxt.call(context, 'get_agent_gateway_port',
+                          network_id=fip_net, host=self.host)
 
     def get_service_plugin_list(self, context):
         """Make a call to get the list of activated services."""
-        return self.call(context,
-                         self.make_msg('get_service_plugin_list'),
-                         topic=self.topic,
-                         version='1.3')
+        cctxt = self.client.prepare(version='1.3')
+        return cctxt.call(context, 'get_service_plugin_list')
 
 
 class LinkLocalAddressPair(netaddr.IPNetwork):
index 24c9de94f93ea25b8ef16801641e85bd604a5b9b..77d1b15cbb7360c3a9a93e7074e94908ed2a7022 100644 (file)
@@ -55,9 +55,8 @@ class L3AgentTestFramework(base.BaseOVSLinuxTestCase):
         br_ex = self.create_ovs_bridge()
         cfg.CONF.set_override('external_network_bridge', br_ex.br_name)
 
-        mock.patch('neutron.common.rpc.RpcProxy.cast').start()
-        mock.patch('neutron.common.rpc.RpcProxy.call').start()
-        mock.patch('neutron.common.rpc.RpcProxy.fanout_cast').start()
+        mock.patch('neutron.agent.l3_agent.L3PluginApi').start()
+
         self.agent = l3_agent.L3NATAgent('localhost', cfg.CONF)
 
         mock.patch.object(self.agent, '_send_gratuitous_arp_packet').start()