You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2020/01/22 08:43:35 UTC

[libcloud] branch trunk updated: Fix #1411

This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git


The following commit(s) were added to refs/heads/trunk by this push:
     new f5b0631  Fix #1411
     new 807f53d  Merge pull request #1412 from micafer/trunk
f5b0631 is described below

commit f5b06310bac2f3fb83b78c90573bd1f984592ba1
Author: micafer <mi...@upv.es>
AuthorDate: Fri Jan 17 10:57:03 2020 +0100

    Fix #1411
---
 libcloud/compute/drivers/openstack.py              |  4 ++--
 .../openstack_v1.1/_v2_0__floatingips.json         | 28 ++++++++++++++++++++++
 libcloud/test/compute/test_openstack.py            |  5 ++++
 3 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/libcloud/compute/drivers/openstack.py b/libcloud/compute/drivers/openstack.py
index 07625ae..e250b91 100644
--- a/libcloud/compute/drivers/openstack.py
+++ b/libcloud/compute/drivers/openstack.py
@@ -3927,8 +3927,8 @@ class OpenStack_2_FloatingIpPool(object):
                                            port.extra["mac_address"]}
 
         if 'port_details' in obj and obj['port_details']:
-            if obj['port_details']['device_owner'] in ['compute:nova',
-                                                       'compute:None']:
+            dev_owner = obj['port_details']['device_owner']
+            if dev_owner and dev_owner.startswith("compute:"):
                 instance_id = obj['port_details']['device_id']
 
         ip_address = obj['floating_ip_address']
diff --git a/libcloud/test/compute/fixtures/openstack_v1.1/_v2_0__floatingips.json b/libcloud/test/compute/fixtures/openstack_v1.1/_v2_0__floatingips.json
index 05ca7d0..638625a 100644
--- a/libcloud/test/compute/fixtures/openstack_v1.1/_v2_0__floatingips.json
+++ b/libcloud/test/compute/fixtures/openstack_v1.1/_v2_0__floatingips.json
@@ -75,6 +75,34 @@
             },
             "tags": ["tag3"],
             "port_forwardings": []
+        },
+        {
+            "router_id": "d23abc8d-2991-4a55-ba98-2aaea84cc72f",
+            "description": "for test",
+            "dns_domain": "my-domain.org.",
+            "dns_name": "myfip",
+            "created_at": "2016-12-21T10:55:50Z",
+            "updated_at": "2016-12-21T10:55:53Z",
+            "revision_number": 1,
+            "project_id": "4969c491a3c74ee4af974e6d800c62de",
+            "tenant_id": "4969c491a3c74ee4af974e6d800c62de",
+            "floating_network_id": "376da547-b977-4cfe-9cba-275c80debf57",
+            "fixed_ip_address": "10.0.0.4",
+            "floating_ip_address": "10.3.1.3",
+            "port_id": "ce705c24-c1ef-408a-bda3-7bbd946164ab",
+            "id": "123c5336a-0629-4694-ba30-04b0bdfa88a4",
+            "status": "ACTIVE",
+            "port_details": {
+                "status": "ACTIVE",
+                "name": "",
+                "admin_state_up": true,
+                "network_id": "02dd8479-ef26-4398-a102-d19d0a7b3a1f",
+                "device_owner": "compute:region",
+                "mac_address": "fa:16:3e:b1:3b:30",
+                "device_id": "cb4fba64-19e2-40fd-8497-f29da1b21143"
+            },
+            "tags": ["tag3"],
+            "port_forwardings": []
         }
     ]
 }
\ No newline at end of file
diff --git a/libcloud/test/compute/test_openstack.py b/libcloud/test/compute/test_openstack.py
index be15b98..0fd510a 100644
--- a/libcloud/test/compute/test_openstack.py
+++ b/libcloud/test/compute/test_openstack.py
@@ -1442,6 +1442,11 @@ class OpenStack_1_1_Tests(unittest.TestCase, TestCaseMixin):
         self.assertEqual(ret[2].ip_address, '10.3.1.2')
         self.assertEqual(
             ret[2].node_id, 'cb4fba64-19e2-40fd-8497-f29da1b21143')
+        self.assertEqual(ret[3].id, '123c5336a-0629-4694-ba30-04b0bdfa88a4')
+        self.assertEqual(ret[3].pool, pool)
+        self.assertEqual(ret[3].ip_address, '10.3.1.3')
+        self.assertEqual(
+            ret[3].node_id, 'cb4fba64-19e2-40fd-8497-f29da1b21143')
 
     def test_OpenStack_2_FloatingIpPool_get_floating_ip(self):
         pool = OpenStack_2_FloatingIpPool(1, 'foo', self.driver.connection)