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 2017/12/29 13:38:17 UTC

[1/2] libcloud git commit: LIBCLOUD-971 - wait_until_running should only append addresses if the list is not empty.

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 <to...@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 <to...@fhe3.com>
Authored: Wed Dec 20 14:04:19 2017 +0100
Committer: Tomaz Muraus <to...@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())


[2/2] libcloud git commit: Add changelog entry for #1156.

Posted by to...@apache.org.
Add changelog entry for #1156.


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

Branch: refs/heads/trunk
Commit: a03877af970c9fc4fb340daa23a33772274ac898
Parents: 5c35c98
Author: Tomaz Muraus <to...@tomaz.me>
Authored: Fri Dec 29 14:38:05 2017 +0100
Committer: Tomaz Muraus <to...@tomaz.me>
Committed: Fri Dec 29 14:38:05 2017 +0100

----------------------------------------------------------------------
 CHANGES.rst | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/a03877af/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index c3522b9..54569c8 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -109,6 +109,11 @@ Compute
 - [CloudStack] Handle NICs without addresses (GITHUB-1141)
   [Pierre-Yves Ritschard]
 
+- Fix "wait_until_running() method so it also works correctly and doesn't
+  append "None" to the addresses list if node has no IP address.
+  (GITHUB-1156, LIBCLOUD-971)
+  [Tobias Paepke]
+
 Storage
 ~~~~~~~