]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
DVR: Rename dvr_vmarp_table_update
authorSwaminathan Vasudevan <swaminathan.vasudevan@hp.com>
Sat, 5 Dec 2015 01:06:01 +0000 (17:06 -0800)
committerSwaminathan Vasudevan <swaminathan.vasudevan@hp.com>
Fri, 8 Jan 2016 17:53:23 +0000 (17:53 +0000)
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

neutron/db/l3_dvr_db.py
neutron/db/l3_dvrscheduler_db.py
neutron/tests/unit/db/test_l3_dvr_db.py
neutron/tests/unit/scheduler/test_l3_agent_scheduler.py

index e4085778adacd77995c3a786d8a723140d194508..e77d665f0d47dd62a91abbdbedf115e625df24fa 100644 (file)
@@ -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
index f921bd3ec837e19ea19d5be06cd6d3202ba6d051..fdce6b0b8b2f1903a898b1b1f2f8b9338a88b43a 100644 (file)
@@ -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():
index e752ca90fb9f99ef95991d47c7288c402985034e..6954f8e703d8f5d45be1caeb94561fa4a597e318 100644 (file)
@@ -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,
index 7d451a7a713cc2546a5d9842b6657844ae6b8c36..d4057ec5911cbf85c45ce7424ade20ab5c458edb 100644 (file)
@@ -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')