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/536ae048 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/536ae048 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/536ae048 Branch: refs/heads/trunk Commit: 536ae048abc918dfe7b18a39a538859aa04231ae Parents: fb11854 Author: Tomaz Muraus <[email protected]> Authored: Wed Jun 26 16:49:28 2013 +0200 Committer: Tomaz Muraus <[email protected]> Committed: Wed Jun 26 16:49:28 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/536ae048/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index ab63e64..4b270d4 100644 --- a/CHANGES +++ b/CHANGES @@ -121,6 +121,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/536ae048/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.
