From 7166d35d6bb3d3441e20937b644cbfa52e72761a Mon Sep 17 00:00:00 2001 From: Cody Herriges Date: Sat, 12 Feb 2011 03:02:09 +0800 Subject: [PATCH 1/2] [aws] One line change to be able to delete AWS tag I have know idea if that was intentional but with that action set the method does not delete tags. Setting it to the DeleteTags action does. --- lib/fog/compute/requests/aws/delete_tags.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/compute/requests/aws/delete_tags.rb b/lib/fog/compute/requests/aws/delete_tags.rb index 43dcf2f21..a3c3e591d 100644 --- a/lib/fog/compute/requests/aws/delete_tags.rb +++ b/lib/fog/compute/requests/aws/delete_tags.rb @@ -26,7 +26,7 @@ module Fog params.merge!(AWS.indexed_param('Tag.%d.Key', tags.keys)) params.merge!(AWS.indexed_param('Tag.%d.Value', tags.values)) request({ - 'Action' => 'CreateTags', + 'Action' => 'DeleteTags', :parser => Fog::Parsers::AWS::Compute::Basic.new }.merge!(params)) end From 57b25e5645162ac5c0e1008194dd978631ba8f21 Mon Sep 17 00:00:00 2001 From: Viven Date: Wed, 9 Feb 2011 20:36:12 +0800 Subject: [PATCH 2/2] Temporary redirect should not execute the block --- lib/fog/storage/aws.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/fog/storage/aws.rb b/lib/fog/storage/aws.rb index e4675fcea..ce050f83e 100644 --- a/lib/fog/storage/aws.rb +++ b/lib/fog/storage/aws.rb @@ -337,20 +337,19 @@ DATA signature = Base64.encode64(signed_string).chomp! end - private def request(params, &block) params[:headers]['Date'] = Fog::Time.now.to_date_header params[:headers]['Authorization'] = "AWS #{@aws_access_key_id}:#{signature(params)}" - params[:expects] = [307, *params[:expects]].flatten + # FIXME: ToHashParser should make this not needed original_params = params.dup - response = @connection.request(params, &block) - - if response.status == 307 - uri = URI.parse(response.headers['Location']) + begin + response = @connection.request(params, &block) + rescue Excon::Errors::TemporaryRedirect => error + uri = URI.parse(error.response.headers['Location']) Formatador.display_line("[yellow][WARN] fog: followed redirect to #{uri.host}, connecting to the matching region will be more performant[/]") response = Fog::Connection.new("#{@scheme}://#{uri.host}:#{@port}", false).request(original_params, &block) end