libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [1/2] libcloud git commit: LIBCLOUD-971 - wait_until_running should only append addresses if the list is not empty.
Date Fri, 29 Dec 2017 13:38:17 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk ac38dff52 -> a03877af9


LIBCLOUD-971 - wait_until_running should only append addresses if the list is not empty.

Closes #1156

Part of LIBCLOUD-971.

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


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

Branch: refs/heads/trunk
Commit: 5c35c9894a776052c60fca4a0f0263bf6be7daad
Parents: ac38dff
Author: Tobias Paepke <tobias.paepke@fhe3.com>
Authored: Wed Dec 20 14:04:19 2017 +0100
Committer: Tomaz Muraus <tomaz@tomaz.me>
Committed: Fri Dec 29 14:36:07 2017 +0100

----------------------------------------------------------------------
 libcloud/compute/base.py                        |  7 +++-
 .../v1_slug_servers_detail_deployment_ipv6.xml  | 14 +++++++
 .../v1_slug_servers_detail_deployment_no_ip.xml | 14 +++++++
 libcloud/test/compute/test_deployment.py        | 44 ++++++++++++++++++++
 4 files changed, 77 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/5c35c989/libcloud/compute/base.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/base.py b/libcloud/compute/base.py
index 891a042..7d04509 100644
--- a/libcloud/compute/base.py
+++ b/libcloud/compute/base.py
@@ -1345,8 +1345,11 @@ class NodeDriver(BaseDriver):
 
             running_nodes = [node for node in matching_nodes
                              if node.state == NodeState.RUNNING]
-            addresses = [filter_addresses(getattr(node, ssh_interface))
-                         for node in running_nodes]
+            addresses = []
+            for node in running_nodes:
+                node_addresses = filter_addresses(getattr(node, ssh_interface))
+                if len(node_addresses) >= 1:
+                    addresses.append(node_addresses)
 
             if len(running_nodes) == len(uuids) == len(addresses):
                 return list(zip(running_nodes, addresses))

http://git-wip-us.apache.org/repos/asf/libcloud/blob/5c35c989/libcloud/test/compute/fixtures/openstack/v1_slug_servers_detail_deployment_ipv6.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/openstack/v1_slug_servers_detail_deployment_ipv6.xml
b/libcloud/test/compute/fixtures/openstack/v1_slug_servers_detail_deployment_ipv6.xml
new file mode 100644
index 0000000..e75b846
--- /dev/null
+++ b/libcloud/test/compute/fixtures/openstack/v1_slug_servers_detail_deployment_ipv6.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<servers xmlns="http://docs.rackspacecloud.com/servers/api/v1.0">
+  <server status="ACTIVE" progress="100" hostId="9dd380940fcbe39cb30255ed4664f1f3" flavorId="1"
imageId="11" id="12345" name="racktest">
+    <metadata/>
+    <addresses>
+      <public>
+        <ip addr="2001:DB8::1"/>
+      </public>
+      <private>
+        <ip addr="2001:DB8:1::1"/>
+      </private>
+    </addresses>
+  </server>
+</servers>

http://git-wip-us.apache.org/repos/asf/libcloud/blob/5c35c989/libcloud/test/compute/fixtures/openstack/v1_slug_servers_detail_deployment_no_ip.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/openstack/v1_slug_servers_detail_deployment_no_ip.xml
b/libcloud/test/compute/fixtures/openstack/v1_slug_servers_detail_deployment_no_ip.xml
new file mode 100644
index 0000000..e75b846
--- /dev/null
+++ b/libcloud/test/compute/fixtures/openstack/v1_slug_servers_detail_deployment_no_ip.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<servers xmlns="http://docs.rackspacecloud.com/servers/api/v1.0">
+  <server status="ACTIVE" progress="100" hostId="9dd380940fcbe39cb30255ed4664f1f3" flavorId="1"
imageId="11" id="12345" name="racktest">
+    <metadata/>
+    <addresses>
+      <public>
+        <ip addr="2001:DB8::1"/>
+      </public>
+      <private>
+        <ip addr="2001:DB8:1::1"/>
+      </private>
+    </addresses>
+  </server>
+</servers>

http://git-wip-us.apache.org/repos/asf/libcloud/blob/5c35c989/libcloud/test/compute/test_deployment.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_deployment.py b/libcloud/test/compute/test_deployment.py
index b2bdab2..83d76f3 100644
--- a/libcloud/test/compute/test_deployment.py
+++ b/libcloud/test/compute/test_deployment.py
@@ -224,6 +224,40 @@ class DeploymentTests(unittest.TestCase):
         self.assertEqual(self.node.uuid, node2.uuid)
         self.assertEqual(['67.23.21.33'], ips)
 
+    def test_wait_until_running_without_ip(self):
+        RackspaceMockHttp.type = 'NO_IP'
+
+        try:
+            node2, ips = self.driver.wait_until_running(
+                nodes=[self.node], wait_period=1,
+                timeout=0.5)[0]
+        except LibcloudError:
+            e = sys.exc_info()[1]
+            self.assertTrue(e.value.find('Timed out after 0.5 second') != -1)
+        else:
+            self.fail('Exception was not thrown')
+
+    def test_wait_until_running_with_only_ipv6(self):
+        RackspaceMockHttp.type = 'IPV6'
+
+        try:
+            node2, ips = self.driver.wait_until_running(
+                nodes=[self.node], wait_period=1,
+                timeout=0.5)[0]
+        except LibcloudError:
+            e = sys.exc_info()[1]
+            self.assertTrue(e.value.find('Timed out after 0.5 second') != -1)
+        else:
+            self.fail('Exception was not thrown')
+
+    def test_wait_until_running_with_ipv6_ok(self):
+        RackspaceMockHttp.type = 'IPV6'
+        node2, ips = self.driver.wait_until_running(
+            nodes=[self.node], wait_period=1, force_ipv4=False,
+            timeout=0.5)[0]
+        self.assertEqual(self.node.uuid, node2.uuid)
+        self.assertEqual(['2001:DB8::1'], ips)
+
     def test_wait_until_running_running_after_1_second(self):
         RackspaceMockHttp.type = '05_SECOND_DELAY'
         node2, ips = self.driver.wait_until_running(
@@ -498,6 +532,16 @@ class RackspaceMockHttp(MockHttp):
             'v1_slug_servers_detail_deployment_multiple_nodes.xml')
         return (httplib.OK, body, XML_HEADERS, httplib.responses[httplib.OK])
 
+    def _v1_0_slug_servers_detail_IPV6(self, method, url, body, headers):
+        body = self.fixtures.load(
+            'v1_slug_servers_detail_deployment_ipv6.xml')
+        return (httplib.OK, body, XML_HEADERS, httplib.responses[httplib.OK])
+
+    def _v1_0_slug_servers_detail_NO_IP(self, method, url, body, headers):
+        body = self.fixtures.load(
+            'v1_slug_servers_detail_deployment_no_ip.xml')
+        return (httplib.OK, body, XML_HEADERS, httplib.responses[httplib.OK])
+
 
 if __name__ == '__main__':
     sys.exit(unittest.main())


Mime
View raw message