You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by ma...@apache.org on 2013/02/27 18:36:06 UTC
git commit: Adds 'valid_credentials?' method for digital_ocean driver
- DTACLOUD-480
Updated Branches:
refs/heads/master a21400d69 -> de51348f6
Adds 'valid_credentials?' method for digital_ocean driver - DTACLOUD-480
https://issues.apache.org/jira/browse/DTACLOUD-480
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/de51348f
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/de51348f
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/de51348f
Branch: refs/heads/master
Commit: de51348f65ab3766a6be93c920a057014a69dda9
Parents: a21400d
Author: marios <ma...@redhat.com>
Authored: Tue Feb 26 18:43:35 2013 +0200
Committer: marios <ma...@redhat.com>
Committed: Wed Feb 27 19:35:27 2013 +0200
----------------------------------------------------------------------
.../drivers/digitalocean/digitalocean_driver.rb | 17 ++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/de51348f/server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb b/server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb
index fbfc987..ad5faf8 100644
--- a/server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb
+++ b/server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb
@@ -206,6 +206,10 @@ module Deltacloud
exceptions do
+ on (/ERROR Unable to verify credentials.*/) do
+ status 401
+ end
+
on(/InternalServerError/) do
status 502
end
@@ -220,6 +224,17 @@ module Deltacloud
end
+ def valid_credentials?(credentials)
+ begin
+ hardware_profile_ids(credentials)
+ rescue Deltacloud::Exceptions::AuthenticationFailure
+ return false
+ rescue => e
+ safely { raise e }
+ end
+ true
+ end
+
private
class Client
@@ -241,7 +256,7 @@ module Deltacloud
json_result = JSON::parse(result)
if json_result['status'] != 'OK'
p result
- error_message = json_result['error_message'] || json_result['status']
+ error_message = json_result['error_message'] || "#{json_result['status']} #{json_result['description']}"
raise error_message
end
json_result