From: Swaminathan Vasudevan Date: Sat, 5 Dec 2015 01:06:01 +0000 (-0800) Subject: DVR: Rename dvr_vmarp_table_update X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=6960cc133c9ebac3ca356a2058230674562d5615;p=openstack-build%2Fneutron-build.git DVR: Rename dvr_vmarp_table_update This dvr_vmarp_table_update is not only used to update the arp entry for the VM ports, but also for other DVR service ports. So the function name is kind of misleading and hence changing it to an appropriate name that fits its function. Change-Id: I6d5b0b717dcff964a514c83b0cd60b044411f0db --- diff --git a/neutron/db/l3_dvr_db.py b/neutron/db/l3_dvr_db.py index e4085778a..e77d665f0 100644 --- a/neutron/db/l3_dvr_db.py +++ b/neutron/db/l3_dvr_db.py @@ -685,12 +685,13 @@ class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin, self._populate_subnets_for_ports(context, port_list) return port_list - def dvr_vmarp_table_update(self, context, port_dict, action): - """Notify L3 agents of VM ARP table changes. + def update_arp_entry_for_dvr_service_port( + self, context, port_dict, action): + """Notify L3 agents of ARP table entry for dvr service port. - When a VM goes up or down, look for one DVR router on the port's - subnet, and send the VM's ARP details to all L3 agents hosting the - router. + When a dvr service port goes up or down, look for the DVR + router on the port's subnet, and send the ARP details to all + L3 agents hosting the router. """ # Check this is a valid VM or service port diff --git a/neutron/db/l3_dvrscheduler_db.py b/neutron/db/l3_dvrscheduler_db.py index f921bd3ec..fdce6b0b8 100644 --- a/neutron/db/l3_dvrscheduler_db.py +++ b/neutron/db/l3_dvrscheduler_db.py @@ -473,7 +473,7 @@ def _notify_l3_agent_new_port(resource, event, trigger, **kwargs): service_constants.L3_ROUTER_NAT) context = kwargs['context'] l3plugin.dvr_handle_new_service_port(context, port) - l3plugin.dvr_vmarp_table_update(context, port, "add") + l3plugin.update_arp_entry_for_dvr_service_port(context, port, "add") def _notify_port_delete(event, resource, trigger, **kwargs): @@ -482,7 +482,7 @@ def _notify_port_delete(event, resource, trigger, **kwargs): removed_routers = kwargs['removed_routers'] l3plugin = manager.NeutronManager.get_service_plugins().get( service_constants.L3_ROUTER_NAT) - l3plugin.dvr_vmarp_table_update(context, port, "del") + l3plugin.update_arp_entry_for_dvr_service_port(context, port, "del") for router in removed_routers: l3plugin.remove_router_from_l3_agent( context, router['agent_id'], router['router_id']) @@ -527,9 +527,11 @@ def _notify_l3_agent_port_update(resource, event, trigger, **kwargs): if (is_new_port_binding_changed and n_utils.is_dvr_serviced(new_device_owner)): l3plugin.dvr_handle_new_service_port(context, new_port) - l3plugin.dvr_vmarp_table_update(context, new_port, "add") + l3plugin.update_arp_entry_for_dvr_service_port( + context, new_port, "add") elif kwargs.get('mac_address_updated'): - l3plugin.dvr_vmarp_table_update(context, new_port, "add") + l3plugin.update_arp_entry_for_dvr_service_port( + context, new_port, "add") def subscribe(): diff --git a/neutron/tests/unit/db/test_l3_dvr_db.py b/neutron/tests/unit/db/test_l3_dvr_db.py index e752ca90f..6954f8e70 100644 --- a/neutron/tests/unit/db/test_l3_dvr_db.py +++ b/neutron/tests/unit/db/test_l3_dvr_db.py @@ -581,7 +581,8 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase): mock_notify.assert_called_once_with( 'router', 'before_update', self.mixin, **kwargs) - def _test_dvr_vmarp_table_update(self, device_owner, action): + def _test_update_arp_entry_for_dvr_service_port( + self, device_owner, action): with mock.patch.object(manager.NeutronManager, 'get_plugin') as gp,\ mock.patch.object(self.mixin, '_get_router') as grtr: plugin = mock.Mock() @@ -606,21 +607,22 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase): plugin.get_ports.return_value = [port, dvr_port] grtr.return_value = dvr_router dvr_router.extra_attributes.distributed = True - self.mixin.dvr_vmarp_table_update(self.ctx, port, action) + self.mixin.update_arp_entry_for_dvr_service_port( + self.ctx, port, action) if action == 'add': self.assertTrue(l3_notify.add_arp_entry.called) elif action == 'del': self.assertTrue(l3_notify.del_arp_entry.called) - def test_dvr_vmarp_table_update_with_service_port_added(self): + def test_update_arp_entry_for_dvr_service_port_added(self): action = 'add' device_owner = l3_const.DEVICE_OWNER_LOADBALANCER - self._test_dvr_vmarp_table_update(device_owner, action) + self._test_update_arp_entry_for_dvr_service_port(device_owner, action) - def test_dvr_vmarp_table_update_with_service_port_deleted(self): + def test_update_arp_entry_for_dvr_service_port_deleted(self): action = 'del' device_owner = l3_const.DEVICE_OWNER_LOADBALANCER - self._test_dvr_vmarp_table_update(device_owner, action) + self._test_update_arp_entry_for_dvr_service_port(device_owner, action) def test_add_router_interface_csnat_ports_failure(self): router_dict = {'name': 'test_router', 'admin_state_up': True, diff --git a/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py b/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py index 7d451a7a7..d4057ec59 100644 --- a/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py +++ b/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py @@ -970,7 +970,8 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase): return_value={'L3_ROUTER_NAT': l3plugin}): l3_dvrscheduler_db._notify_l3_agent_port_update( 'port', 'after_update', plugin, **kwargs) - self.assertFalse(l3plugin.dvr_vmarp_table_update.called) + self.assertFalse( + l3plugin.update_arp_entry_for_dvr_service_port.called) self.assertFalse( l3plugin.dvr_handle_new_service_port.called) self.assertFalse(l3plugin.remove_router_from_l3_agent.called) @@ -990,8 +991,9 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase): return_value={'L3_ROUTER_NAT': l3plugin}): l3_dvrscheduler_db._notify_l3_agent_new_port( 'port', 'after_create', mock.ANY, **kwargs) - l3plugin.dvr_vmarp_table_update.assert_called_once_with( - self.adminContext, kwargs.get('port'), 'add') + l3plugin.update_arp_entry_for_dvr_service_port.\ + assert_called_once_with( + self.adminContext, kwargs.get('port'), 'add') l3plugin.dvr_handle_new_service_port.assert_called_once_with( self.adminContext, kwargs.get('port')) @@ -1009,7 +1011,8 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase): return_value={'L3_ROUTER_NAT': l3plugin}): l3_dvrscheduler_db._notify_l3_agent_new_port( 'port', 'after_create', mock.ANY, **kwargs) - self.assertFalse(l3plugin.dvr_vmarp_table_update.called) + self.assertFalse( + l3plugin.update_arp_entry_for_dvr_service_port.called) self.assertFalse( l3plugin.dvr_handle_new_service_port.called) @@ -1032,7 +1035,8 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase): l3_dvrscheduler_db._notify_l3_agent_port_update( 'port', 'after_update', mock.ANY, **kwargs) - self.assertFalse(l3plugin.dvr_vmarp_table_update.called) + self.assertFalse( + l3plugin.update_arp_entry_for_dvr_service_port.called) self.assertFalse( l3plugin.dvr_handle_new_service_port.called) self.assertFalse(l3plugin.remove_router_from_l3_agent.called) @@ -1058,8 +1062,9 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase): l3_dvrscheduler_db._notify_l3_agent_port_update( 'port', 'after_update', mock.ANY, **kwargs) - l3plugin.dvr_vmarp_table_update.assert_called_once_with( - self.adminContext, kwargs.get('port'), 'add') + l3plugin.update_arp_entry_for_dvr_service_port.\ + assert_called_once_with( + self.adminContext, kwargs.get('port'), 'add') self.assertFalse(l3plugin.dvr_handle_new_service_port.called) def test__notify_l3_agent_update_port_with_port_binding_change(self): @@ -1086,7 +1091,8 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase): 'port', 'after_update', mock.ANY, **kwargs) l3plugin.remove_router_from_l3_agent.assert_called_once_with( self.adminContext, 'foo_agent', 'foo_id') - self.assertEqual(2, l3plugin.dvr_vmarp_table_update.call_count) + self.assertEqual( + 2, l3plugin.update_arp_entry_for_dvr_service_port.call_count) l3plugin.dvr_handle_new_service_port.assert_called_once_with( self.adminContext, kwargs.get('port')) @@ -1124,9 +1130,11 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase): l3_dvrscheduler_db._notify_l3_agent_port_update( 'port', 'after_update', plugin, **kwargs) - self.assertEqual(1, l3plugin.dvr_vmarp_table_update.call_count) - l3plugin.dvr_vmarp_table_update.assert_called_once_with( - self.adminContext, mock.ANY, 'del') + self.assertEqual( + 1, l3plugin.update_arp_entry_for_dvr_service_port.call_count) + l3plugin.update_arp_entry_for_dvr_service_port.\ + assert_called_once_with( + self.adminContext, mock.ANY, 'del') self.assertFalse( l3plugin.dvr_handle_new_service_port.called) @@ -1152,8 +1160,9 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase): } l3_dvrscheduler_db._notify_port_delete( 'port', 'after_delete', plugin, **kwargs) - l3plugin.dvr_vmarp_table_update.assert_called_once_with( - self.adminContext, mock.ANY, 'del') + l3plugin.update_arp_entry_for_dvr_service_port.\ + assert_called_once_with( + self.adminContext, mock.ANY, 'del') l3plugin.remove_router_from_l3_agent.assert_called_once_with( self.adminContext, 'foo_agent', 'foo_id')