Rename method to better reflect what it does
Just noticed confusing method and local var names while reviewing code. TrivialFix Change-Id: I31f9734e06952293273506a457e95f16d043b962
This commit is contained in:
parent
19a069d99f
commit
42f7942d86
|
@ -495,7 +495,7 @@ class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin,
|
|||
routers_dict = {}
|
||||
snat_intfs_by_router_id = self._get_snat_sync_interfaces(
|
||||
context, [r['id'] for r in routers])
|
||||
fip_sync_interfaces = None
|
||||
fip_agent_gw_ports = None
|
||||
LOG.debug("FIP Agent: %s ", agent.id)
|
||||
for router in routers:
|
||||
routers_dict[router['id']] = router
|
||||
|
@ -503,12 +503,12 @@ class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin,
|
|||
snat_router_intfs = snat_intfs_by_router_id[router['id']]
|
||||
LOG.debug("SNAT ports returned: %s ", snat_router_intfs)
|
||||
router[l3_const.SNAT_ROUTER_INTF_KEY] = snat_router_intfs
|
||||
if not fip_sync_interfaces:
|
||||
fip_sync_interfaces = self._get_fip_sync_interfaces(
|
||||
if not fip_agent_gw_ports:
|
||||
fip_agent_gw_ports = self._get_fip_agent_gw_ports(
|
||||
context, agent.id)
|
||||
LOG.debug("FIP Agent ports: %s", fip_sync_interfaces)
|
||||
LOG.debug("FIP Agent ports: %s", fip_agent_gw_ports)
|
||||
router[l3_const.FLOATINGIP_AGENT_INTF_KEY] = (
|
||||
fip_sync_interfaces)
|
||||
fip_agent_gw_ports)
|
||||
|
||||
return routers_dict
|
||||
|
||||
|
@ -526,15 +526,15 @@ class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin,
|
|||
router_floatingips.append(floating_ip)
|
||||
router[const.FLOATINGIP_KEY] = router_floatingips
|
||||
|
||||
def _get_fip_sync_interfaces(self, context, fip_agent_id):
|
||||
"""Query router interfaces that relate to list of router_ids."""
|
||||
def _get_fip_agent_gw_ports(self, context, fip_agent_id):
|
||||
"""Return list of floating agent gateway ports for the agent."""
|
||||
if not fip_agent_id:
|
||||
return []
|
||||
filters = {'device_id': [fip_agent_id],
|
||||
'device_owner': [const.DEVICE_OWNER_AGENT_GW]}
|
||||
interfaces = self._core_plugin.get_ports(context.elevated(), filters)
|
||||
LOG.debug("Return the FIP ports: %s ", interfaces)
|
||||
return interfaces
|
||||
ports = self._core_plugin.get_ports(context.elevated(), filters)
|
||||
LOG.debug("Return the FIP ports: %s ", ports)
|
||||
return ports
|
||||
|
||||
@log_helper.log_method_call
|
||||
def _get_dvr_sync_data(self, context, host, agent, router_ids=None,
|
||||
|
|
|
@ -169,18 +169,18 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
|||
self.l3_plugin._get_agent_gw_ports_exist_for_network(
|
||||
self.context, network_id, "", self.l3_agent['id']))
|
||||
|
||||
def test_get_fip_sync_interfaces(self):
|
||||
def test_get_fip_agent_gw_ports(self):
|
||||
self.setup_create_agent_gw_port_for_network()
|
||||
|
||||
self.assertEqual(
|
||||
1, len(self.l3_plugin._get_fip_sync_interfaces(
|
||||
1, len(self.l3_plugin._get_fip_agent_gw_ports(
|
||||
self.context, self.l3_agent['id'])))
|
||||
|
||||
def test_process_routers(self):
|
||||
router = self._create_router()
|
||||
if not router.get('gw_port_id'):
|
||||
router['gw_port_id'] = 'fake_gw_id'
|
||||
self.l3_plugin._get_fip_sync_interfaces = mock.Mock(
|
||||
self.l3_plugin._get_fip_agent_gw_ports = mock.Mock(
|
||||
return_value='fip_interface')
|
||||
self.l3_plugin._get_snat_sync_interfaces = mock.Mock(
|
||||
return_value={router['id']: 'snat_interface'})
|
||||
|
@ -190,7 +190,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
|||
self.assertEqual(
|
||||
router['id'], result[router['id']]['id'])
|
||||
self.assertIn(n_const.FLOATINGIP_AGENT_INTF_KEY, result[router['id']])
|
||||
self.l3_plugin._get_fip_sync_interfaces.assert_called_once_with(
|
||||
self.l3_plugin._get_fip_agent_gw_ports.assert_called_once_with(
|
||||
self.context, self.l3_agent['id'])
|
||||
self.l3_plugin._get_snat_sync_interfaces.assert_called_once_with(
|
||||
self.context, [router['id']])
|
||||
|
|
|
@ -378,7 +378,7 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
return_value=hostid)
|
||||
self.mixin._get_agent_by_type_and_host = mock.Mock(
|
||||
return_value=fipagent)
|
||||
self.mixin._get_fip_sync_interfaces = mock.Mock(
|
||||
self.mixin._get_fip_agent_gw_ports = mock.Mock(
|
||||
return_value='fip_interface')
|
||||
self.mixin._process_floating_ips_dvr(self.ctx, routers, [floatingip],
|
||||
hostid)
|
||||
|
|
Loading…
Reference in New Issue