Skip to content

Commit

Permalink
#1381: Add UCSB-contributed patch for paths other than '/' in the EC2…
Browse files Browse the repository at this point in the history
… service endpoint. This allows use of RightAws with Eucalyptus.

git-svn-id: https://wush.net/svn/rightscale/right_aws/trunk@4534 9f0cbaf6-ce18-0410-ad37-d14a22affa91
  • Loading branch information
trbryan committed Jul 3, 2008
1 parent 7ecb2f7 commit df06c54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/awsbase/right_awsbase.rb
Expand Up @@ -132,6 +132,7 @@ def init(service_info, aws_access_key_id, aws_secret_access_key, params={}) #:no
@aws_secret_access_key = aws_secret_access_key
@params[:server] ||= service_info[:default_host]
@params[:port] ||= service_info[:default_port]
@params[:service] ||= service_info[:default_service]
@params[:protocol] ||= service_info[:default_protocol]
@params[:multi_thread] ||= defined?(AWS_DAEMON)
@logger = @params[:logger]
Expand Down
6 changes: 4 additions & 2 deletions lib/ec2/right_ec2.rb
Expand Up @@ -69,6 +69,7 @@ class Ec2 < RightAwsBase
# Amazon EC2 API version being used
API_VERSION = "2008-02-01"
DEFAULT_HOST = "ec2.amazonaws.com"
DEFAULT_PATH = '/'
DEFAULT_PROTOCOL = 'https'
DEFAULT_PORT = 443

Expand Down Expand Up @@ -108,7 +109,8 @@ def self.api
def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
init({ :name => 'EC2',
:default_host => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).host : DEFAULT_HOST,
:default_port => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).port : DEFAULT_PORT,
:default_port => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).port : DEFAULT_PORT,
:default_service => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).path : DEFAULT_PATH,
:default_protocol => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).scheme : DEFAULT_PROTOCOL },
aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'] ,
aws_secret_access_key|| ENV['AWS_SECRET_ACCESS_KEY'],
Expand All @@ -130,7 +132,7 @@ def generate_request(action, params={}) #:nodoc:
end
service_hash.update('Signature' => AwsUtils::sign(@aws_secret_access_key, string_to_sign))
request_params = service_hash.to_a.collect{|key,val| key + "=" + CGI::escape(val) }.join("&")
request = Net::HTTP::Get.new("/?#{request_params}")
request = Net::HTTP::Get.new("#{@params[:service]}?#{request_params}")
# prepare output hash
{ :request => request,
:server => @params[:server],
Expand Down

0 comments on commit df06c54

Please sign in to comment.