deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject git commit: Improved valid_credentials? method on rhevm and vsphere driver
Date Tue, 07 Feb 2012 12:27:49 GMT
Updated Branches:
  refs/heads/master e60bd6428 -> a9ce30265


Improved valid_credentials? method on rhevm and vsphere driver

Signed-off-by: Francesco Vollero <fvollero@redhat.com>


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

Branch: refs/heads/master
Commit: a9ce30265b6519dd8cd8e2d296a8aea357e0d239
Parents: e60bd64
Author: Francesco Vollero <fvollero@redhat.com>
Authored: Tue Feb 7 13:23:58 2012 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Tue Feb 7 13:28:42 2012 +0100

----------------------------------------------------------------------
 .../lib/deltacloud/drivers/rhevm/rhevm_driver.rb   |   10 ++++++----
 .../deltacloud/drivers/vsphere/vsphere_driver.rb   |    9 ++++++---
 2 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a9ce3026/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
index 665e2fe..a66b9c6 100644
--- a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
+++ b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
@@ -208,13 +208,15 @@ class RHEVMDriver < Deltacloud::BaseDriver
   end
 
   def valid_credentials?(credentials)
-    retval = true
     begin
-      realms(credentials)
-    rescue
+      realms(credentials) && true
+    rescue RestClient::Unauthorized
       retval = false
+    rescue => e
+      safely do
+        raise e
+      end
     end
-    retval
   end
 
   private

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a9ce3026/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
index a2a5249..51b6648 100644
--- a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
+++ b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
@@ -370,10 +370,13 @@ module Deltacloud::Drivers::VSphere
 
     def valid_credentials?(credentials)
       begin
-        RbVmomi::VIM.connect(:host => host_endpoint, :user => credentials.user, :password
=> credentials.password, :insecure => true)
-        return true
-      rescue
+        RbVmomi::VIM.connect(:host => host_endpoint, :user => credentials.user, :password
=> credentials.password, :insecure => true) && true
+      rescue RbVmomi::Fault:InvalidLogin
         return false
+      rescue => e
+        safely do
+          raise e
+        end
       end
     end
 


Mime
View raw message