deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [3/7] git commit: Core: Removed 'root_url' mappings from all servers
Date Wed, 12 Sep 2012 07:35:34 GMT
Core: Removed 'root_url' mappings from all servers

* All servers are now internally mapped on '/' URL.
* Rack::Builder maps servers on proper frontend URI.
* This obsolete 'route_for' and 'root_url' helpers
* This allow to use Sinatra 'url' helper to generate
  absolute URLs


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

Branch: refs/heads/master
Commit: 07febe4b077a55cdf265a4165e6652773c34ad29
Parents: 796db31
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Thu Sep 6 14:17:39 2012 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Tue Sep 11 12:08:28 2012 +0200

----------------------------------------------------------------------
 server/lib/cimi/helpers.rb                         |    2 -
 server/lib/cimi/server.rb                          |    4 +-
 server/lib/deltacloud/collections/addresses.rb     |    2 +-
 server/lib/deltacloud/collections/buckets.rb       |    6 ++--
 server/lib/deltacloud/collections/firewalls.rb     |    2 +-
 server/lib/deltacloud/collections/instances.rb     |    2 +-
 server/lib/deltacloud/collections/keys.rb          |    2 +-
 .../lib/deltacloud/collections/storage_volumes.rb  |    2 +-
 server/lib/deltacloud/helpers.rb                   |    8 +-----
 server/lib/deltacloud/server.rb                    |   19 ++++++--------
 10 files changed, 19 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/07febe4b/server/lib/cimi/helpers.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/helpers.rb b/server/lib/cimi/helpers.rb
index 2dba3be..bf268f8 100644
--- a/server/lib/cimi/helpers.rb
+++ b/server/lib/cimi/helpers.rb
@@ -70,8 +70,6 @@ module CIMI::Collections
     set :views, root + '/views/cimi'
     set :public_folder, root + '/public'
 
-    Sinatra::Rabbit.set :root_path, "#{config.root_url}/"
-
     error do
       report_error
     end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/07febe4b/server/lib/cimi/server.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/server.rb b/server/lib/cimi/server.rb
index 0c78a2a..cbb6486 100644
--- a/server/lib/cimi/server.rb
+++ b/server/lib/cimi/server.rb
@@ -45,8 +45,8 @@ module CIMI
     include CIMI::Collections
     include CIMI::Model
 
-    get Deltacloud[:cimi].root_url do
-      redirect Deltacloud[:cimi].root_url + '/cloudEntryPoint', 301
+    get '/' do
+      redirect url('/cloudEntryPoint'), 301
     end
 
   end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/07febe4b/server/lib/deltacloud/collections/addresses.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/collections/addresses.rb b/server/lib/deltacloud/collections/addresses.rb
index 622a949..664b80d 100644
--- a/server/lib/deltacloud/collections/addresses.rb
+++ b/server/lib/deltacloud/collections/addresses.rb
@@ -18,7 +18,7 @@ module Deltacloud::Collections
 
     set :capability, lambda { |m| driver.respond_to? m }
 
-    get route_for('/addresses/:id/associate') do
+    get '/addresses/:id/associate' do
       @address = driver.address(credentials, params )
       @instances = driver.instances(credentials)
       respond_to do |format|

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/07febe4b/server/lib/deltacloud/collections/buckets.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/collections/buckets.rb b/server/lib/deltacloud/collections/buckets.rb
index bb2a805..1b00033 100644
--- a/server/lib/deltacloud/collections/buckets.rb
+++ b/server/lib/deltacloud/collections/buckets.rb
@@ -24,7 +24,7 @@ module Deltacloud::Collections
 
     new_route_for :buckets
 
-    get route_for('/buckets/:bucket/%s' % NEW_BLOB_FORM_ID) do
+    get '/buckets/:bucket/%s' % NEW_BLOB_FORM_ID do
       @bucket_id = params[:bucket]
       respond_to do |format|
         format.html {haml :"blobs/new"}
@@ -32,7 +32,7 @@ module Deltacloud::Collections
     end
 
 
-    head route_for('/buckets/:bucket/:blob') do
+    head '/buckets/:bucket/:blob' do
       @blob_id = params[:blob]
       @blob_metadata = driver.blob_metadata(credentials, {:id => params[:blob], 'bucket'
=> params[:bucket]})
       if @blob_metadata
@@ -49,7 +49,7 @@ module Deltacloud::Collections
       end
     end
 
-    put route_for("/buckets/:bucket/:blob") do
+    put "/buckets/:bucket/:blob" do
       if(env["BLOB_SUCCESS"]) #ie got a 200ok after putting blob
         content_type = env["CONTENT_TYPE"]
         content_type ||=  ""

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/07febe4b/server/lib/deltacloud/collections/firewalls.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/collections/firewalls.rb b/server/lib/deltacloud/collections/firewalls.rb
index 0046cf3..47ab68f 100644
--- a/server/lib/deltacloud/collections/firewalls.rb
+++ b/server/lib/deltacloud/collections/firewalls.rb
@@ -22,7 +22,7 @@ module Deltacloud::Collections
 
     check_features :for => lambda { |c, f| driver.class.has_feature?(c, f) }
 
-    get route_for('/firewalls/:id/new_rule') do
+    get '/firewalls/:id/new_rule' do
       @firewall_name = params[:id]
       respond_to do |format|
         format.html {haml :"firewalls/new_rule" }

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/07febe4b/server/lib/deltacloud/collections/instances.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/collections/instances.rb b/server/lib/deltacloud/collections/instances.rb
index 742b16a..f7d2646 100644
--- a/server/lib/deltacloud/collections/instances.rb
+++ b/server/lib/deltacloud/collections/instances.rb
@@ -31,7 +31,7 @@ module Deltacloud::Collections
       @keys = driver.keys(credentials) if driver.class.has_feature? :instances, :authentication_key
     end
 
-    get route_for('/instances/:id/run') do
+    get '/instances/:id/run' do
       respond_to do |format|
         @instance = driver.instances(credentials, :id => params[:id]).first
         format.html {haml :"instances/run_command" }

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/07febe4b/server/lib/deltacloud/collections/keys.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/collections/keys.rb b/server/lib/deltacloud/collections/keys.rb
index bb9859d..fa1b3e0 100644
--- a/server/lib/deltacloud/collections/keys.rb
+++ b/server/lib/deltacloud/collections/keys.rb
@@ -21,7 +21,7 @@ module Deltacloud::Collections
     set :capability, lambda { |m| driver.respond_to? m }
     check_features :for => lambda { |c, f| driver.class.has_feature?(c, f) }
 
-    get route_for('/keys/new') do
+    get '/keys/new' do
       respond_to do |format|
         format.html { haml :"keys/new" }
       end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/07febe4b/server/lib/deltacloud/collections/storage_volumes.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/collections/storage_volumes.rb b/server/lib/deltacloud/collections/storage_volumes.rb
index 99f99f2..53d646d 100644
--- a/server/lib/deltacloud/collections/storage_volumes.rb
+++ b/server/lib/deltacloud/collections/storage_volumes.rb
@@ -21,7 +21,7 @@ module Deltacloud::Collections
 
     new_route_for(:storage_volumes)
 
-    get route_for("/storage_volumes/:id/attach_instance") do
+    get "/storage_volumes/:id/attach_instance" do
       @instances = driver.instances(credentials)
       respond_to do |format|
         format.html{ haml :"storage_volumes/attach"}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/07febe4b/server/lib/deltacloud/helpers.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/helpers.rb b/server/lib/deltacloud/helpers.rb
index 6566c59..872c239 100644
--- a/server/lib/deltacloud/helpers.rb
+++ b/server/lib/deltacloud/helpers.rb
@@ -49,8 +49,6 @@ module Deltacloud::Collections
     set :views, root + '/views'
     set :public_folder, root + '/public'
 
-    Sinatra::Rabbit.set :root_path, "#{config.root_url}/"
-
     error do
       report_error
     end
@@ -73,7 +71,7 @@ module Deltacloud::Collections
     end
 
     def self.new_route_for(route, &block)
-      get route_for('/' + route.to_s + '/new') do
+      get '/' + route.to_s + '/new' do
         instance_eval(&block) if block_given?
         respond_to do |format|
           format.html do
@@ -87,9 +85,5 @@ module Deltacloud::Collections
       Sinatra::Rabbit.set :check_features, opts[:for]
     end
 
-    def self.route_for(url)
-      "#{settings.root_url}#{url}"
-    end
-
   end
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/07febe4b/server/lib/deltacloud/server.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/server.rb b/server/lib/deltacloud/server.rb
index c60edfa..fcd24d9 100644
--- a/server/lib/deltacloud/server.rb
+++ b/server/lib/deltacloud/server.rb
@@ -36,7 +36,6 @@ module Deltacloud
     use Deltacloud[:deltacloud].logger unless RUBY_PLATFORM == 'java'
     use Rack::Date
     use Rack::ETag
-    use Rack::MatrixParams
     use Rack::DriverSelect
     use Rack::Accept
     use Rack::MediaType
@@ -46,7 +45,7 @@ module Deltacloud
 
     set :config, Deltacloud[:deltacloud]
 
-    get Deltacloud.config[:deltacloud].root_url + '/?' do
+    get '/' do
       if params[:force_auth]
         return [401, 'Authentication failed'] unless driver.valid_credentials?(credentials)
       end
@@ -57,24 +56,22 @@ module Deltacloud
       end
     end
 
-    options Deltacloud.config[:deltacloud].root_url + '/?' do
+    options '/' do
       headers 'Allow' => supported_collections { |c| c.collection_name }.join(',')
     end
 
-    post Deltacloud.config[:deltacloud].root_url + '/?' do
+    post '/' do
       param_driver, param_provider = params["driver"], params["provider"]
       if param_driver
-        redirect "#{Deltacloud.config[:deltacloud].root_url}\;driver=#{param_driver}", 301
+        redirect "#{root_url};driver=#{param_driver}", 301
       elsif param_provider && param_provider != "default"
-#FIXME NEEDS A BETTER WAY OF GRABBING CURRENT DRIVER FROM MATRIX PARAMS...
-        current_matrix_driver = env['HTTP_REFERER'] ? env["HTTP_REFERER"].match(/\;(driver)=(\w*).*$/i)
: nil
-        if current_matrix_driver
-          redirect "#{Deltacloud.config[:deltacloud].root_url}\;driver=#{$2}\;provider=#{param_provider}",
301
+        if request.referrer and request.referrer[/\;(driver)=(\w*).*$/i]
+          redirect "#{root_url};driver=#{$2}\;provider=#{param_provider}", 301
         else
-          redirect "#{Deltacloud.config[:deltacloud].root_url}\;provider=#{param_provider}",
301
+          redirect "#{root_url};provider=#{param_provider}", 301
         end
       else
-        redirect "#{Deltacloud.config[:deltacloud].root_url}", 301
+        redirect url('/'), 301
       end
     end
 


Mime
View raw message