Permalink
Browse files

Merge branch 'eucalyptus_compatible' of https://github.com/sangmin/am…

…azon-ec2 into sangmin-eucalyptus_compatible
  • Loading branch information...
2 parents 098e528 + f125f76 commit bfd4a2e9a7552d02fcde67646c9e2a1d7e42670b @grempe grempe committed Nov 21, 2010
Showing with 15 additions and 3 deletions.
  1. +11 −1 bin/setup.rb
  2. +4 −2 lib/AWS.rb
View
12 bin/setup.rb
@@ -17,7 +17,17 @@
}
if ENV['EC2_URL']
- opts[:server] = URI.parse(ENV['EC2_URL']).host
+ ec2uri = URI.parse(ENV['EC2_URL'])
+ opts[:server] = ec2uri.host
+ if ec2uri.path.downcase.include?("eucalyptus")
+ opts[:path] = ec2uri.path
+ opts[:port] = ec2uri.port
+ if ec2uri.class == URI::HTTPS
+ opts[:use_ssl] = true
+ else
+ opts[:use_ssl] = false
+ end
+ end
@ec2 = AWS::EC2::Base.new(opts)
else
@ec2 = AWS::EC2::Base.new(opts)
View
6 lib/AWS.rb
@@ -126,12 +126,14 @@ def initialize( options = {} )
:secret_access_key => "",
:use_ssl => true,
:server => default_host,
+ :path => "/",
:proxy_server => nil
}.merge(options)
@server = options[:server]
@proxy_server = options[:proxy_server]
@use_ssl = options[:use_ssl]
+ @path = options[:path]
raise ArgumentError, "No :access_key_id provided" if options[:access_key_id].nil? || options[:access_key_id].empty?
raise ArgumentError, "No :secret_access_key provided" if options[:secret_access_key].nil? || options[:secret_access_key].empty?
@@ -287,7 +289,7 @@ def make_request(action, params, data='')
CGI::escape(param[0]) + "=" + CGI::escape(param[1])
end.join("&") + "&Signature=" + sig
- req = Net::HTTP::Post.new("/")
+ req = Net::HTTP::Post.new(@path)
req.content_type = 'application/x-www-form-urlencoded'
req['User-Agent'] = "github-amazon-ec2-ruby-gem"
@@ -304,7 +306,7 @@ def make_request(action, params, data='')
# Set the Authorization header using AWS signed header authentication
def get_aws_auth_param(params, secret_access_key, server)
- canonical_string = AWS.canonical_string(params, server)
+ canonical_string = AWS.canonical_string(params, server,"POST", @path)
encoded_canonical = AWS.encode(secret_access_key, canonical_string)
end

0 comments on commit bfd4a2e

Please sign in to comment.