deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject git commit: Deltacloud - rework 'valid_credentials' - moved to base_driver where possible
Date Wed, 27 Feb 2013 17:39:26 GMT
Updated Branches:
  refs/heads/master de51348f6 -> a8d19ea5a


Deltacloud - rework 'valid_credentials' - moved to base_driver where possible

Drivers can override this where needed - like e.g. in ec2 driver where just
creating a handle to the aws service (via the appoxy/aws rubygem) isn't enough
to determine that credentials are not valid.


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

Branch: refs/heads/master
Commit: a8d19ea5a195bdaa7e72b1b0e66d861a6f71f07d
Parents: de51348
Author: marios <marios@redhat.com>
Authored: Tue Feb 26 18:51:04 2013 +0200
Committer: marios <marios@redhat.com>
Committed: Wed Feb 27 19:39:00 2013 +0200

----------------------------------------------------------------------
 .../drivers/arubacloud/arubacloud_driver.rb        |    9 ---------
 server/lib/deltacloud/drivers/base_driver.rb       |   12 ++++++++++++
 server/lib/deltacloud/drivers/mock/mock_driver.rb  |   10 +---------
 .../drivers/openstack/openstack_driver.rb          |    9 ---------
 .../drivers/rackspace/rackspace_driver.rb          |    9 ---------
 .../drivers/terremark/terremark_driver.rb          |    8 --------
 .../deltacloud/drivers/vsphere/vsphere_driver.rb   |   12 ------------
 7 files changed, 13 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8d19ea5/server/lib/deltacloud/drivers/arubacloud/arubacloud_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/arubacloud/arubacloud_driver.rb b/server/lib/deltacloud/drivers/arubacloud/arubacloud_driver.rb
index 4a24760..be919e8 100644
--- a/server/lib/deltacloud/drivers/arubacloud/arubacloud_driver.rb
+++ b/server/lib/deltacloud/drivers/arubacloud/arubacloud_driver.rb
@@ -61,15 +61,6 @@ class ArubacloudDriver < Deltacloud::BaseDriver
     architecture ['x86_64', 'i386']
   end
 
-  def valid_credentials?(credentials)
-    begin
-      new_client(credentials)
-    rescue
-      return false
-    end
-    true
-  end
-
   def realms(credentials, opts=nil)
     client = new_client(credentials)
     safely do

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8d19ea5/server/lib/deltacloud/drivers/base_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/base_driver.rb b/server/lib/deltacloud/drivers/base_driver.rb
index 1bb80d5..e346e7c 100644
--- a/server/lib/deltacloud/drivers/base_driver.rb
+++ b/server/lib/deltacloud/drivers/base_driver.rb
@@ -286,6 +286,18 @@ module Deltacloud
     def configured_providers
       []
     end
+
+    def valid_credentials?(credentials)
+      begin
+        new_client(credentials)
+      rescue  Deltacloud::Exceptions::AuthenticationFailure
+        return false
+      rescue => e
+        safely { raise e }
+      end
+      true
+    end
+
   end
 
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8d19ea5/server/lib/deltacloud/drivers/mock/mock_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/mock_driver.rb b/server/lib/deltacloud/drivers/mock/mock_driver.rb
index fe930c2..f4e86c1 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver.rb
@@ -578,15 +578,6 @@ module Deltacloud::Drivers::Mock
       metric
     end
 
-    def valid_credentials?(credentials)
-      begin
-        check_credentials(credentials)
-        return true
-      rescue
-      end
-      return false
-    end
-
     private
 
     def check_credentials(credentials)
@@ -596,6 +587,7 @@ module Deltacloud::Drivers::Mock
         end
       end
     end
+    alias :new_client :check_credentials
 
     #Mock allocation of 'new' address
     #There is a synchronization problem (but it's the mock driver,

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8d19ea5/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/openstack/openstack_driver.rb b/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
index 356d835..5b420bb 100644
--- a/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
+++ b/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
@@ -237,15 +237,6 @@ module Deltacloud
 
         alias_method :stop_instance, :destroy_instance
 
-        def valid_credentials?(credentials)
-          begin
-            new_client(credentials)
-          rescue
-            return false
-          end
-          true
-        end
-
         def buckets(credentials, opts={})
           os = new_client(credentials, "object-store")
           buckets = []

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8d19ea5/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
index 8082767..24ae55d 100644
--- a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
+++ b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
@@ -181,15 +181,6 @@ class RackspaceDriver < Deltacloud::BaseDriver
     insts
   end
 
-  def valid_credentials?(credentials)
-    begin
-      new_client(credentials)
-    rescue
-      return false
-    end
-    true
-  end
-
   define_instance_states do
     start.to( :pending )          .on( :create )
     pending.to( :running )        .automatically

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8d19ea5/server/lib/deltacloud/drivers/terremark/terremark_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/terremark/terremark_driver.rb b/server/lib/deltacloud/drivers/terremark/terremark_driver.rb
index 1d3f4ce..30d092b 100644
--- a/server/lib/deltacloud/drivers/terremark/terremark_driver.rb
+++ b/server/lib/deltacloud/drivers/terremark/terremark_driver.rb
@@ -197,14 +197,6 @@ def destroy_instance(credentials, id)
   end
 end
 
-def valid_credentials?(credentials)
-  begin
-    new_client(credentials)
-  rescue
-    return false
-  end
-  true
-end
 
 #--
 # PRIVATE METHODS:

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8d19ea5/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 272f471..0f9978e 100644
--- a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
+++ b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
@@ -390,18 +390,6 @@ module Deltacloud::Drivers::Vsphere
 
     end
 
-    def valid_credentials?(credentials)
-      begin
-        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
-
     #######
     private
     #######


Mime
View raw message