Przeglądaj źródła

Merge pull request #256 from CloudVE/almahmoud-patch-2

OS floating IP fix
Enis Afgan 5 lat temu
rodzic
commit
9fdc473164

+ 1 - 1
cloudbridge/providers/openstack/resources.py

@@ -449,7 +449,7 @@ class OpenStackInstance(BaseInstance):
 
     def _get_fip(self, floating_ip):
         """Get a floating IP object based on the supplied ID."""
-        return self._provider.networking._floating_ips.get(floating_ip)
+        return self._provider.networking._floating_ips.get(None, floating_ip)
 
     def add_floating_ip(self, floating_ip):
         """

+ 19 - 0
tests/test_compute_service.py

@@ -395,3 +395,22 @@ class CloudComputeServiceTestCase(ProviderTestBase):
                     self.assertNotIn(
                         fip.public_ip,
                         test_inst.public_ips + test_inst.private_ips)
+
+                    with cb_helpers.cleanup_action(
+                            lambda: test_inst.remove_floating_ip(fip.id)):
+                        test_inst.add_floating_ip(fip.id)
+                        test_inst.refresh()
+                        # On Devstack, FloatingIP is listed under private_ips.
+                        self.assertIn(fip.public_ip, test_inst.public_ips +
+                                      test_inst.private_ips)
+                        fip.refresh()
+                        self.assertTrue(
+                            fip.in_use,
+                            "Attached floating IP %s address should be in use."
+                            % fip.public_ip)
+                    test_inst.refresh()
+                    test_inst.reboot()
+                    test_inst.wait_till_ready()
+                    self.assertNotIn(
+                        fip.public_ip,
+                        test_inst.public_ips + test_inst.private_ips)