deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r1228519 - in /deltacloud/trunk/server: lib/deltacloud/base_driver/base_driver.rb lib/deltacloud/drivers/ec2/ec2_driver.rb lib/deltacloud/server.rb views/api/show.html.haml
Date Sat, 07 Jan 2012 00:33:49 GMT
Author: lutter
Date: Sat Jan  7 00:33:48 2012
New Revision: 1228519

URL: http://svn.apache.org/viewvc?rev=1228519&view=rev
Log:
Do not throw an error on HTML request to /api for non-EC2 drivers

The generation of the provider selection was EC2 specific, and causes an
internal error for drivers other than the EC2 driver.

Cleaned this up by adding a 'configured_providers' method to drivers, since
they ultimately are the ones who knows how available providers are listed
in their YAML config files.

Fixes https://issues.apache.org/jira/browse/DTACLOUD-124

Modified:
    deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb
    deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
    deltacloud/trunk/server/lib/deltacloud/server.rb
    deltacloud/trunk/server/views/api/show.html.haml

Modified: deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb?rev=1228519&r1=1228518&r2=1228519&view=diff
==============================================================================
--- deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb (original)
+++ deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb Sat Jan  7 00:33:48
2012
@@ -235,6 +235,11 @@ module Deltacloud
       Thread.current[:provider] || ENV['API_PROVIDER']
     end
 
+    # Return an array of the providers statically configured
+    # in the driver's YAML file
+    def configured_providers
+      []
+    end
   end
 
 end

Modified: deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb?rev=1228519&r1=1228518&r2=1228519&view=diff
==============================================================================
--- deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb (original)
+++ deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb Sat Jan  7 00:33:48 2012
@@ -701,6 +701,10 @@ module Deltacloud
            :url=>"#{ENV['API_HOST']}:#{ENV['API_PORT']}#{settings.root_url}\;provider=#{r}"
}) }
         end
 
+        def configured_providers
+          Deltacloud::Drivers::driver_config[:ec2][:entrypoints]["ec2"].keys
+        end
+
         def valid_credentials?(credentials)
           retval = true
           begin

Modified: deltacloud/trunk/server/lib/deltacloud/server.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/lib/deltacloud/server.rb?rev=1228519&r1=1228518&r2=1228519&view=diff
==============================================================================
--- deltacloud/trunk/server/lib/deltacloud/server.rb (original)
+++ deltacloud/trunk/server/lib/deltacloud/server.rb Sat Jan  7 00:33:48 2012
@@ -110,8 +110,7 @@ get "#{settings.root_url}\/?" do
     return [401, 'Authentication failed'] unless driver.valid_credentials?(credentials)
   end
   @collections = [:drivers] + driver.supported_collections
-  #could use driver.providers - but that will require credentials for /api ...
-  @providers = Deltacloud::Drivers::driver_config["#{driver.name}".to_sym][:entrypoints]["#{driver.name}"].keys
unless driver_provider(Deltacloud::Drivers::driver_config["#{driver.name}".to_sym]).empty?
+  @providers = driver.configured_providers
   respond_to do |format|
     format.xml { haml :"api/show" }
     format.json do

Modified: deltacloud/trunk/server/views/api/show.html.haml
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/views/api/show.html.haml?rev=1228519&r1=1228518&r2=1228519&view=diff
==============================================================================
--- deltacloud/trunk/server/views/api/show.html.haml (original)
+++ deltacloud/trunk/server/views/api/show.html.haml Sat Jan  7 00:33:48 2012
@@ -6,7 +6,7 @@
     - @collections.sort_by { |k| k.to_s }.each do |key|
       %li= link_to key.to_s.gsub('_', ' ').titlecase, api_url_for(key), :'data-icon' =>
"arrow-r", :'data-ajax' => false
 
-- if @providers
+- if @providers.size > 1
   %div{ :'data-role' => :footer, :'data-theme' => 'a'}
     %form{ :action => settings.root_url, :method => :post, :'data-ajax' => 'false'}
       %div{ :'data-role' => :footer, :'data-theme' => 'a' , :class => 'middle-dialog'}
@@ -16,4 +16,3 @@
           - @providers.each do |provider|
             %option{ :value => provider } #{provider}
         %button{ :type => :submit} Change Provider
-



Mime
View raw message