libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [1/3] git commit: [LIBCLOUD-503] OpenStack public ip addresses fix
Date Tue, 11 Mar 2014 18:04:37 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 0619c9257 -> 8b3bb0f94


[LIBCLOUD-503] OpenStack public ip addresses fix

Closes #235

Signed-off-by: Tomaz Muraus <tomaz@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/859a0a4f
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/859a0a4f
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/859a0a4f

Branch: refs/heads/trunk
Commit: 859a0a4f769c32761944e35bea0efac88add8207
Parents: 0619c92
Author: Markos Gogoulos <mgogoulos@mist.io>
Authored: Fri Jan 31 13:53:43 2014 +0200
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Tue Mar 11 19:02:30 2014 +0100

----------------------------------------------------------------------
 libcloud/compute/drivers/openstack.py   | 11 ++++++++++-
 libcloud/test/compute/test_openstack.py | 12 ++++++++----
 2 files changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/859a0a4f/libcloud/compute/drivers/openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/openstack.py b/libcloud/compute/drivers/openstack.py
index aba37bc..c7d0b09 100644
--- a/libcloud/compute/drivers/openstack.py
+++ b/libcloud/compute/drivers/openstack.py
@@ -37,6 +37,7 @@ except ImportError:
 from libcloud.common.openstack import OpenStackBaseConnection
 from libcloud.common.openstack import OpenStackDriverMixin
 from libcloud.common.types import MalformedResponseError, ProviderError
+from libcloud.utils.networking import is_private_subnet
 from libcloud.compute.base import NodeSize, NodeImage
 from libcloud.compute.base import (NodeDriver, Node, NodeLocation,
                                    StorageVolume, VolumeSnapshot)
@@ -1987,7 +1988,15 @@ class OpenStack_1_1_NodeDriver(OpenStackNodeDriver):
             if label in public_networks_labels:
                 public_ips.extend(ips)
             else:
-                private_ips.extend(ips)
+                for ip in ips:
+                    #is_private_subnet does not check for ipv6
+                    try:
+                        if is_private_subnet(ip):
+                            private_ips.append(ip)
+                        else:
+                            public_ips.append(ip)
+                    except:
+                        private_ips.append(ip)
 
         # Sometimes 'image' attribute is not present if the node is in an error
         # state

http://git-wip-us.apache.org/repos/asf/libcloud/blob/859a0a4f/libcloud/test/compute/test_openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_openstack.py b/libcloud/test/compute/test_openstack.py
index 1bb6487..bdc6979 100644
--- a/libcloud/test/compute/test_openstack.py
+++ b/libcloud/test/compute/test_openstack.py
@@ -961,11 +961,15 @@ class OpenStack_1_1_Tests(unittest.TestCase, TestCaseMixin):
         node = nodes[0]
 
         self.assertEqual('12065', node.id)
-        self.assertEqual('50.57.94.35', node.public_ips[0])
-        self.assertEqual(
-            '2001:4801:7808:52:16:3eff:fe47:788a', node.public_ips[1])
+        #test public IPv4
+        self.assertTrue('12.16.18.28' in node.public_ips)
+        self.assertTrue('50.57.94.35' in node.public_ips)
+        #test public IPv6
+        self.assertTrue(
+            '2001:4801:7808:52:16:3eff:fe47:788a' in node.public_ips)
+        #test private IPv4
         self.assertTrue('10.182.64.34' in node.private_ips)
-        self.assertTrue('12.16.18.28' in node.private_ips)
+        #test private IPv6
         self.assertTrue(
             'fec0:4801:7808:52:16:3eff:fe60:187d' in node.private_ips)
 


Mime
View raw message