libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1347214 - in /libcloud/trunk: CHANGES libcloud/common/cloudstack.py test/common/test_cloudstack.py
Date Thu, 07 Jun 2012 00:11:52 GMT
Author: tomaz
Date: Thu Jun  7 00:11:52 2012
New Revision: 1347214

URL: http://svn.apache.org/viewvc?rev=1347214&view=rev
Log:
Include error text if a CloudStack async job returns an error code. Contributed
by Gabriel Reid, part of LIBCLOUD-207.

Modified:
    libcloud/trunk/CHANGES
    libcloud/trunk/libcloud/common/cloudstack.py
    libcloud/trunk/test/common/test_cloudstack.py

Modified: libcloud/trunk/CHANGES
URL: http://svn.apache.org/viewvc/libcloud/trunk/CHANGES?rev=1347214&r1=1347213&r2=1347214&view=diff
==============================================================================
--- libcloud/trunk/CHANGES (original)
+++ libcloud/trunk/CHANGES Thu Jun  7 00:11:52 2012
@@ -34,6 +34,10 @@ Changes with Apache Libcloud in developm
       This will make Libcloud ignore IPv6 addresses when using deploy_node.
       [Jay Doane, Tomaz muraus]
 
+    - Include error text if a CloudStack async job returns an error code. ;
+      LIBCLOUD-207
+      [Gabriel Reid]
+
   *) DNS
 
     - Add support for GEO RecordType to Zerigo driver. ; LIBCLOUD-203

Modified: libcloud/trunk/libcloud/common/cloudstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/common/cloudstack.py?rev=1347214&r1=1347213&r2=1347214&view=diff
==============================================================================
--- libcloud/trunk/libcloud/common/cloudstack.py (original)
+++ libcloud/trunk/libcloud/common/cloudstack.py Thu Jun  7 00:11:52 2012
@@ -55,7 +55,7 @@ class CloudStackConnection(ConnectionUse
         return params
 
     def pre_connect_hook(self, params, headers):
-        params['signature'] = self._make_signature(params).decode('utf-8')
+        params['signature'] = self._make_signature(params)
 
         return params, headers
 
@@ -83,7 +83,8 @@ class CloudStackConnection(ConnectionUse
         status = response.get('jobstatus', self.ASYNC_PENDING)
 
         if status == self.ASYNC_FAILURE:
-            raise Exception(status)
+            msg = response.get('jobresult', {}).get('errortext', status)
+            raise Exception(msg)
 
         return status == self.ASYNC_SUCCESS
 

Modified: libcloud/trunk/test/common/test_cloudstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/common/test_cloudstack.py?rev=1347214&r1=1347213&r2=1347214&view=diff
==============================================================================
--- libcloud/trunk/test/common/test_cloudstack.py (original)
+++ libcloud/trunk/test/common/test_cloudstack.py Thu Jun  7 00:11:52 2012
@@ -21,6 +21,7 @@ from libcloud.common.types import Malfor
 
 from test import MockHttpTestCase
 
+
 async_delay = 0
 
 class CloudStackMockDriver(object):
@@ -63,7 +64,9 @@ class CloudStackCommonTest(unittest.Test
         self.driver.path = '/async/fail'
         try:
             self.connection._async_request('fake')
-        except:
+        except Exception:
+            e = sys.exc_info()[1]
+            self.assertEquals(CloudStackMockHttp.ERROR_TEXT, str(e))
             return
         self.assertFalse(True)
 
@@ -109,6 +112,9 @@ class CloudStackCommonTest(unittest.Test
             self.assertEqual(connection._make_signature(params), b(case[1]))
 
 class CloudStackMockHttp(MockHttpTestCase):
+
+    ERROR_TEXT = 'ERROR TEXT'
+
     def _response(self, status, result, response):
         return (status, json.dumps(result), result, response)
 
@@ -156,7 +162,7 @@ class CloudStackMockHttp(MockHttpTestCas
             result = {
                 query['command'].lower() + 'response': {
                     'jobstatus': 2,
-                    'jobresult': {'fake': 'failresult'}
+                    'jobresult': {'errortext': self.ERROR_TEXT}
                 }
             }
         else:



Mime
View raw message