Author: tomaz
Date: Sat Apr 7 03:58:43 2012
New Revision: 1310664
URL: http://svn.apache.org/viewvc?rev=1310664&view=rev
Log:
Fix a problem in deploy_node - make it work with providers which
don't instantly return created nodein the list_node response.
Also add __str__ and __repr__ method to DeploymentError so the
error message is more useful. This patch has been submitted by
Jouke Waleson and is part of LIBCLOUD-176.
Modified:
libcloud/trunk/CHANGES
libcloud/trunk/libcloud/compute/base.py
libcloud/trunk/libcloud/compute/types.py
libcloud/trunk/test/compute/test_deployment.py
Modified: libcloud/trunk/CHANGES
URL:
http://svn.apache.org/viewvc/libcloud/trunk/CHANGES?rev=1310664&r1=1310663&r2=1310664&view=diff
==============================================================================
--- libcloud/trunk/CHANGES (original)
+++ libcloud/trunk/CHANGES Sat Apr 7 03:58:43 2012
@@ -8,6 +8,12 @@ Changes with Apache Libcloud in developm
driver.
[Jay Doane]
+ - Fix a problem in deploy_node - make it work with providers which
+ don' instantly return created node in the list_node response.
+ Also add __str__ and __repr__ method to DeploymentError so the
+ error message is more useful.
+ [Jouke Waleson, Tomaz Muraus]
+
Changes with Apache Libcloud 0.9.1:
*) General:
Modified: libcloud/trunk/libcloud/compute/base.py
URL:
http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/base.py?rev=1310664&r1=1310663&r2=1310664&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/base.py (original)
+++ libcloud/trunk/libcloud/compute/base.py Sat Apr 7 03:58:43 2012
@@ -631,20 +631,13 @@ class NodeDriver(BaseDriver):
nodes = self.list_nodes()
nodes = list([n for n in nodes if n.uuid == node.uuid])
- if len(nodes) == 0:
- raise LibcloudError(value=('Booted node[%s] ' % node
- + 'is missing from list_nodes.'),
- driver=self)
-
if len(nodes) > 1:
raise LibcloudError(value=('Booted single node[%s], ' % node
+ 'but multiple nodes have same UUID'),
driver=self)
- node = nodes[0]
-
- if (node.public_ips and node.state == NodeState.RUNNING):
- return node
+ if (len(nodes) == 1 and nodes[0].public_ips and nodes[0].state ==
NodeState.RUNNING):
+ return nodes[0]
else:
time.sleep(wait_period)
continue
Modified: libcloud/trunk/libcloud/compute/types.py
URL:
http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/types.py?rev=1310664&r1=1310663&r2=1310664&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/types.py (original)
+++ libcloud/trunk/libcloud/compute/types.py Sat Apr 7 03:58:43 2012
@@ -151,6 +151,13 @@ class DeploymentError(LibcloudError):
self.node = node
self.value = original_exception
+ def __str__(self):
+ return self.__repr__()
+
+ def __repr__(self):
+ return (('<DeploymentError: node=%s, error=%s>'
+ % (self.node.id, str(self.value))))
+
"""Deprecated alias of L{DeploymentException}"""
DeploymentException = DeploymentError
Modified: libcloud/trunk/test/compute/test_deployment.py
URL:
http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_deployment.py?rev=1310664&r1=1310663&r2=1310664&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_deployment.py (original)
+++ libcloud/trunk/test/compute/test_deployment.py Sat Apr 7 03:58:43 2012
@@ -158,7 +158,7 @@ class DeploymentTests(unittest.TestCase)
timeout=1)
except LibcloudError:
e = sys.exc_info()[1]
- self.assertTrue(e.value.find('is missing from list_nodes') != -1)
+ self.assertTrue(e.value.find('Timed out after 1 second') != -1)
else:
self.fail('Exception was not thrown')