Drop usage of RpcProxy from L3PluginApi

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
This commit is contained in:
Russell Bryant 2014-11-07 16:30:15 +01:00
parent 50f65e2a9a
commit e38e259c28
2 changed files with 21 additions and 33 deletions

View 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):

View 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()