diff --git a/neutron/db/l3_dvr_db.py b/neutron/db/l3_dvr_db.py index 6e019cdbcf5..db76722be44 100644 --- a/neutron/db/l3_dvr_db.py +++ b/neutron/db/l3_dvr_db.py @@ -656,12 +656,13 @@ class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin, notifier(context, router_id, arp_table) return - 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 f030ad4e447..0fa27942f69 100644 --- a/neutron/db/l3_dvrscheduler_db.py +++ b/neutron/db/l3_dvrscheduler_db.py @@ -481,7 +481,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): @@ -490,7 +490,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: # we need admin context in case a tenant removes the last dvr # serviceable port on a shared network owned by admin, where router @@ -541,9 +541,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') or is_fixed_ips_changed: - 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 b8df0f8aea6..1d65c3511fb 100644 --- a/neutron/tests/unit/db/test_l3_dvr_db.py +++ b/neutron/tests/unit/db/test_l3_dvr_db.py @@ -542,7 +542,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() @@ -570,21 +571,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.assertEqual(3, l3_notify.add_arp_entry.call_count) elif action == 'del': self.assertTrue(3, l3_notify.del_arp_entry.call_count) - 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 d11ec70667a..3b83242280b 100644 --- a/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py +++ b/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py @@ -904,7 +904,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) @@ -924,8 +925,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')) @@ -943,7 +945,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) @@ -966,7 +969,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) @@ -992,8 +996,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): @@ -1020,7 +1025,8 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase): 'port', 'after_update', mock.ANY, **kwargs) l3plugin.remove_router_from_l3_agent.assert_called_once_with( mock.ANY, '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')) @@ -1058,9 +1064,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) @@ -1086,8 +1094,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( mock.ANY, 'foo_agent', 'foo_id')