]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
NSX: Avoid floating IP status reset
authorSalvatore Orlando <salv.orlando@gmail.com>
Fri, 15 Aug 2014 11:20:26 +0000 (04:20 -0700)
committerSalvatore Orlando <salv.orlando@gmail.com>
Fri, 15 Aug 2014 14:56:03 +0000 (07:56 -0700)
The method for setting the floating IP status in the NSX plugin
has a flaw that causes in some cases the status to be reset.
This patch removes this bug and also protects against regression
adding status check in the unit test covering floating ip
creation.

This patch also moves the above mentioned unit test in a more
suitable place in the test same module.

Change-Id: Ib08c421ade20ce23b5c08145203a2df6a8f3efa5
Closes-Bug: #1357514

neutron/plugins/vmware/plugins/base.py
neutron/tests/unit/test_l3_plugin.py

index 12a1fb81bfb215e7fa7c45f0e2b3ef79e461a11d..2c97b140755eb56751c2b3c09c14e9f1f250ae6c 100644 (file)
@@ -1837,6 +1837,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
         elif (not associated and
               floatingip_db['status'] != constants.FLOATINGIP_STATUS_DOWN):
             return constants.FLOATINGIP_STATUS_DOWN
+        # in any case ensure the status is not reset by this method!
+        return floatingip_db['status']
 
     def _update_fip_assoc(self, context, fip, floatingip_db, external_port):
         """Update floating IP association data.
index f1bc02b7e71eaa9151750bb47ada6d55d6b9358b..0b7ad7c69c6444e9d1a2568bebd6d20adfceb332 100644 (file)
@@ -1335,6 +1335,18 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
         self._test_floatingip_with_assoc_fails(
             'neutron.db.l3_db.L3_NAT_db_mixin._check_and_get_fip_assoc')
 
+    def test_create_floatingip_with_assoc(
+        self, expected_status=l3_constants.FLOATINGIP_STATUS_ACTIVE):
+        with self.floatingip_with_assoc() as fip:
+            body = self._show('floatingips', fip['floatingip']['id'])
+            self.assertEqual(body['floatingip']['id'],
+                             fip['floatingip']['id'])
+            self.assertEqual(body['floatingip']['port_id'],
+                             fip['floatingip']['port_id'])
+            self.assertEqual(expected_status, body['floatingip']['status'])
+            self.assertIsNotNone(body['floatingip']['fixed_ip_address'])
+            self.assertIsNotNone(body['floatingip']['router_id'])
+
     def test_floatingip_update(
         self, expected_status=l3_constants.FLOATINGIP_STATUS_ACTIVE):
         with self.port() as p:
@@ -1508,16 +1520,6 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
                         fip2_r2_res = associate_and_assert(fip2, p2)
                         self.assertEqual(fip2_r2_res, r2['router']['id'])
 
-    def test_floatingip_with_assoc(self):
-        with self.floatingip_with_assoc() as fip:
-            body = self._show('floatingips', fip['floatingip']['id'])
-            self.assertEqual(body['floatingip']['id'],
-                             fip['floatingip']['id'])
-            self.assertEqual(body['floatingip']['port_id'],
-                             fip['floatingip']['port_id'])
-            self.assertIsNotNone(body['floatingip']['fixed_ip_address'])
-            self.assertIsNotNone(body['floatingip']['router_id'])
-
     def test_floatingip_port_delete(self):
         with self.subnet() as private_sub:
             with self.floatingip_no_assoc(private_sub) as fip: