From: Michal Fojtik <[email protected]>
Signed-off-by: Michal fojtik <[email protected]> --- .../lib/deltacloud/helpers/application_helper.rb | 21 ++++++----- server/lib/deltacloud/models/bucket.rb | 3 +- server/lib/deltacloud/models/image.rb | 2 +- server/lib/sinatra/rabbit.rb | 36 ++++++++----------- server/server.rb | 38 ++++++++++---------- server/views/api/show.html.haml | 2 +- server/views/buckets/index.html.haml | 2 +- server/views/buckets/show.html.haml | 2 +- server/views/docs/collection.html.haml | 4 +- server/views/docs/collection.xml.haml | 4 +- server/views/docs/index.html.haml | 2 +- server/views/docs/index.xml.haml | 2 +- server/views/docs/operation.xml.haml | 2 +- server/views/images/show.html.haml | 2 +- server/views/instance_states/show.html.haml | 2 +- server/views/instances/index.html.haml | 4 +- server/views/instances/show.html.haml | 2 +- server/views/keys/index.html.haml | 2 +- server/views/keys/new.html.haml | 2 +- server/views/load_balancers/index.html.haml | 2 +- server/views/load_balancers/new.html.haml | 2 +- server/views/load_balancers/show.html.haml | 2 +- server/views/storage_snapshots/new.html.haml | 2 +- server/views/storage_volumes/index.html.haml | 6 ++-- server/views/storage_volumes/new.html.haml | 2 +- 25 files changed, 73 insertions(+), 77 deletions(-) diff --git a/server/lib/deltacloud/helpers/application_helper.rb b/server/lib/deltacloud/helpers/application_helper.rb index d496368..4c0c36d 100644 --- a/server/lib/deltacloud/helpers/application_helper.rb +++ b/server/lib/deltacloud/helpers/application_helper.rb @@ -22,17 +22,17 @@ module ApplicationHelper include Deltacloud def bread_crumb - s = "<ul class='breadcrumb'><li class='first'><a href='#{url_for('/')}'>δ</a></li>" + s = "<ul class='breadcrumb'><li class='first'><a href='#{root_url}'>δ</a></li>" url = request.path_info.split('?') #remove extra query string parameters levels = url[0].split('/') #break up url into different levels levels.each_with_index do |level, index| unless level.blank? - if index == levels.size-1 || - (level == levels[levels.size-2] && levels[levels.size-1].to_i > 0) + next if "/#{level}" == Sinatra::UrlForHelper::DEFAULT_URI_PREFIX + if index == levels.size-1 || (level == levels[levels.size-2] && levels[levels.size-1].to_i > 0) s += "<li class='subsequent'>#{level.gsub(/_/, ' ')}</li>\n" unless level.to_i > 0 else - link = levels.slice(0, index+1).join("/") - s += "<li class='subsequent'><a href=\"#{url_for(link)}\">#{level.gsub(/_/, ' ')}</a></li>\n" + link = levels.slice(2, index-1).join("/") + s += "<li class='subsequent'><a href=\"#{api_url_for(link)}\">#{level.gsub(/_/, ' ')}</a></li>\n" end end end @@ -182,19 +182,20 @@ module ApplicationHelper def link_to_documentation return '' unless request.env['REQUEST_URI'] uri = request.env['REQUEST_URI'].dup - uri.gsub!('/api', '/api/docs/') unless uri.include?("docs") #i.e. if already serving under /api/docs, leave it be + uri.gsub!(Sinatra::UrlForHelper::DEFAULT_URI_PREFIX, + api_url_for(:docs)) unless uri.include?("docs") #i.e. if already serving under /api/docs, leave it be '<a href="%s">[ Documentation ]</a>' % uri end def action_url if [:index].include?(@operation.name) - url_for("/api/#{@collection.name.to_s}") + api_url_for("#{@collection.name.to_s}") elsif [:show, :stop, :start, :reboot, :attach, :detach].include?(@operation.name) - url_for("/api/#{@collection.name.to_s}/:id/#{@operation.name}") + api_url_for("#{@collection.name.to_s}/:id/#{@operation.name}") elsif [:destroy].include?(@operation.name) - url_for("/api/#{@collection.name.to_s}/:id") + api_url_for("#{@collection.name.to_s}/:id") else - url_for("/api/#{@collection.name}/#{@operation.name}") + api_url_for("#{@collection.name}/#{@operation.name}") end end diff --git a/server/lib/deltacloud/models/bucket.rb b/server/lib/deltacloud/models/bucket.rb index 304fc0b..e6b2b34 100644 --- a/server/lib/deltacloud/models/bucket.rb +++ b/server/lib/deltacloud/models/bucket.rb @@ -24,7 +24,8 @@ class Bucket < BaseModel def to_hash h = self.to_hash_original - h[:blob_list] = self.blob_list.collect { |blob| { :id => blob, :href => "/api/buckets/#{self.id}/#{blob.id}"}} + h[:blob_list] = self.blob_list.collect { |blob| { :id => blob, + :href => "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/buckets/#{self.id}/#{blob.id}"}} return h end end diff --git a/server/lib/deltacloud/models/image.rb b/server/lib/deltacloud/models/image.rb index ca75717..91e1060 100644 --- a/server/lib/deltacloud/models/image.rb +++ b/server/lib/deltacloud/models/image.rb @@ -30,7 +30,7 @@ class Image < BaseModel h.merge({ :actions => [ :create_instance => { :method => 'post', - :href => "/api/instances;image_id=#{self.id}" # FIXME: Figure out how instances_url should be called here + :href => "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/instances;image_id=#{self.id}" }] }) end diff --git a/server/lib/sinatra/rabbit.rb b/server/lib/sinatra/rabbit.rb index 3d40112..3f40914 100644 --- a/server/lib/sinatra/rabbit.rb +++ b/server/lib/sinatra/rabbit.rb @@ -80,7 +80,7 @@ module Sinatra def generate_documentation coll, oper = @collection, self - ::Sinatra::Application.get("/api/docs/#{@collection.name}/#{@name}") do + ::Sinatra::Application.get("#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/docs/#{@collection.name}/#{@name}") do @collection, @operation = coll, oper @features = driver.features_for_operation(coll.name, oper.name) respond_to do |format| @@ -92,7 +92,7 @@ module Sinatra def generate_options current_operation = self - ::Sinatra::Application.options("/api/#{current_operation.collection.name}/#{current_operation.name}") do + ::Sinatra::Application.options("#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/#{current_operation.collection.name}/#{current_operation.name}") do required_params = current_operation.effective_params(driver).collect do |name, validation| name.to_s if validation.type.eql?(:required) end.compact.join(',') @@ -115,26 +115,20 @@ module Sinatra end end - def prefix - # FIXME: Make the /api prefix configurable - "/api" - end - def path(args = {}) - l_prefix = args[:prefix] || prefix if @member if standard? - "#{l_prefix}/#{@collection.name}/:id" + "#{@collection.name}/:id" else - "#{l_prefix}/#{@collection.name}/:id/#{name}" + "#{@collection.name}/:id/#{name}" end else - "#{l_prefix}/#{@collection.name}" + "#{@collection.name}" end end def generate - ::Sinatra::Application.send(@method, path, {}, &@control) + ::Sinatra::Application.send(@method, "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/#{path}", {}, &@control) # Set up some Rails-like URL helpers if name == :index gen_route "#{@collection.name}_url" @@ -169,12 +163,12 @@ module Sinatra if @member ::Sinatra::Application.send(:define_method, name) do |id, *args| url = query_url(route_url, args[0]) - url_for url.gsub(/:id/, id.to_s), :full + api_url_for url.gsub(/:id/, id.to_s), :full end else ::Sinatra::Application.send(:define_method, name) do |*args| url = query_url(route_url, args[0]) - url_for url, :full + api_url_for url, :full end end end @@ -216,7 +210,7 @@ module Sinatra def generate_head current_collection = self - ::Sinatra::Application.head("/api/#{name}") do + ::Sinatra::Application.head("#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/#{name}") do methods_allowed = current_collection.operations.collect { |o| o[1].method.to_s.upcase }.uniq.join(',') headers 'Allow' => "HEAD,OPTIONS,#{methods_allowed}" [200, ''] @@ -225,7 +219,7 @@ module Sinatra def generate_options current_collection = self - ::Sinatra::Application.options("/api/#{name}") do + ::Sinatra::Application.options("#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/#{name}") do operations_allowed = current_collection.operations.collect { |o| o[0] }.join(',') headers 'X-Operations-Allowed' => operations_allowed [200, ''] @@ -234,7 +228,7 @@ module Sinatra def generate_documentation coll = self - ::Sinatra::Application.get("/api/docs/#{@name}") do + ::Sinatra::Application.get("#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/docs/#{@name}") do coll.check_supported(driver) @collection = coll @operations = coll.operations @@ -271,12 +265,12 @@ module Sinatra app = ::Sinatra::Application collname = name # Work around Ruby's weird scoping/capture app.send(:define_method, "#{name.to_s.singularize}_url") do |id| - url_for "/api/#{collname}/#{id}", :full + api_url_for "#{collname}/#{id}", :full end if index_op = operations[:index] app.send(:define_method, "#{name}_url") do - url_for index_op.path.gsub(/\/\?$/,''), :full + api_url_for index_op.path.gsub(/\/\?$/,''), :full end end end @@ -304,7 +298,7 @@ module Sinatra end # Generate a root route for API docs - get '/api/docs\/?' do + get "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/docs\/?" do respond_to do |format| format.html { haml :'docs/index' } format.xml { haml :'docs/index' } @@ -323,7 +317,7 @@ module Sinatra collections.values.select { |coll| coll.global? || driver.has_collection?(coll.name) }.inject([]) do |m, coll| - url = url_for coll.operations[:index].path, :full + url = api_url_for coll.operations[:index].path, :full m << [ coll.name, url ] end end diff --git a/server/server.rb b/server/server.rb index 86dd524..7d28f23 100644 --- a/server/server.rb +++ b/server/server.rb @@ -64,9 +64,9 @@ end Sinatra::Application.register Sinatra::RespondTo # Redirect to /api -get '/' do redirect url_for('/api'), 301; end +get '/' do redirect root_url, 301; end -get '/api\/?' do +get "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}\/?" do if params[:force_auth] return [401, 'Authentication failed'] unless driver.valid_credentials?(credentials) end @@ -156,7 +156,7 @@ END end -get "/api/images/new" do +get "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/images/new" do @instance = Instance.new( :id => params[:instance_id] ) respond_to do |format| format.html { haml :"images/new" } @@ -255,7 +255,7 @@ collection :instance_states do end end -get "/api/instances/new" do +get "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/instances/new" do @instance = Instance.new( { :id=>params[:id], :image_id=>params[:image_id] } ) @image = driver.image( credentials, :id => params[:image_id] ) @hardware_profiles = driver.hardware_profiles(credentials, :architecture => @image.architecture ) @@ -269,14 +269,14 @@ get "/api/instances/new" do end end -get '/api/instances/:id/run' do +get "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/instances/:id/run" do @instance = driver.instance(credentials, :id => params[:id]) respond_to do |format| format.html { haml :"instances/run_command" } end end -get '/api/load_balancers/new' do +get "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/load_balancers/new" do @realms = driver.realms(credentials) @instances = driver.instances(credentials) if driver_has_feature?(:register_instance, :load_balancers) respond_to do |format| @@ -493,7 +493,7 @@ END end -get '/api/storage_snapshots/new' do +get "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/storage_snapshots/new" do respond_to do |format| format.html { haml :"storage_snapshots/new" } end @@ -542,13 +542,13 @@ collection :storage_snapshots do end end -get '/api/storage_volumes/new' do +get "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/storage_volumes/new" do respond_to do |format| format.html { haml :"storage_volumes/new" } end end -get '/api/storage_volumes/attach' do +get "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/storage_volumes/attach" do respond_to do |format| @instances = driver.instances(credentials) format.html { haml :"storage_volumes/attach" } @@ -631,7 +631,7 @@ collection :storage_volumes do end -get '/api/keys/new' do +get "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/keys/new" do respond_to do |format| format.html { haml :"keys/new" } end @@ -689,7 +689,7 @@ collection :keys do end #get html form for creating a new blob -get '/api/buckets/:bucket/new_blob' do +get "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/buckets/:bucket/new_blob" do @bucket_id = params[:bucket] respond_to do |format| format.html {haml :"blobs/new"} @@ -697,7 +697,7 @@ get '/api/buckets/:bucket/new_blob' do end #create a new blob -post '/api/buckets/:bucket' do +post "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/buckets/:bucket" do bucket_id = params[:bucket] blob_id = params['blob_id'] blob_data = params['blob_data'] @@ -723,7 +723,7 @@ post '/api/buckets/:bucket' do end #delete a blob -delete '/api/buckets/:bucket/:blob' do +delete "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/buckets/:bucket/:blob" do bucket_id = params[:bucket] blob_id = params[:blob] driver.delete_blob(credentials, bucket_id, blob_id) @@ -735,7 +735,7 @@ delete '/api/buckets/:bucket/:blob' do end #get blob metadata -head '/api/buckets/:bucket/:blob' do +head "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/buckets/:bucket/:blob" do @blob_id = params[:blob] @blob_metadata = driver.blob_metadata(credentials, {:id => params[:blob], 'bucket' => params[:bucket]}) if @blob_metadata @@ -748,7 +748,7 @@ head '/api/buckets/:bucket/:blob' do end #update blob metadata -post '/api/buckets/:bucket/:blob' do +post "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/buckets/:bucket/:blob" do meta_hash = {} request.env.inject({}){|current, (k,v)| meta_hash[k] = v if k.match(/^HTTP[-_]X[-_]Deltacloud[-_]Blobmeta[-_]/i)} success = driver.update_blob_metadata(credentials, {'bucket'=>params[:bucket], :id =>params[:blob], 'meta_hash' => meta_hash}) @@ -762,7 +762,7 @@ post '/api/buckets/:bucket/:blob' do end #Get a particular blob's particulars (not actual blob data) -get '/api/buckets/:bucket/:blob' do +get "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/buckets/:bucket/:blob" do @blob = driver.blob(credentials, { :id => params[:blob], 'bucket' => params[:bucket]}) if @blob respond_to do |format| @@ -776,7 +776,7 @@ get '/api/buckets/:bucket/:blob' do end #get the content of a particular blob -get '/api/buckets/:bucket/:blob/content' do +get "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/buckets/:bucket/:blob/content" do @blob = driver.blob(credentials, { :id => params[:blob], 'bucket' => params[:bucket]}) if @blob params['content_length'] = @blob.content_length @@ -789,7 +789,7 @@ get '/api/buckets/:bucket/:blob/content' do end #Get html form for creating a new bucket -get '/api/buckets/new' do +get "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/buckets/new" do respond_to do |format| format.html { haml :"buckets/new" } end @@ -853,7 +853,7 @@ collection :buckets do end -get '/api/addresses/:id/associate' do +get "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/addresses/:id/associate" do @instances = driver.instances(credentials) @address = Address::new(:id => params[:id]) respond_to do |format| diff --git a/server/views/api/show.html.haml b/server/views/api/show.html.haml index 287b989..3dc387d 100644 --- a/server/views/api/show.html.haml +++ b/server/views/api/show.html.haml @@ -4,7 +4,7 @@ %ul - @collections.sort_by { |k| k.to_s }.each do |key| %li - = link_to key.to_s.gsub('_', ' ').titlecase, url_for("/api/#{key}") + = link_to key.to_s.gsub('_', ' ').titlecase, api_url_for(key) %dl - collections[key].operations.each_key do |op| - next if [:index, :show].include?(op) diff --git a/server/views/buckets/index.html.haml b/server/views/buckets/index.html.haml index 5acc5f6..1cf5d6a 100644 --- a/server/views/buckets/index.html.haml +++ b/server/views/buckets/index.html.haml @@ -2,7 +2,7 @@ Buckets %br %p - =link_to 'Create new bucket', "/api/buckets/new" + =link_to 'Create new bucket', api_url_for("buckets/new") %table.display %thead diff --git a/server/views/buckets/show.html.haml b/server/views/buckets/show.html.haml index 28f2476..0335217 100644 --- a/server/views/buckets/show.html.haml +++ b/server/views/buckets/show.html.haml @@ -20,4 +20,4 @@ %dt Delete bucket (must be empty) %dd -if @bucket.size == 0 - =link_to_action 'Delete', destroy_bucket_url(@bucket.name), :delete \ No newline at end of file + =link_to_action 'Delete', destroy_bucket_url(@bucket.name), :delete diff --git a/server/views/docs/collection.html.haml b/server/views/docs/collection.html.haml index 505cbde..fb0babd 100644 --- a/server/views/docs/collection.html.haml +++ b/server/views/docs/collection.html.haml @@ -16,7 +16,7 @@ - @operations.keys.sort_by { |k| k.to_s }.each do |operation| %tr %td{:style => "width:15em"} - %a{:href => url_for("/api/docs/#{@collection.name.to_s}/#{operation}")} #{operation} + %a{:href => api_url_for("docs/#{@collection.name.to_s}/#{operation}")} #{operation} %td{:style => "width:10em"} #{@operations[operation].description} %h3 Features: @@ -34,4 +34,4 @@ %td= feature.description %td - feature.operations.each do |op| - %a{:href => url_for("/api/docs/#{@collection.name.to_s}/#{op.name}")} #{op.name} + %a{:href => api_url_for("docs/#{@collection.name.to_s}/#{op.name}")} #{op.name} diff --git a/server/views/docs/collection.xml.haml b/server/views/docs/collection.xml.haml index a82d4e1..8525f45 100644 --- a/server/views/docs/collection.xml.haml +++ b/server/views/docs/collection.xml.haml @@ -1,9 +1,9 @@ %docs{:status => "unsupported"} - %collection{:url => url_for("/api/docs/#{@collection.name}"), :name => "#{@collection.name}"} + %collection{:url => api_url_for("docs/#{@collection.name}"), :name => "#{@collection.name}"} %description #{@collection.description} %operations - @operations.keys.sort_by { |k| k.to_s }.each do |operation| - %operation{:url => url_for("/api/#{@collection.name.to_s}"), :name => "#{operation}", :href => url_for("#{@operations[operation].path}"), :method => "#{@operations[operation].method}"} + %operation{:url => api_url_for("#{@collection.name.to_s}"), :name => "#{operation}", :href => api_url_for("#{@operations[operation].path}"), :method => "#{@operations[operation].method}"} %description #{@operations[operation].description} - @operations[operation].each_param do |param| %parameter{:name => "#{param.name}", :type => "#{param.type}"} diff --git a/server/views/docs/index.html.haml b/server/views/docs/index.html.haml index 66d56e7..a2a68f1 100644 --- a/server/views/docs/index.html.haml +++ b/server/views/docs/index.html.haml @@ -11,5 +11,5 @@ - collections.keys.sort_by { |k| k.to_s }.each do |collection| %tr %td{:style => "width:15em"} - %a{:href => url_for("/api/docs/#{collection}")} #{collection} + %a{:href => api_url_for("docs/#{collection}")} #{collection} %td{:style => "width:10em"} #{collections[collection].description} diff --git a/server/views/docs/index.xml.haml b/server/views/docs/index.xml.haml index 4edcf9a..c953c33 100644 --- a/server/views/docs/index.xml.haml +++ b/server/views/docs/index.xml.haml @@ -1,5 +1,5 @@ %docs{:status => "unsupported"} - collections.keys.sort_by { |k| k.to_s }.each do |collection| - %collection{:url => url_for("/api/docs/#{collection}")} + %collection{:url => api_url_for("docs/#{collection}")} %name #{collection} %description #{collections[collection].description} diff --git a/server/views/docs/operation.xml.haml b/server/views/docs/operation.xml.haml index 189ef47..fcc9c59 100644 --- a/server/views/docs/operation.xml.haml +++ b/server/views/docs/operation.xml.haml @@ -1,5 +1,5 @@ %docs{:status => "unsupported"} - %operation{:url => url_for("/api/docs/#{@collection.name.to_s}"), :name => "#{@operation.name.to_s}", :href => url_for("#{@operation.path}"), :method => "#{@operation.method}"} + %operation{:url => api_url_for("docs/#{@collection.name.to_s}"), :name => "#{@operation.name.to_s}", :href => url_for("#{@operation.path}"), :method => "#{@operation.method}"} %description #{@operation.description} - @operation.each_param do |param| %parameter{:name => "#{param.name}", :type => "#{param.type}"} diff --git a/server/views/images/show.html.haml b/server/views/images/show.html.haml index 93a9a7d..752952b 100644 --- a/server/views/images/show.html.haml +++ b/server/views/images/show.html.haml @@ -18,4 +18,4 @@ = @image.description %dt %dd - = link_to 'Launch', "/api/instances/new?image_id=#{@image.id}" + = link_to 'Launch', api_url_for("instances/new?image_id=#{@image.id}") diff --git a/server/views/instance_states/show.html.haml b/server/views/instance_states/show.html.haml index 21c6343..6d80d92 100644 --- a/server/views/instance_states/show.html.haml +++ b/server/views/instance_states/show.html.haml @@ -1,7 +1,7 @@ %h1 Instance States %div#state_graph - = image_tag url_for( '/api/instance_states?format=png' ) + = image_tag api_url_for('instance_states?format=png') %table.states %thead diff --git a/server/views/instances/index.html.haml b/server/views/instances/index.html.haml index d0ada19..6bc9f9e 100644 --- a/server/views/instances/index.html.haml +++ b/server/views/instances/index.html.haml @@ -16,7 +16,7 @@ %td = link_to truncate_words(instance.id), instance_url( instance.id ) %td - = link_to instance.owner_id, images_url + = link_to instance.owner_id, instances_url + "?owner_id=#{instance.owner_id}" %td = instance.name %td @@ -29,4 +29,4 @@ -instance.actions.each do |action| =link_to_action action, self.send(:"#{action}_instance_url", instance.id), instance_action_method(action) - if driver.respond_to?(:run_on_instance) and instance.state=="RUNNING" - =link_to_action "Run command", url_for("/api/instances/#{instance.id}/run"), :get + =link_to_action "Run command", api_url_for("instances/#{instance.id}/run"), :get diff --git a/server/views/instances/show.html.haml b/server/views/instances/show.html.haml index 4b44e8f..6c53bde 100644 --- a/server/views/instances/show.html.haml +++ b/server/views/instances/show.html.haml @@ -58,5 +58,5 @@ %dt %dd - if @instance.can_create_image? - =link_to_action 'Create Image', url_for("/api/images/new?instance_id=#{@instance.id}"), :get + =link_to_action 'Create Image', api_url_for("images/new?instance_id=#{@instance.id}"), :get diff --git a/server/views/keys/index.html.haml b/server/views/keys/index.html.haml index 6f246a4..a1b3628 100644 --- a/server/views/keys/index.html.haml +++ b/server/views/keys/index.html.haml @@ -23,4 +23,4 @@ - if driver.respond_to?(:create_key) %tr %td{:colspan => 3, :style => "text-align:right;"} - =link_to 'Create »', "#{url_for('/api/keys/new')}", :class => 'button' + =link_to 'Create »', "#{api_url_for('keys/new')}", :class => 'button' diff --git a/server/views/keys/new.html.haml b/server/views/keys/new.html.haml index 7a10a5e..b64056e 100644 --- a/server/views/keys/new.html.haml +++ b/server/views/keys/new.html.haml @@ -1,6 +1,6 @@ %h1 New key -%form{ :action => '/api/keys', :method => :post } +%form{ :action => keys_url, :method => :post } %p %label Name: diff --git a/server/views/load_balancers/index.html.haml b/server/views/load_balancers/index.html.haml index f75b1c6..dca84c1 100644 --- a/server/views/load_balancers/index.html.haml +++ b/server/views/load_balancers/index.html.haml @@ -29,5 +29,5 @@ %tfoot %tr %td{:colspan => 6, :style => "text-align:right;"} - =link_to 'Create »', "#{url_for('/api/load_balancers/new')}", :class => 'button' + =link_to 'Create »', "#{api_url_for('load_balancers/new')}", :class => 'button' diff --git a/server/views/load_balancers/new.html.haml b/server/views/load_balancers/new.html.haml index 58a89f7..4685b69 100644 --- a/server/views/load_balancers/new.html.haml +++ b/server/views/load_balancers/new.html.haml @@ -1,6 +1,6 @@ %h1 New Load Balancer -%form{ :action => '/api/load_balancers', :method => :post } +%form{ :action => load_balancers_url, :method => :post } %p %label Name: diff --git a/server/views/load_balancers/show.html.haml b/server/views/load_balancers/show.html.haml index 074ec8c..4c95dc2 100644 --- a/server/views/load_balancers/show.html.haml +++ b/server/views/load_balancers/show.html.haml @@ -27,7 +27,7 @@ =inst.id =link_to_action 'Delete', unregister_load_balancer_url(@load_balancer.id, :instance_id => inst.id), :post -%form{:action => url_for("/api/load_balancers/#{@load_balancer.id}/register"), :method => :post} +%form{:action => api_url_for("load_balancers/#{@load_balancer.id}/register"), :method => :post} %p %strong Add instances to load balancer %p diff --git a/server/views/storage_snapshots/new.html.haml b/server/views/storage_snapshots/new.html.haml index 8e7d6f8..c211672 100644 --- a/server/views/storage_snapshots/new.html.haml +++ b/server/views/storage_snapshots/new.html.haml @@ -1,6 +1,6 @@ %h1 Create new storage volume snapshot -%form{ :action => '/api/storage_snapshots', :method => :post } +%form{ :action => storage_snapshots_url, :method => :post } %p %label Volume ID: diff --git a/server/views/storage_volumes/index.html.haml b/server/views/storage_volumes/index.html.haml index 6f116fd..372dcc7 100644 --- a/server/views/storage_volumes/index.html.haml +++ b/server/views/storage_volumes/index.html.haml @@ -24,13 +24,13 @@ = "#{volume.state}" %td - if ["AVAILABLE", "IN-USE"].include?(volume.state) - =link_to_action "Snaphot", url_for("/api/storage_snapshots/new?volume_id=#{volume.id}"), :get + =link_to_action "Snaphot", api_url_for("storage_snapshots/new?volume_id=#{volume.id}"), :get - unless volume.instance_id =link_to_action "Delete", destroy_storage_volume_url(volume.id), :delete - =link_to_action "Attach", url_for("/api/storage_volumes/attach?id=#{volume.id}"), :get + =link_to_action "Attach", api_url_for("storage_volumes/attach?id=#{volume.id}"), :get - if volume.instance_id =link_to_action "Detach", detach_storage_volume_url(volume.id), :post %tfoot %tr %td{:colspan => 6} - %a{ :href => url_for("/api/storage_volumes/new")} Create volume + %a{ :href => api_url_for("storage_volumes/new")} Create volume diff --git a/server/views/storage_volumes/new.html.haml b/server/views/storage_volumes/new.html.haml index f8ab6b8..7cbcf2b 100644 --- a/server/views/storage_volumes/new.html.haml +++ b/server/views/storage_volumes/new.html.haml @@ -1,6 +1,6 @@ %h1 Create new storage volume -%form{ :action => '/api/storage_volumes', :method => :post } +%form{ :action => storage_volumes_url, :method => :post } %p %label Snapshot ID: -- 1.7.4.1
