From 7021f12aba38320d3354684ece477d7920fdaaf8 Mon Sep 17 00:00:00 2001 From: rossella Date: Wed, 23 Jul 2014 19:26:12 +0000 Subject: [PATCH] Remove redundant topic from rpc calls RpcProxy sets by default topic=self.topic, there's no need to specify it explicitly in derived class, unless it is overridden Change-Id: I19b9a67072a7f3c42e3b0e4ba412241a056a79a3 Closes-bug: 1348180 --- neutron/agent/dhcp_agent.py | 21 ++++++---------- neutron/agent/l3_agent.py | 7 ++---- neutron/agent/rpc.py | 21 +++++++--------- neutron/agent/securitygroups_rpc.py | 3 +-- .../agentnotifiers/metering_rpc_agent_api.py | 6 ++--- neutron/api/rpc/handlers/dvr_rpc.py | 12 ++++------ .../plugins/ibm/agent/sdnve_neutron_agent.py | 3 +-- .../plugins/ryu/agent/ryu_neutron_agent.py | 3 +-- .../firewall/agents/firewall_agent_api.py | 6 ++--- .../agents/l3reference/firewall_l3_agent.py | 6 ++--- neutron/services/firewall/fwaas_plugin.py | 9 +++---- .../services/loadbalancer/agent/agent_api.py | 24 +++++++------------ .../vpn/device_drivers/cisco_ipsec.py | 6 ++--- neutron/services/vpn/device_drivers/ipsec.py | 6 ++--- .../tests/unit/hyperv/test_hyperv_rpcapi.py | 22 ++++++++--------- neutron/tests/unit/linuxbridge/test_rpcapi.py | 12 ++++++---- neutron/tests/unit/ml2/test_rpcapi.py | 24 +++++++++---------- neutron/tests/unit/mlnx/test_rpcapi.py | 12 ++++++---- .../tests/unit/openvswitch/test_ovs_rpcapi.py | 14 ++++++----- neutron/tests/unit/ryu/test_ryu_agent.py | 2 +- .../agents/test_firewall_agent_api.py | 6 ++--- .../services/firewall/test_fwaas_plugin.py | 3 +-- .../services/loadbalancer/agent/test_api.py | 22 ++++++----------- .../services/metering/test_metering_plugin.py | 21 ++++++---------- neutron/tests/unit/test_agent_rpc.py | 2 -- .../tests/unit/test_security_groups_rpc.py | 3 +-- 26 files changed, 109 insertions(+), 167 deletions(-) diff --git a/neutron/agent/dhcp_agent.py b/neutron/agent/dhcp_agent.py index 29119799e..13514c519 100644 --- a/neutron/agent/dhcp_agent.py +++ b/neutron/agent/dhcp_agent.py @@ -400,8 +400,7 @@ class DhcpPluginApi(n_rpc.RpcProxy): """Make a remote process call to retrieve all network info.""" networks = self.call(self.context, self.make_msg('get_active_networks_info', - host=self.host), - topic=self.topic) + host=self.host)) return [dhcp.NetModel(self.use_namespaces, n) for n in networks] def get_network_info(self, network_id): @@ -409,8 +408,7 @@ class DhcpPluginApi(n_rpc.RpcProxy): network = self.call(self.context, self.make_msg('get_network_info', network_id=network_id, - host=self.host), - topic=self.topic) + host=self.host)) if network: return dhcp.NetModel(self.use_namespaces, network) @@ -420,8 +418,7 @@ class DhcpPluginApi(n_rpc.RpcProxy): self.make_msg('get_dhcp_port', network_id=network_id, device_id=device_id, - host=self.host), - topic=self.topic) + host=self.host)) if port: return dhcp.DictModel(port) @@ -430,8 +427,7 @@ class DhcpPluginApi(n_rpc.RpcProxy): port = self.call(self.context, self.make_msg('create_dhcp_port', port=port, - host=self.host), - topic=self.topic) + host=self.host)) if port: return dhcp.DictModel(port) @@ -441,8 +437,7 @@ class DhcpPluginApi(n_rpc.RpcProxy): self.make_msg('update_dhcp_port', port_id=port_id, port=port, - host=self.host), - topic=self.topic) + host=self.host)) if port: return dhcp.DictModel(port) @@ -452,8 +447,7 @@ class DhcpPluginApi(n_rpc.RpcProxy): self.make_msg('release_dhcp_port', network_id=network_id, device_id=device_id, - host=self.host), - topic=self.topic) + host=self.host)) def release_port_fixed_ip(self, network_id, device_id, subnet_id): """Make a remote process call to release a fixed_ip on the port.""" @@ -462,8 +456,7 @@ class DhcpPluginApi(n_rpc.RpcProxy): network_id=network_id, subnet_id=subnet_id, device_id=device_id, - host=self.host), - topic=self.topic) + host=self.host)) class NetworkCache(object): diff --git a/neutron/agent/l3_agent.py b/neutron/agent/l3_agent.py index cf66df7b1..5e5fe663c 100644 --- a/neutron/agent/l3_agent.py +++ b/neutron/agent/l3_agent.py @@ -96,8 +96,7 @@ class L3PluginApi(n_rpc.RpcProxy): """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), - topic=self.topic) + router_ids=router_ids)) def get_external_network_id(self, context): """Make a remote process call to retrieve the external network id. @@ -108,8 +107,7 @@ class L3PluginApi(n_rpc.RpcProxy): """ return self.call(context, self.make_msg('get_external_network_id', - host=self.host), - topic=self.topic) + host=self.host)) def update_floatingip_statuses(self, context, router_id, fip_statuses): """Call the plugin update floating IPs's operational status.""" @@ -117,7 +115,6 @@ class L3PluginApi(n_rpc.RpcProxy): self.make_msg('update_floatingip_statuses', router_id=router_id, fip_statuses=fip_statuses), - topic=self.topic, version='1.1') def get_ports_by_subnet(self, context, subnet_id): diff --git a/neutron/agent/rpc.py b/neutron/agent/rpc.py index dee9d2517..7777a6673 100644 --- a/neutron/agent/rpc.py +++ b/neutron/agent/rpc.py @@ -67,9 +67,9 @@ class PluginReportStateAPI(n_rpc.RpcProxy): agent_state}, time=timeutils.strtime()) if use_call: - return self.call(context, msg, topic=self.topic) + return self.call(context, msg) else: - return self.cast(context, msg, topic=self.topic) + return self.cast(context, msg) class PluginApi(n_rpc.RpcProxy): @@ -91,8 +91,7 @@ class PluginApi(n_rpc.RpcProxy): def get_device_details(self, context, device, agent_id, host=None): return self.call(context, self.make_msg('get_device_details', device=device, - agent_id=agent_id, host=host), - topic=self.topic) + agent_id=agent_id, host=host)) def get_devices_details_list(self, context, devices, agent_id, host=None): res = [] @@ -102,7 +101,7 @@ class PluginApi(n_rpc.RpcProxy): devices=devices, agent_id=agent_id, host=host), - topic=self.topic, version='1.3') + version='1.3') except messaging.UnsupportedVersion: # If the server has not been upgraded yet, a DVR-enabled agent # may not work correctly, however it can function in 'degraded' @@ -112,8 +111,7 @@ class PluginApi(n_rpc.RpcProxy): res = [ self.call(context, self.make_msg('get_device_details', device=device, - agent_id=agent_id, host=host), - topic=self.topic) + agent_id=agent_id, host=host)) for device in devices ] return res @@ -121,17 +119,14 @@ class PluginApi(n_rpc.RpcProxy): def update_device_down(self, context, device, agent_id, host=None): return self.call(context, self.make_msg('update_device_down', device=device, - agent_id=agent_id, host=host), - topic=self.topic) + agent_id=agent_id, host=host)) def update_device_up(self, context, device, agent_id, host=None): return self.call(context, self.make_msg('update_device_up', device=device, - agent_id=agent_id, host=host), - topic=self.topic) + agent_id=agent_id, host=host)) def tunnel_sync(self, context, tunnel_ip, tunnel_type=None): return self.call(context, self.make_msg('tunnel_sync', tunnel_ip=tunnel_ip, - tunnel_type=tunnel_type), - topic=self.topic) + tunnel_type=tunnel_type)) diff --git a/neutron/agent/securitygroups_rpc.py b/neutron/agent/securitygroups_rpc.py index 163bfe339..49f0b7dab 100644 --- a/neutron/agent/securitygroups_rpc.py +++ b/neutron/agent/securitygroups_rpc.py @@ -80,8 +80,7 @@ class SecurityGroupServerRpcApiMixin(object): return self.call(context, self.make_msg('security_group_rules_for_devices', devices=devices), - version=SG_RPC_VERSION, - topic=self.topic) + version=SG_RPC_VERSION) class SecurityGroupAgentRpcCallbackMixin(object): diff --git a/neutron/api/rpc/agentnotifiers/metering_rpc_agent_api.py b/neutron/api/rpc/agentnotifiers/metering_rpc_agent_api.py index e00e73b39..3b5debc55 100644 --- a/neutron/api/rpc/agentnotifiers/metering_rpc_agent_api.py +++ b/neutron/api/rpc/agentnotifiers/metering_rpc_agent_api.py @@ -68,8 +68,7 @@ class MeteringAgentNotifyAPI(n_rpc.RpcProxy): 'router_id': router_id}) self.fanout_cast( context, self.make_msg(method, - router_id=router_id), - topic=self.topic) + router_id=router_id)) def _notification(self, context, method, routers): """Notify all the agents that are hosting the routers.""" @@ -79,8 +78,7 @@ class MeteringAgentNotifyAPI(n_rpc.RpcProxy): plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS): self._agent_notification(context, method, routers) else: - self.fanout_cast(context, self.make_msg(method, routers=routers), - topic=self.topic) + self.fanout_cast(context, self.make_msg(method, routers=routers)) def router_deleted(self, context, router_id): self._notification_fanout(context, 'router_deleted', router_id) diff --git a/neutron/api/rpc/handlers/dvr_rpc.py b/neutron/api/rpc/handlers/dvr_rpc.py index 3a9623ead..a555c91b2 100644 --- a/neutron/api/rpc/handlers/dvr_rpc.py +++ b/neutron/api/rpc/handlers/dvr_rpc.py @@ -31,15 +31,13 @@ class DVRServerRpcApiMixin(object): return self.call(context, self.make_msg('get_dvr_mac_address_by_host', host=host), - version=self.DVR_RPC_VERSION, - topic=self.topic) + version=self.DVR_RPC_VERSION) @log.log def get_dvr_mac_address_list(self, context): return self.call(context, self.make_msg('get_dvr_mac_address_list'), - version=self.DVR_RPC_VERSION, - topic=self.topic) + version=self.DVR_RPC_VERSION) @log.log def get_compute_ports_on_host_by_subnet(self, context, host, subnet): @@ -47,16 +45,14 @@ class DVRServerRpcApiMixin(object): self.make_msg('get_compute_ports_on_host_by_subnet', host=host, subnet=subnet), - version=self.DVR_RPC_VERSION, - topic=self.topic) + version=self.DVR_RPC_VERSION) @log.log def get_subnet_for_dvr(self, context, subnet): return self.call(context, self.make_msg('get_subnet_for_dvr', subnet=subnet), - version=self.DVR_RPC_VERSION, - topic=self.topic) + version=self.DVR_RPC_VERSION) class DVRServerRpcCallbackMixin(object): diff --git a/neutron/plugins/ibm/agent/sdnve_neutron_agent.py b/neutron/plugins/ibm/agent/sdnve_neutron_agent.py index b3203d4ae..08d5a08bb 100644 --- a/neutron/plugins/ibm/agent/sdnve_neutron_agent.py +++ b/neutron/plugins/ibm/agent/sdnve_neutron_agent.py @@ -48,8 +48,7 @@ class SdnvePluginApi(agent_rpc.PluginApi): def sdnve_info(self, context, info): return self.call(context, - self.make_msg('sdnve_info', info=info), - topic=self.topic) + self.make_msg('sdnve_info', info=info)) class SdnveNeutronAgent(n_rpc.RpcCallback): diff --git a/neutron/plugins/ryu/agent/ryu_neutron_agent.py b/neutron/plugins/ryu/agent/ryu_neutron_agent.py index 18db0f919..dfe9e4ddc 100755 --- a/neutron/plugins/ryu/agent/ryu_neutron_agent.py +++ b/neutron/plugins/ryu/agent/ryu_neutron_agent.py @@ -168,8 +168,7 @@ class RyuPluginApi(agent_rpc.PluginApi, def get_ofp_rest_api_addr(self, context): LOG.debug(_("Get Ryu rest API address")) return self.call(context, - self.make_msg('get_ofp_rest_api'), - topic=self.topic) + self.make_msg('get_ofp_rest_api')) class RyuSecurityGroupAgent(sg_rpc.SecurityGroupAgentRpcMixin): diff --git a/neutron/services/firewall/agents/firewall_agent_api.py b/neutron/services/firewall/agents/firewall_agent_api.py index 9dcc44ae0..56ee804a5 100644 --- a/neutron/services/firewall/agents/firewall_agent_api.py +++ b/neutron/services/firewall/agents/firewall_agent_api.py @@ -52,15 +52,13 @@ class FWaaSPluginApiMixin(n_rpc.RpcProxy): """Make a RPC to set the status of a firewall.""" return self.call(context, self.make_msg('set_firewall_status', host=self.host, - firewall_id=firewall_id, status=status), - topic=self.topic) + firewall_id=firewall_id, status=status)) def firewall_deleted(self, context, firewall_id): """Make a RPC to indicate that the firewall resources are deleted.""" return self.call(context, self.make_msg('firewall_deleted', host=self.host, - firewall_id=firewall_id), - topic=self.topic) + firewall_id=firewall_id)) class FWaaSAgentRpcCallbackMixin(object): diff --git a/neutron/services/firewall/agents/l3reference/firewall_l3_agent.py b/neutron/services/firewall/agents/l3reference/firewall_l3_agent.py index fbe8c132a..a650a9e4e 100644 --- a/neutron/services/firewall/agents/l3reference/firewall_l3_agent.py +++ b/neutron/services/firewall/agents/l3reference/firewall_l3_agent.py @@ -44,8 +44,7 @@ class FWaaSL3PluginApi(api.FWaaSPluginApiMixin): return self.call(context, self.make_msg('get_firewalls_for_tenant', - host=self.host), - topic=self.topic) + host=self.host)) def get_tenants_with_firewalls(self, context, **kwargs): """Get all Tenants that have Firewalls configured from plugin.""" @@ -53,8 +52,7 @@ class FWaaSL3PluginApi(api.FWaaSPluginApiMixin): return self.call(context, self.make_msg('get_tenants_with_firewalls', - host=self.host), - topic=self.topic) + host=self.host)) class FWaaSL3AgentRpcCallback(api.FWaaSAgentRpcCallbackMixin): diff --git a/neutron/services/firewall/fwaas_plugin.py b/neutron/services/firewall/fwaas_plugin.py index 27a543930..5c8d04c77 100644 --- a/neutron/services/firewall/fwaas_plugin.py +++ b/neutron/services/firewall/fwaas_plugin.py @@ -114,24 +114,21 @@ class FirewallAgentApi(n_rpc.RpcProxy): return self.fanout_cast( context, self.make_msg('create_firewall', firewall=firewall, - host=self.host), - topic=self.topic + host=self.host) ) def update_firewall(self, context, firewall): return self.fanout_cast( context, self.make_msg('update_firewall', firewall=firewall, - host=self.host), - topic=self.topic + host=self.host) ) def delete_firewall(self, context, firewall): return self.fanout_cast( context, self.make_msg('delete_firewall', firewall=firewall, - host=self.host), - topic=self.topic + host=self.host) ) diff --git a/neutron/services/loadbalancer/agent/agent_api.py b/neutron/services/loadbalancer/agent/agent_api.py index eb2a165c5..219c0a226 100644 --- a/neutron/services/loadbalancer/agent/agent_api.py +++ b/neutron/services/loadbalancer/agent/agent_api.py @@ -35,22 +35,19 @@ class LbaasAgentApi(n_rpc.RpcProxy): def get_ready_devices(self): return self.call( self.context, - self.make_msg('get_ready_devices', host=self.host), - topic=self.topic + self.make_msg('get_ready_devices', host=self.host) ) def pool_destroyed(self, pool_id): return self.call( self.context, - self.make_msg('pool_destroyed', pool_id=pool_id), - topic=self.topic + self.make_msg('pool_destroyed', pool_id=pool_id) ) def pool_deployed(self, pool_id): return self.call( self.context, - self.make_msg('pool_deployed', pool_id=pool_id), - topic=self.topic + self.make_msg('pool_deployed', pool_id=pool_id) ) def get_logical_device(self, pool_id): @@ -59,30 +56,26 @@ class LbaasAgentApi(n_rpc.RpcProxy): self.make_msg( 'get_logical_device', pool_id=pool_id - ), - topic=self.topic + ) ) def update_status(self, obj_type, obj_id, status): return self.call( self.context, self.make_msg('update_status', obj_type=obj_type, obj_id=obj_id, - status=status), - topic=self.topic + status=status) ) def plug_vip_port(self, port_id): return self.call( self.context, - self.make_msg('plug_vip_port', port_id=port_id, host=self.host), - topic=self.topic + self.make_msg('plug_vip_port', port_id=port_id, host=self.host) ) def unplug_vip_port(self, port_id): return self.call( self.context, - self.make_msg('unplug_vip_port', port_id=port_id, host=self.host), - topic=self.topic + self.make_msg('unplug_vip_port', port_id=port_id, host=self.host) ) def update_pool_stats(self, pool_id, stats): @@ -93,6 +86,5 @@ class LbaasAgentApi(n_rpc.RpcProxy): pool_id=pool_id, stats=stats, host=self.host - ), - topic=self.topic + ) ) diff --git a/neutron/services/vpn/device_drivers/cisco_ipsec.py b/neutron/services/vpn/device_drivers/cisco_ipsec.py index ddc51b693..e9c8b166c 100644 --- a/neutron/services/vpn/device_drivers/cisco_ipsec.py +++ b/neutron/services/vpn/device_drivers/cisco_ipsec.py @@ -161,15 +161,13 @@ class CiscoCsrIPsecVpnDriverApi(n_rpc.RpcProxy): """ return self.call(context, self.make_msg('get_vpn_services_on_host', - host=host), - topic=self.topic) + host=host)) def update_status(self, context, status): """Update status for all VPN services and connections.""" return self.cast(context, self.make_msg('update_status', - status=status), - topic=self.topic) + status=status)) @six.add_metaclass(abc.ABCMeta) diff --git a/neutron/services/vpn/device_drivers/ipsec.py b/neutron/services/vpn/device_drivers/ipsec.py index 3f6cc966c..c19b61ec2 100644 --- a/neutron/services/vpn/device_drivers/ipsec.py +++ b/neutron/services/vpn/device_drivers/ipsec.py @@ -454,8 +454,7 @@ class IPsecVpnDriverApi(n_rpc.RpcProxy): return self.call(context, self.make_msg('get_vpn_services_on_host', host=host), - version=self.IPSEC_PLUGIN_VERSION, - topic=self.topic) + version=self.IPSEC_PLUGIN_VERSION) def update_status(self, context, status): """Update local status. @@ -466,8 +465,7 @@ class IPsecVpnDriverApi(n_rpc.RpcProxy): return self.cast(context, self.make_msg('update_status', status=status), - version=self.IPSEC_PLUGIN_VERSION, - topic=self.topic) + version=self.IPSEC_PLUGIN_VERSION) @six.add_metaclass(abc.ABCMeta) diff --git a/neutron/tests/unit/hyperv/test_hyperv_rpcapi.py b/neutron/tests/unit/hyperv/test_hyperv_rpcapi.py index 06372561c..971efdea0 100644 --- a/neutron/tests/unit/hyperv/test_hyperv_rpcapi.py +++ b/neutron/tests/unit/hyperv/test_hyperv_rpcapi.py @@ -46,14 +46,14 @@ class rpcHyperVApiTestCase(base.BaseTestCase): retval = getattr(rpcapi, method)(ctxt, **kwargs) self.assertEqual(retval, expected_retval) + additional_args = {} + if topic: + additional_args['topic'] = topic if expected_version: - expected = [ - mock.call(ctxt, expected_msg, topic=topic, - version=expected_version)] - else: - expected = [ - mock.call(ctxt, expected_msg, topic=topic) - ] + additional_args['version'] = expected_version + expected = [ + mock.call(ctxt, expected_msg, **additional_args) + ] rpc_method_mock.assert_has_calls(expected) def test_delete_network(self): @@ -106,7 +106,7 @@ class rpcHyperVApiTestCase(base.BaseTestCase): def test_device_details(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) self._test_hyperv_neutron_api( - rpcapi, topics.PLUGIN, + rpcapi, None, 'get_device_details', rpc_method='call', device='fake_device', agent_id='fake_agent_id', @@ -115,7 +115,7 @@ class rpcHyperVApiTestCase(base.BaseTestCase): def test_devices_details_list(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) self._test_hyperv_neutron_api( - rpcapi, topics.PLUGIN, + rpcapi, None, 'get_devices_details_list', rpc_method='call', devices=['fake_device1', 'fake_device2'], agent_id='fake_agent_id', host='fake_host', @@ -124,7 +124,7 @@ class rpcHyperVApiTestCase(base.BaseTestCase): def test_update_device_down(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) self._test_hyperv_neutron_api( - rpcapi, topics.PLUGIN, + rpcapi, None, 'update_device_down', rpc_method='call', device='fake_device', agent_id='fake_agent_id', @@ -133,7 +133,7 @@ class rpcHyperVApiTestCase(base.BaseTestCase): def test_tunnel_sync(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) self._test_hyperv_neutron_api( - rpcapi, topics.PLUGIN, + rpcapi, None, 'tunnel_sync', rpc_method='call', tunnel_ip='fake_tunnel_ip', tunnel_type=None) diff --git a/neutron/tests/unit/linuxbridge/test_rpcapi.py b/neutron/tests/unit/linuxbridge/test_rpcapi.py index 8b049e013..ee2972f67 100644 --- a/neutron/tests/unit/linuxbridge/test_rpcapi.py +++ b/neutron/tests/unit/linuxbridge/test_rpcapi.py @@ -31,7 +31,9 @@ class rpcApiTestCase(base.BaseTestCase): expected_msg=None, **kwargs): ctxt = context.RequestContext('fake_user', 'fake_project') expected_retval = 'foo' if method == 'call' else None - expected_kwargs = {'topic': topic} + expected_kwargs = {} + if topic: + expected_kwargs['topic'] = topic if 'version' in kwargs: expected_kwargs['version'] = kwargs.pop('version') if not expected_msg: @@ -110,7 +112,7 @@ class rpcApiTestCase(base.BaseTestCase): def test_device_details(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) - self._test_lb_api(rpcapi, topics.PLUGIN, + self._test_lb_api(rpcapi, None, 'get_device_details', rpc_method='call', device='fake_device', agent_id='fake_agent_id', @@ -118,7 +120,7 @@ class rpcApiTestCase(base.BaseTestCase): def test_devices_details_list(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) - self._test_lb_api(rpcapi, topics.PLUGIN, + self._test_lb_api(rpcapi, None, 'get_devices_details_list', rpc_method='call', devices=['fake_device1', 'fake_device2'], agent_id='fake_agent_id', host='fake_host', @@ -126,7 +128,7 @@ class rpcApiTestCase(base.BaseTestCase): def test_update_device_down(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) - self._test_lb_api(rpcapi, topics.PLUGIN, + self._test_lb_api(rpcapi, None, 'update_device_down', rpc_method='call', device='fake_device', agent_id='fake_agent_id', @@ -134,7 +136,7 @@ class rpcApiTestCase(base.BaseTestCase): def test_update_device_up(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) - self._test_lb_api(rpcapi, topics.PLUGIN, + self._test_lb_api(rpcapi, None, 'update_device_up', rpc_method='call', device='fake_device', agent_id='fake_agent_id', diff --git a/neutron/tests/unit/ml2/test_rpcapi.py b/neutron/tests/unit/ml2/test_rpcapi.py index 8277b2594..357312c16 100644 --- a/neutron/tests/unit/ml2/test_rpcapi.py +++ b/neutron/tests/unit/ml2/test_rpcapi.py @@ -80,14 +80,14 @@ class RpcApiTestCase(base.BaseTestCase): retval = getattr(rpcapi, method)(ctxt, **kwargs) self.assertEqual(retval, expected_retval) + additional_args = {} + if topic: + additional_args['topic'] = topic if expected_version: - expected = [ - mock.call(ctxt, expected_msg, topic=topic, - version=expected_version)] - else: - expected = [ - mock.call(ctxt, expected_msg, topic=topic) - ] + additional_args['version'] = expected_version + expected = [ + mock.call(ctxt, expected_msg, **additional_args) + ] rpc_method_mock.assert_has_calls(expected) def test_delete_network(self): @@ -122,7 +122,7 @@ class RpcApiTestCase(base.BaseTestCase): def test_device_details(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) - self._test_rpc_api(rpcapi, topics.PLUGIN, + self._test_rpc_api(rpcapi, None, 'get_device_details', rpc_method='call', device='fake_device', agent_id='fake_agent_id', @@ -130,7 +130,7 @@ class RpcApiTestCase(base.BaseTestCase): def test_devices_details_list(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) - self._test_rpc_api(rpcapi, topics.PLUGIN, + self._test_rpc_api(rpcapi, None, 'get_devices_details_list', rpc_method='call', devices=['fake_device1', 'fake_device2'], agent_id='fake_agent_id', host='fake_host', @@ -138,7 +138,7 @@ class RpcApiTestCase(base.BaseTestCase): def test_update_device_down(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) - self._test_rpc_api(rpcapi, topics.PLUGIN, + self._test_rpc_api(rpcapi, None, 'update_device_down', rpc_method='call', device='fake_device', agent_id='fake_agent_id', @@ -146,14 +146,14 @@ class RpcApiTestCase(base.BaseTestCase): def test_tunnel_sync(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) - self._test_rpc_api(rpcapi, topics.PLUGIN, + self._test_rpc_api(rpcapi, None, 'tunnel_sync', rpc_method='call', tunnel_ip='fake_tunnel_ip', tunnel_type=None) def test_update_device_up(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) - self._test_rpc_api(rpcapi, topics.PLUGIN, + self._test_rpc_api(rpcapi, None, 'update_device_up', rpc_method='call', device='fake_device', agent_id='fake_agent_id', diff --git a/neutron/tests/unit/mlnx/test_rpcapi.py b/neutron/tests/unit/mlnx/test_rpcapi.py index b094ffb16..a31e9478d 100644 --- a/neutron/tests/unit/mlnx/test_rpcapi.py +++ b/neutron/tests/unit/mlnx/test_rpcapi.py @@ -33,7 +33,9 @@ class rpcApiTestCase(base.BaseTestCase): expected_msg=None, **kwargs): ctxt = context.RequestContext('fake_user', 'fake_project') expected_retval = 'foo' if method == 'call' else None - expected_kwargs = {'topic': topic} + expected_kwargs = {} + if topic: + expected_kwargs['topic'] = topic if 'version' in kwargs: expected_kwargs['version'] = kwargs.pop('version') if not expected_msg: @@ -133,7 +135,7 @@ class rpcApiTestCase(base.BaseTestCase): def test_device_details(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) - self._test_mlnx_api(rpcapi, topics.PLUGIN, + self._test_mlnx_api(rpcapi, None, 'get_device_details', rpc_method='call', device='fake_device', agent_id='fake_agent_id', @@ -141,7 +143,7 @@ class rpcApiTestCase(base.BaseTestCase): def test_devices_details_list(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) - self._test_mlnx_api(rpcapi, topics.PLUGIN, + self._test_mlnx_api(rpcapi, None, 'get_devices_details_list', rpc_method='call', devices=['fake_device1', 'fake_device1'], agent_id='fake_agent_id', host='fake_host', @@ -149,7 +151,7 @@ class rpcApiTestCase(base.BaseTestCase): def test_update_device_down(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) - self._test_mlnx_api(rpcapi, topics.PLUGIN, + self._test_mlnx_api(rpcapi, None, 'update_device_down', rpc_method='call', device='fake_device', agent_id='fake_agent_id', @@ -157,7 +159,7 @@ class rpcApiTestCase(base.BaseTestCase): def test_update_device_up(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) - self._test_mlnx_api(rpcapi, topics.PLUGIN, + self._test_mlnx_api(rpcapi, None, 'update_device_up', rpc_method='call', device='fake_device', agent_id='fake_agent_id', diff --git a/neutron/tests/unit/openvswitch/test_ovs_rpcapi.py b/neutron/tests/unit/openvswitch/test_ovs_rpcapi.py index 9d61dd375..c443d6cd9 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_rpcapi.py +++ b/neutron/tests/unit/openvswitch/test_ovs_rpcapi.py @@ -31,7 +31,9 @@ class rpcApiTestCase(base.BaseTestCase): def _test_ovs_api(self, rpcapi, topic, method, rpc_method, **kwargs): ctxt = context.RequestContext('fake_user', 'fake_project') expected_retval = 'foo' if method == 'call' else None - expected_kwargs = {'topic': topic} + expected_kwargs = {} + if topic: + expected_kwargs['topic'] = topic if 'version' in kwargs: expected_kwargs['version'] = kwargs.pop('version') expected_msg = rpcapi.make_msg(method, **kwargs) @@ -94,7 +96,7 @@ class rpcApiTestCase(base.BaseTestCase): def test_device_details(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) - self._test_ovs_api(rpcapi, topics.PLUGIN, + self._test_ovs_api(rpcapi, None, 'get_device_details', rpc_method='call', device='fake_device', agent_id='fake_agent_id', @@ -102,7 +104,7 @@ class rpcApiTestCase(base.BaseTestCase): def test_devices_details_list(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) - self._test_ovs_api(rpcapi, topics.PLUGIN, + self._test_ovs_api(rpcapi, None, 'get_devices_details_list', rpc_method='call', devices=['fake_device1', 'fake_device2'], agent_id='fake_agent_id', host='fake_host', @@ -110,7 +112,7 @@ class rpcApiTestCase(base.BaseTestCase): def test_update_device_down(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) - self._test_ovs_api(rpcapi, topics.PLUGIN, + self._test_ovs_api(rpcapi, None, 'update_device_down', rpc_method='call', device='fake_device', agent_id='fake_agent_id', @@ -118,14 +120,14 @@ class rpcApiTestCase(base.BaseTestCase): def test_tunnel_sync(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) - self._test_ovs_api(rpcapi, topics.PLUGIN, + self._test_ovs_api(rpcapi, None, 'tunnel_sync', rpc_method='call', tunnel_ip='fake_tunnel_ip', tunnel_type=None) def test_update_device_up(self): rpcapi = agent_rpc.PluginApi(topics.PLUGIN) - self._test_ovs_api(rpcapi, topics.PLUGIN, + self._test_ovs_api(rpcapi, None, 'update_device_up', rpc_method='call', device='fake_device', agent_id='fake_agent_id', diff --git a/neutron/tests/unit/ryu/test_ryu_agent.py b/neutron/tests/unit/ryu/test_ryu_agent.py index 756b39d04..b1609fc59 100644 --- a/neutron/tests/unit/ryu/test_ryu_agent.py +++ b/neutron/tests/unit/ryu/test_ryu_agent.py @@ -240,7 +240,7 @@ class TestRyuPluginApi(RyuAgentTestCase): mock.call('get_ofp_rest_api') ]) mock_call.assert_has_calls([ - mock.call('context', 'msg', topic='topics') + mock.call('context', 'msg') ]) diff --git a/neutron/tests/unit/services/firewall/agents/test_firewall_agent_api.py b/neutron/tests/unit/services/firewall/agents/test_firewall_agent_api.py index 188d3c293..d0525a65a 100644 --- a/neutron/tests/unit/services/firewall/agents/test_firewall_agent_api.py +++ b/neutron/tests/unit/services/firewall/agents/test_firewall_agent_api.py @@ -77,8 +77,7 @@ class TestFWaaSAgentApi(base.BaseTestCase): mock_call.assert_called_once_with( mock.sentinel.context, - mock_make_msg.return_value, - topic='topic') + mock_make_msg.return_value) def test_firewall_deleted(self): with contextlib.nested( @@ -99,5 +98,4 @@ class TestFWaaSAgentApi(base.BaseTestCase): mock_call.assert_called_once_with( mock.sentinel.context, - mock_make_msg.return_value, - topic='topic') + mock_make_msg.return_value) diff --git a/neutron/tests/unit/services/firewall/test_fwaas_plugin.py b/neutron/tests/unit/services/firewall/test_fwaas_plugin.py index de05d0caa..59bb42b99 100644 --- a/neutron/tests/unit/services/firewall/test_fwaas_plugin.py +++ b/neutron/tests/unit/services/firewall/test_fwaas_plugin.py @@ -184,8 +184,7 @@ class TestFirewallAgentApi(base.BaseTestCase): self.assertEqual(rv, self.mock_fanoutcast.return_value) self.mock_fanoutcast.assert_called_once_with( mock.sentinel.context, - self.mock_msg.return_value, - topic='topic' + self.mock_msg.return_value ) self.mock_msg.assert_called_once_with( diff --git a/neutron/tests/unit/services/loadbalancer/agent/test_api.py b/neutron/tests/unit/services/loadbalancer/agent/test_api.py index 211fce3a6..988ed1f80 100644 --- a/neutron/tests/unit/services/loadbalancer/agent/test_api.py +++ b/neutron/tests/unit/services/loadbalancer/agent/test_api.py @@ -41,8 +41,7 @@ class TestApiCache(base.BaseTestCase): self.make_msg.assert_called_once_with('get_ready_devices', host='host') self.mock_call.assert_called_once_with( mock.sentinel.context, - self.make_msg.return_value, - topic='topic' + self.make_msg.return_value ) def test_get_logical_device(self): @@ -57,8 +56,7 @@ class TestApiCache(base.BaseTestCase): self.mock_call.assert_called_once_with( mock.sentinel.context, - self.make_msg.return_value, - topic='topic' + self.make_msg.return_value ) def test_pool_destroyed(self): @@ -73,8 +71,7 @@ class TestApiCache(base.BaseTestCase): self.mock_call.assert_called_once_with( mock.sentinel.context, - self.make_msg.return_value, - topic='topic' + self.make_msg.return_value ) def test_pool_deployed(self): @@ -89,8 +86,7 @@ class TestApiCache(base.BaseTestCase): self.mock_call.assert_called_once_with( mock.sentinel.context, - self.make_msg.return_value, - topic='topic' + self.make_msg.return_value ) def test_update_status(self): @@ -108,7 +104,6 @@ class TestApiCache(base.BaseTestCase): self.mock_call.assert_called_once_with( mock.sentinel.context, self.make_msg.return_value, - topic='topic' ) def test_plug_vip_port(self): @@ -124,8 +119,7 @@ class TestApiCache(base.BaseTestCase): self.mock_call.assert_called_once_with( mock.sentinel.context, - self.make_msg.return_value, - topic='topic' + self.make_msg.return_value ) def test_unplug_vip_port(self): @@ -141,8 +135,7 @@ class TestApiCache(base.BaseTestCase): self.mock_call.assert_called_once_with( mock.sentinel.context, - self.make_msg.return_value, - topic='topic' + self.make_msg.return_value ) def test_update_pool_stats(self): @@ -159,6 +152,5 @@ class TestApiCache(base.BaseTestCase): self.mock_call.assert_called_once_with( mock.sentinel.context, - self.make_msg.return_value, - topic='topic' + self.make_msg.return_value ) diff --git a/neutron/tests/unit/services/metering/test_metering_plugin.py b/neutron/tests/unit/services/metering/test_metering_plugin.py index c97559d8d..3fbc20fb1 100644 --- a/neutron/tests/unit/services/metering/test_metering_plugin.py +++ b/neutron/tests/unit/services/metering/test_metering_plugin.py @@ -118,8 +118,7 @@ class TestMeteringPlugin(test_db_plugin.NeutronDbPluginV2TestCase, set_context=True): with self.metering_label(tenant_id=self.tenant_id, set_context=True): - self.mock_fanout.assert_called_with(self.ctx, expected, - topic=self.topic) + self.mock_fanout.assert_called_with(self.ctx, expected) def test_remove_metering_label_rpc_call(self): expected = {'args': @@ -138,11 +137,9 @@ class TestMeteringPlugin(test_db_plugin.NeutronDbPluginV2TestCase, with self.router(tenant_id=self.tenant_id, set_context=True): with self.metering_label(tenant_id=self.tenant_id, set_context=True): - self.mock_fanout.assert_called_with(self.ctx, expected, - topic=self.topic) + self.mock_fanout.assert_called_with(self.ctx, expected) expected['method'] = 'remove_metering_label' - self.mock_fanout.assert_called_with(self.ctx, expected, - topic=self.topic) + self.mock_fanout.assert_called_with(self.ctx, expected) def test_remove_one_metering_label_rpc_call(self): second_uuid = 'e27fe2df-376e-4ac7-ae13-92f050a21f84' @@ -179,10 +176,8 @@ class TestMeteringPlugin(test_db_plugin.NeutronDbPluginV2TestCase, self.mock_uuid.return_value = second_uuid with self.metering_label(tenant_id=self.tenant_id, set_context=True): - self.mock_fanout.assert_called_with(self.ctx, expected_add, - topic=self.topic) - self.mock_fanout.assert_called_with(self.ctx, expected_remove, - topic=self.topic) + self.mock_fanout.assert_called_with(self.ctx, expected_add) + self.mock_fanout.assert_called_with(self.ctx, expected_remove) def test_update_metering_label_rules_rpc_call(self): second_uuid = 'e27fe2df-376e-4ac7-ae13-92f050a21f84' @@ -237,11 +232,9 @@ class TestMeteringPlugin(test_db_plugin.NeutronDbPluginV2TestCase, self.mock_uuid.return_value = second_uuid with self.metering_label_rule(l['id'], direction='egress'): self.mock_fanout.assert_called_with(self.ctx, - expected_add, - topic=self.topic) + expected_add) self.mock_fanout.assert_called_with(self.ctx, - expected_del, - topic=self.topic) + expected_del) def test_delete_metering_label_does_not_clear_router_tenant_id(self): tenant_id = '654f6b9d-0f36-4ae5-bd1b-01616794ca60' diff --git a/neutron/tests/unit/test_agent_rpc.py b/neutron/tests/unit/test_agent_rpc.py index a182b49bd..c0f7e0ddd 100644 --- a/neutron/tests/unit/test_agent_rpc.py +++ b/neutron/tests/unit/test_agent_rpc.py @@ -76,7 +76,6 @@ class AgentPluginReportState(base.BaseTestCase): {'agent_state': expected_agent_state}) self.assertIsInstance(call.call_args[0][1]['args']['time'], str) - self.assertEqual(call.call_args[1]['topic'], topic) def test_plugin_report_state_cast(self): topic = 'test' @@ -92,7 +91,6 @@ class AgentPluginReportState(base.BaseTestCase): {'agent_state': expected_agent_state}) self.assertIsInstance(cast.call_args[0][1]['args']['time'], str) - self.assertEqual(cast.call_args[1]['topic'], topic) class AgentRPCMethods(base.BaseTestCase): diff --git a/neutron/tests/unit/test_security_groups_rpc.py b/neutron/tests/unit/test_security_groups_rpc.py index 158334856..52e66a258 100644 --- a/neutron/tests/unit/test_security_groups_rpc.py +++ b/neutron/tests/unit/test_security_groups_rpc.py @@ -1184,8 +1184,7 @@ class SecurityGroupServerRpcApiTestCase(base.BaseTestCase): {'devices': ['fake_device']}, 'method': 'security_group_rules_for_devices', 'namespace': None}, - version=sg_rpc.SG_RPC_VERSION, - topic='fake_topic')]) + version=sg_rpc.SG_RPC_VERSION)]) class FakeSGNotifierAPI(n_rpc.RpcProxy, -- 2.45.2