incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r995825 - in /incubator/deltacloud/trunk/server/lib/deltacloud/drivers: ec2/ec2_driver.rb gogrid/gogrid_driver.rb mock/mock_driver.rb rackspace/rackspace_driver.rb terremark/terremark_driver.rb
Date Fri, 10 Sep 2010 15:20:16 GMT
Author: mfojtik
Date: Fri Sep 10 15:20:15 2010
New Revision: 995825

URL: http://svn.apache.org/viewvc?rev=995825&view=rev
Log:
Implemented validate_credentials? method in drivers

Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/mock/mock_driver.rb
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/terremark/terremark_driver.rb

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb?rev=995825&r1=995824&r2=995825&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb Fri Sep 10
15:20:15 2010
@@ -310,6 +310,15 @@ class EC2Driver < Deltacloud::BaseDriver
     end
   end
 
+  def valid_credentials?(credentials)
+    client = new_client(credentials)
+    # FIXME: We need to do this call to determine if
+    #        EC2 is working with given credentials. There is no
+    #        other way to check, if given credentials are valid or not.
+    realms = client.describe_availability_zones rescue false
+    return realms ? true : false
+  end
+
   private
 
   def new_client(credentials)

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb?rev=995825&r1=995824&r2=995825&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb Fri Sep
10 15:20:15 2010
@@ -192,6 +192,15 @@ class GogridDriver < Deltacloud::BaseDri
     return creds
   end
 
+  def valid_credentials?(credentials)
+    client = new_client(credentials)
+    # FIXME: We need to do this call to determine if
+    #        GoGrid is working with given credentials. There is no
+    #        other way to check, if given credentials are valid or not.
+    return false unless new_client(credentials).request('common/lookup/list', { 'lookup'
=> 'ip.datacenter' })
+    true
+  end
+
   define_instance_states do
     start.to( :pending )         .automatically
     pending.to( :running )       .automatically

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/mock/mock_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/mock/mock_driver.rb?rev=995825&r1=995824&r2=995825&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/mock/mock_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/mock/mock_driver.rb Fri Sep 10
15:20:15 2010
@@ -257,6 +257,15 @@ class MockDriver < Deltacloud::BaseDrive
     snapshots
   end
 
+  def valid_credentials?(credentials)
+    begin
+      check_credentials(credentials)
+      return true
+    rescue Deltacloud::AuthException
+    end
+    return false
+  end
+
   private
 
   def check_credentials(credentials)

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb?rev=995825&r1=995824&r2=995825&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
(original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
Fri Sep 10 15:20:15 2010
@@ -131,6 +131,15 @@ class RackspaceDriver < Deltacloud::Base
     instances
   end
 
+  def valid_credentials?(credentials)
+    begin
+      new_client(credentials)
+    rescue
+      return false
+    end
+    true
+  end
+
 
   def convert_srv_to_instance(srv)
     inst = Instance.new(:id => srv["id"].to_s,

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/terremark/terremark_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/terremark/terremark_driver.rb?rev=995825&r1=995824&r2=995825&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/terremark/terremark_driver.rb
(original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/terremark/terremark_driver.rb
Fri Sep 10 15:20:15 2010
@@ -191,6 +191,15 @@ def destroy_instance(credentials, id)
   end
 end
 
+def valid_credentials?(credentials)
+  begin
+    new_client(credentials)
+  rescue Deltacloud::AuthException
+    return false
+  end
+  true
+end
+
 #--
 # PRIVATE METHODS:
 #--



Mime
View raw message