Correctly throw InvalidCredsError if user passes invalid credentials to
the DigitalOcean driver.


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

Branch: refs/heads/0.12.x
Commit: f3be0573b86250c32651556807f71193221fa842
Parents: d654482
Author: Tomaz Muraus <[email protected]>
Authored: Wed Jun 26 16:49:28 2013 +0200
Committer: Tomaz Muraus <[email protected]>
Committed: Wed Jun 26 17:08:52 2013 +0200

----------------------------------------------------------------------
 CHANGES                                  | 4 ++++
 libcloud/compute/drivers/digitalocean.py | 7 +++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/f3be0573/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 444c9c5..95703ee 100644
--- a/CHANGES
+++ b/CHANGES
@@ -120,6 +120,10 @@ Changes with Apache Libcloud in deveploment:
       CloudStack driver. (LIBCLOUD-349)
       [Philipp Strube]
 
+    - Correctly throw InvalidCredsError if user passes invalid credentials to
+      the DigitalOcean driver.
+      [Tomaz muraus]
+
  *) Storage
 
     - Fix an issue with double encoding the container name in the CloudFiles

http://git-wip-us.apache.org/repos/asf/libcloud/blob/f3be0573/libcloud/compute/drivers/digitalocean.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/digitalocean.py 
b/libcloud/compute/drivers/digitalocean.py
index cde0b18..0f4ee40 100644
--- a/libcloud/compute/drivers/digitalocean.py
+++ b/libcloud/compute/drivers/digitalocean.py
@@ -29,6 +29,9 @@ class DigitalOceanResponse(JsonResponse):
         if self.status == httplib.FOUND and '/api/error' in self.body:
             # Hacky, but DigitalOcean error responses are awful
             raise InvalidCredsError(self.body)
+        elif self.status == httplib.UNAUTHORIZED:
+            body = self.parse_body()
+            raise InvalidCredsError(body['message'])
 
 
 class SSHKey(object):
@@ -99,8 +102,8 @@ class DigitalOceanNodeDriver(NodeDriver):
         """
         Create a node.
 
-        @keyword    ex_ssh_key_ids: A list of ssh key ids which will be added 
to
-                                 the server. (optional)
+        @keyword    ex_ssh_key_ids: A list of ssh key ids which will be added
+                                   to the server. (optional)
         @type       ex_ssh_key_ids: C{list} of C{str}
 
         @return: The newly created node.

Reply via email to