incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1087214 - in /incubator/deltacloud/trunk/server: ./ lib/deltacloud/base_driver/ lib/deltacloud/drivers/ec2/ lib/deltacloud/drivers/gogrid/ lib/deltacloud/drivers/mock/ lib/deltacloud/drivers/rackspace/
Date Thu, 31 Mar 2011 08:35:04 GMT
Author: mfojtik
Date: Thu Mar 31 08:35:03 2011
New Revision: 1087214

URL: http://svn.apache.org/viewvc?rev=1087214&view=rev
Log:
Return HTTP status code 401 when authentication fails

Fixes JIRA #DTACLOUD-29

Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb
    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/server.rb

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb?rev=1087214&r1=1087213&r2=1087214&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb Thu Mar 31
08:35:03 2011
@@ -238,18 +238,26 @@ module Deltacloud
     def safely(&block)
       begin
         block.call
-      rescue *catched_exceptions_list[:error] => e
-        raise Deltacloud::BackendError.new(502, e.class.to_s, e.message, e.backtrace)
-      rescue *catched_exceptions_list[:auth] => e
-        raise Deltacloud::AuthException.new
       rescue => e
+        catched_exceptions_list[:auth].each do |ex|
+          if e.class == ex or e.class.name =~ ex or e.message =~ ex
+            raise Deltacloud::AuthException.new
+          end
+        end
+        catched_exceptions_list[:error].each do |ex|
+          if e.class == ex or e.class.name =~ ex or e.message =~ ex
+            raise Deltacloud::BackendError.new(502, e.class.to_s, e.message, e.backtrace)
if e.class.name =~ ex
+          end
+        end
         catched_exceptions_list[:glob].each do |ex|
-          raise Deltacloud::BackendError.new(502, e.class.to_s, e.message, e.backtrace) if
e.class.name =~ ex
+          if e.class == ex or e.class.name =~ ex or e.message =~ ex
+            raise Deltacloud::BackendError.new(500, e.class.to_s, e.message, e.backtrace)
+          end
         end
-        puts "======= UNHANDLED EXCEPTION ============"
-        puts e.inspect
-        puts "========================================"
-        raise e
+        $stderr.puts "# UNCAUGHT EXCEPTION # -> '#{e.class}' - '#{e.message}'"
+        $stderr.puts "# #{e.backtrace.join("\n")}"
+        $stderr.puts "##############"
+        raise Deltacloud::BackendError.new(500, e.class.to_s, e.message, e.backtrace)
       end
     end
 

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=1087214&r1=1087213&r2=1087214&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 Thu Mar 31
08:35:03 2011
@@ -715,8 +715,8 @@ module Deltacloud
 
         def catched_exceptions_list
           {
-            :auth => [], # [ ::Aws::AuthFailure ],
-            :error => [ ::Aws::AwsError ],
+            :auth => [ /AuthFailure/ ],
+            :error => [ /Aws::AwsError/, /Error/ ],
             :glob => [ /AWS::(\w+)/, /Deltacloud::Runner::(\w+)/ ]
           }
         end

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=1087214&r1=1087213&r2=1087214&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 Thu Mar
31 08:35:03 2011
@@ -471,15 +471,6 @@ class GogridDriver < Deltacloud::BaseDri
     end
     return ip
   end
-
-  def safely(&block)
-    begin
-      block.call
-    rescue Exception => e
-      raise Deltacloud::BackendError.new(500, e.class.to_s, e.message, e.backtrace)
-    end
-  end
-
 end
 
     end

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=1087214&r1=1087213&r2=1087214&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 Thu Mar 31
08:35:03 2011
@@ -508,8 +508,8 @@ class MockDriver < Deltacloud::BaseDrive
   def catched_exceptions_list
     {
       :auth => [],
-      :error => [ ::Deltacloud::BackendError, Errno::ENOENT ],
-      :glob => []
+      :error => [ /Deltacloud::BackendError/, /Errno::ENOENT/ ],
+      :glob => [ /Error/ ]
     }
   end
 

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=1087214&r1=1087213&r2=1087214&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
Thu Mar 31 08:35:03 2011
@@ -393,12 +393,12 @@ private
     end
   end
 
-  def safely(&block)
-    begin
-      block.call
-    rescue Exception => e
-      raise Deltacloud::BackendError.new(500, e.class.to_s, e.message, e.backtrace)
-    end
+  def catched_exceptions_list
+    {
+      :auth => [ /Authentication failed/ ],
+      :error => [ /Error/ ],
+      :glob => [ /CloudServers::Exception::(\w+)/, /Deltacloud::Runner::(\w+)/ ]
+    }
   end
 
   private

Modified: incubator/deltacloud/trunk/server/server.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/server.rb?rev=1087214&r1=1087213&r2=1087214&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/server.rb (original)
+++ incubator/deltacloud/trunk/server/server.rb Thu Mar 31 08:35:03 2011
@@ -66,8 +66,9 @@ end
 error Deltacloud::BackendCapability::Failure do
   report_error(405, "backend_capability_failure")
 end
+
 error Deltacloud::AuthException do
-  report_error(403, "auth_exception")
+  report_error(401, "auth_exception")
 end
 
 error Deltacloud::BackendError do



Mime
View raw message