]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Deletes floating agent gw port on disassociate
authorSwaminathan Vasudevan <swaminathan.vasudevan@hp.com>
Tue, 25 Nov 2014 23:47:59 +0000 (15:47 -0800)
committerSwaminathan Vasudevan <swaminathan.vasudevan@hp.com>
Mon, 5 Jan 2015 21:37:59 +0000 (13:37 -0800)
This patch deletes the floating agent gw port
on floatingip disassociate.

A recent change in the neutron trunk broke
this functionality. This was introduced by
the patch that addressed the re-order
operations in (l3_dvr) update floating ip.

The current patch fixes the problem.

Change-Id: I98e766cf4ed33412d9d5dae07217553acbb5009c
Closes-Bug: #1394026

neutron/db/l3_dvr_db.py
neutron/tests/unit/db/test_l3_dvr_db.py

index d3974db8f780bf6fa0a829a0373d1c1f684493fa..9189610434826c3789b365a20134d0ee03122d13 100644 (file)
@@ -159,17 +159,17 @@ class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin,
             l3_db.RouterPort.port_type.in_(l3_const.ROUTER_INTERFACE_OWNERS)
         )
 
-    def update_floatingip(self, context, id, floatingip):
-        res_fip = super(L3_NAT_with_dvr_db_mixin, self).update_floatingip(
-            context, id, floatingip)
-        admin_ctx = context.elevated()
-        fip = floatingip['floatingip']
-        unused_agent_port = (fip.get('port_id', -1) is None and
-                            res_fip.get('fixed_port_id'))
-        if unused_agent_port:
+    def _update_fip_assoc(self, context, fip, floatingip_db, external_port):
+        """Override to delete the fip agent gw port on disassociate."""
+        fip_port = fip.get('port_id')
+        unused_fip_agent_gw_port = (
+            fip_port is None and floatingip_db['fixed_port_id'])
+        if unused_fip_agent_gw_port:
+            admin_ctx = context.elevated()
             self.clear_unused_fip_agent_gw_port(
-                admin_ctx, floatingip)
-        return res_fip
+                admin_ctx, floatingip_db)
+        super(L3_NAT_with_dvr_db_mixin, self)._update_fip_assoc(
+            context, fip, floatingip_db, external_port)
 
     def clear_unused_fip_agent_gw_port(
             self, context, floatingip_db):
index 68d48e3171ae39e9003e35cee8615638f3ff8914..404b552e3e73c6c799e70c77612f52f8c26b8e5c 100644 (file)
@@ -310,3 +310,22 @@ class L3DvrTestCase(testlib_api.SqlTestCase):
         self.assertIn(fip, router[l3_const.FLOATINGIP_KEY])
         self.assertIn('fip_interface',
             router[l3_const.FLOATINGIP_AGENT_INTF_KEY])
+
+    def test_delete_disassociated_floatingip_agent_port(self):
+        fip = {
+            'id': _uuid(),
+            'port_id': None
+        }
+        floatingip = {
+            'id': _uuid(),
+            'fixed_port_id': 1234,
+        }
+        with contextlib.nested(
+            mock.patch.object(self.mixin,
+                              'clear_unused_fip_agent_gw_port'),
+            mock.patch.object(l3_dvr_db.l3_db.L3_NAT_db_mixin,
+                              '_update_fip_assoc'),
+                 ) as (vf, cf):
+            self.mixin._update_fip_assoc(
+                self.ctx, fip, floatingip, mock.ANY)
+            self.assertTrue(vf.called)