Author: tomaz
Date: Sat Nov 12 01:35:53 2011
New Revision: 1201148

URL: http://svn.apache.org/viewvc?rev=1201148&view=rev
Log:
Fix a bug in Rackspace Cloud DNS driver and make sure to throw an
exception if an unexpected status code is returned. Reported by
"jeblair" (backport from trunk)

Modified:
    libcloud/branches/0.6.x/   (props changed)
    libcloud/branches/0.6.x/CHANGES
    libcloud/branches/0.6.x/libcloud/dns/drivers/rackspace.py
    libcloud/branches/0.6.x/test/dns/test_rackspace.py

Propchange: libcloud/branches/0.6.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov 12 01:35:53 2011
@@ -1 +1 @@
-/libcloud/trunk:1201138
+/libcloud/trunk:1201138,1201141

Modified: libcloud/branches/0.6.x/CHANGES
URL: 
http://svn.apache.org/viewvc/libcloud/branches/0.6.x/CHANGES?rev=1201148&r1=1201147&r2=1201148&view=diff
==============================================================================
--- libcloud/branches/0.6.x/CHANGES (original)
+++ libcloud/branches/0.6.x/CHANGES Sat Nov 12 01:35:53 2011
@@ -22,9 +22,15 @@ Changes with Apache Libcloud in developm
        [Tomaz Muraus]
 
    *) DNS:
+
       - Increase the default poll interval in the Rackspace driver to 2.5
-      seconds
-      [Tomaz Muraus]
+        seconds.
+        [Tomaz Muraus]
+
+      - Fix a bug in Rackspace Cloud DNS driver and make sure to throw an
+        exception if an unexpected status code is returned. Reported by
+        jeblair.
+        [Tomaz Muraus]
 
 Changes with Apache Libcloud 0.6.1:
 

Modified: libcloud/branches/0.6.x/libcloud/dns/drivers/rackspace.py
URL: 
http://svn.apache.org/viewvc/libcloud/branches/0.6.x/libcloud/dns/drivers/rackspace.py?rev=1201148&r1=1201147&r2=1201148&view=diff
==============================================================================
--- libcloud/branches/0.6.x/libcloud/dns/drivers/rackspace.py (original)
+++ libcloud/branches/0.6.x/libcloud/dns/drivers/rackspace.py Sat Nov 12 
01:35:53 2011
@@ -63,15 +63,17 @@ class RackspaceDNSResponse(OpenStack_1_1
             elif context['resource'] == 'record':
                 raise RecordDoesNotExistError(value='', driver=self,
                                               record_id=context['id'])
+        if body:
+            if 'code' and 'message' in body:
+                err = '%s - %s (%s)' % (body['code'], body['message'],
+                                        body['details'])
+                return err
+            elif 'validationErrors' in body:
+                errors = [m for m in body['validationErrors']['messages']]
+                err = 'Validation errors: %s' % ', '.join(errors)
+                return err
 
-        if 'code' and 'message' in body:
-            err = '%s - %s (%s)' % (body['code'], body['message'],
-                                    body['details'])
-        elif 'validationErrors' in body:
-            errors = [m for m in body['validationErrors']['messages']]
-            err = 'Validation errors: %s' % ', '.join(errors)
-
-        return err
+        raise LibcloudError('Unexpected status code: %s' % (status))
 
 
 class RackspaceDNSConnection(OpenStack_1_1_Connection, PollingConnection):

Modified: libcloud/branches/0.6.x/test/dns/test_rackspace.py
URL: 
http://svn.apache.org/viewvc/libcloud/branches/0.6.x/test/dns/test_rackspace.py?rev=1201148&r1=1201147&r2=1201148&view=diff
==============================================================================
--- libcloud/branches/0.6.x/test/dns/test_rackspace.py (original)
+++ libcloud/branches/0.6.x/test/dns/test_rackspace.py Sat Nov 12 01:35:53 2011
@@ -48,6 +48,16 @@ class RackspaceUSTests(unittest.TestCase
         self.assertEqual(zones[0].domain, 'foo4.bar.com')
         self.assertEqual(zones[0].extra['comment'], 'wazaaa')
 
+    def test_list_zones_http_413(self):
+        RackspaceMockHttp.type = '413'
+
+        try:
+            self.driver.list_zones()
+        except LibcloudError:
+            pass
+        else:
+            self.fail('Exception was not thrown')
+
     def test_list_zones_no_results(self):
         RackspaceMockHttp.type = 'NO_RESULTS'
         zones = self.driver.list_zones()
@@ -269,6 +279,11 @@ class RackspaceMockHttp(MockHttp):
         return (httplib.OK, body, self.base_headers,
                 httplib.responses[httplib.OK])
 
+    def _v1_0_11111_domains_413(self, method, url, body, headers):
+        body = ''
+        return (httplib.REQUEST_ENTITY_TOO_LARGE, body, self.base_headers,
+                httplib.responses[httplib.REQUEST_ENTITY_TOO_LARGE])
+
     def _v1_0_11111_domains_NO_RESULTS(self, method, url, body, headers):
         body = self.fixtures.load('list_zones_no_results.json')
         return (httplib.OK, body, self.base_headers,


Reply via email to