You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2010/07/09 01:14:39 UTC

svn commit: r961983 - in /incubator/deltacloud/trunk/framework: app/controllers/accounts_controller.rb app/controllers/images_controller.rb app/controllers/instances_controller.rb app/helpers/driver_helper.rb lib/drivers/ec2.rb

Author: lutter
Date: Thu Jul  8 23:14:39 2010
New Revision: 961983

URL: http://svn.apache.org/viewvc?rev=961983&view=rev
Log:
Refactor auth-handling, wire up to accounts and instances.
Add better error-checking before creating EC2 client.

Modified:
    incubator/deltacloud/trunk/framework/app/controllers/accounts_controller.rb
    incubator/deltacloud/trunk/framework/app/controllers/images_controller.rb
    incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb
    incubator/deltacloud/trunk/framework/app/helpers/driver_helper.rb
    incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb

Modified: incubator/deltacloud/trunk/framework/app/controllers/accounts_controller.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/controllers/accounts_controller.rb?rev=961983&r1=961982&r2=961983&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/controllers/accounts_controller.rb (original)
+++ incubator/deltacloud/trunk/framework/app/controllers/accounts_controller.rb Thu Jul  8 23:14:39 2010
@@ -5,6 +5,8 @@ class AccountsController < ApplicationCo
 
   include DriverHelper
 
+  around_filter :catch_auth
+
   def index
     @accounts = driver.accounts( credentials )
     respond_to do |format|

Modified: incubator/deltacloud/trunk/framework/app/controllers/images_controller.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/controllers/images_controller.rb?rev=961983&r1=961982&r2=961983&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/controllers/images_controller.rb (original)
+++ incubator/deltacloud/trunk/framework/app/controllers/images_controller.rb Thu Jul  8 23:14:39 2010
@@ -8,15 +8,6 @@ class ImagesController < ApplicationCont
 
   around_filter :catch_auth
 
-  def catch_auth
-    begin
-      yield
-    rescue Drivers::AuthException => e
-      authenticate_or_request_with_http_basic() do |n,p|
-      end
-    end
-  end
-
   def index
     @images = driver.images( credentials, [ 'ami-015db968', 'ami-015dba68' ])
 

Modified: incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb?rev=961983&r1=961982&r2=961983&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb (original)
+++ incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb Thu Jul  8 23:14:39 2010
@@ -7,6 +7,8 @@ class InstancesController < ApplicationC
 
   include DriverHelper
 
+  around_filter :catch_auth
+
   def index
     @instances = driver.instances( credentials )
 

Modified: incubator/deltacloud/trunk/framework/app/helpers/driver_helper.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/helpers/driver_helper.rb?rev=961983&r1=961982&r2=961983&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/helpers/driver_helper.rb (original)
+++ incubator/deltacloud/trunk/framework/app/helpers/driver_helper.rb Thu Jul  8 23:14:39 2010
@@ -5,4 +5,13 @@ module DriverHelper
     @driver ||= Drivers::EC2.new
   end
 
+  def catch_auth
+    begin
+      yield
+    rescue Drivers::AuthException => e
+      authenticate_or_request_with_http_basic() do |n,p|
+      end
+    end
+  end
+
 end

Modified: incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb?rev=961983&r1=961982&r2=961983&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb (original)
+++ incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb Thu Jul  8 23:14:39 2010
@@ -25,9 +25,11 @@ module Drivers
     def images(credentials, *ids)
       ec2 = new_client( credentials )
       images = []
-      ec2.describe_images(*ids).each do |ec2_image|
-        if ( ec2_image[:aws_id] =~ /^ami-/ ) 
-          images << convert_image( ec2_image )
+      safely do
+        ec2.describe_images(*ids).each do |ec2_image|
+          if ( ec2_image[:aws_id] =~ /^ami-/ ) 
+            images << convert_image( ec2_image )
+          end
         end
       end
       images