]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix 500 error during router-update for dvr routers
authorarmando-migliaccio <armamig@gmail.com>
Tue, 5 Aug 2014 15:56:23 +0000 (08:56 -0700)
committerarmando-migliaccio <armamig@gmail.com>
Tue, 5 Aug 2014 15:56:37 +0000 (08:56 -0700)
This was caused because the l3 service plugin was
erroneously calling a method on self, whereas the
method is implemented by the core plugin.

Closes-bug: #1352786

Change-Id: I0746eee314730370b2df4bef6d9fd41680e2e3d1

neutron/db/l3_dvrscheduler_db.py
neutron/tests/unit/test_l3_schedulers.py

index 686be112f03be03b47179911f7683501a7aa424f..5f23cee959373df854661700488d635fb27df23b 100644 (file)
@@ -224,7 +224,7 @@ class L3_DVRsch_db_mixin(l3agent_sch_db.L3AgentSchedulerDbMixin):
             subnet_ids = self.get_subnet_ids_on_router(context, router_id)
             for subnet in subnet_ids:
                 vm_ports = (
-                    self.get_compute_ports_on_host_by_subnet(
+                    self._core_plugin.get_compute_ports_on_host_by_subnet(
                         context, host, subnet))
                 if vm_ports:
                     LOG.debug('VM exists on the snat enabled l3_agent '
index 7dda7fd701217b4e86eef0f980a491ae8231ac39..ae9fe0f124610f901e9fa74c3bb3209ec992d5eb 100644 (file)
@@ -501,3 +501,30 @@ class L3DvrSchedulerTestCase(base.BaseTestCase):
                 self.adminContext, 'foo_router_id', mock.ANY, True)
         mock_bind.assert_called_once_with(
             self.adminContext, 'foo_router_id', [agent])
+
+    def test_unbind_snat_servicenode(self):
+        router_id = 'foo_router_id'
+        core_plugin = mock.PropertyMock()
+        type(self.dut)._core_plugin = core_plugin
+        (self.dut._core_plugin.get_compute_ports_on_host_by_subnet.
+         return_value) = []
+        core_plugin.reset_mock()
+        l3_notifier = mock.PropertyMock()
+        type(self.dut).l3_rpc_notifier = l3_notifier
+        binding = l3_dvrscheduler_db.CentralizedSnatL3AgentBinding(
+            router_id=router_id, l3_agent_id='foo_l3_agent_id',
+            l3_agent=agents_db.Agent())
+        with contextlib.nested(
+            mock.patch.object(query.Query, 'one'),
+            mock.patch.object(self.adminContext.session, 'delete'),
+            mock.patch.object(query.Query, 'delete'),
+            mock.patch.object(self.dut, 'get_subnet_ids_on_router')) as (
+                mock_query, mock_session, mock_delete, mock_get_subnets):
+            mock_query.return_value = binding
+            mock_get_subnets.return_value = ['foo_subnet_id']
+            self.dut.unbind_snat_servicenode(self.adminContext, router_id)
+        mock_get_subnets.assert_called_with(self.adminContext, router_id)
+        self.assertTrue(mock_session.call_count)
+        self.assertTrue(mock_delete.call_count)
+        core_plugin.assert_called_once_with()
+        l3_notifier.assert_called_once_with()