Skip to content

Commit

Permalink
dynamic driver switching for eucalyptus
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/incubator/deltacloud/trunk@1090218 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mfojtik committed Apr 8, 2011
1 parent d462c9b commit 4027730
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions server/lib/deltacloud/drivers/ec2/ec2_driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ def tagging?
end

def endpoint_for_service(service)
ENV['EC2_URL']='' # unset endpoints that may have been set by eucalyptus; otherwise it can conflict with the EC2/S3 endpoints in aws gem.
ENV['S3_URL']=''
endpoint = (Thread.current[:provider] || ENV['API_PROVIDER'] || DEFAULT_REGION)
# return the endpoint if it does not map to a default endpoint, allowing
# the endpoint to be a full hostname instead of a region.
Expand Down
25 changes: 18 additions & 7 deletions server/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,24 @@ def new_client(credentials, type = :ec2)

def eucalyptus_endpoint
endpoint = (Thread.current[:provider] || ENV['API_PROVIDER'])
#parse endpoint string into server, port, service, and protocol
if endpoint
{:server => URI.parse(endpoint).host,
:port => URI.parse(endpoint).port,
:service => URI.parse(endpoint).path,
:protocol => URI.parse(endpoint).scheme,
:connection_mode => :per_thread}
if endpoint && (endpoint.include?('ec2') || endpoint.include?('s3')) # example endpoint: 'ec2=192.168.1.1; s3=192.168.1.2'
default_port=8773
endpoint.split(';').each do |svc_addr|
addr = svc_addr.sub('ec2=','').sub('s3=','').strip
if addr.include?(':')
host = addr.split(':')[0]
port = addr.split(':')[1]
else
host = addr
port = default_port
end
if svc_addr.include?('ec2')
ENV['EC2_URL'] = "http://#{host}:#{port}/services/Eucalyptus"
elsif svc_addr.include?('s3')
ENV['S3_URL'] = "http://#{host}:#{port}/services/Walrus"
end
end
{}
else
#EC2_URL/S3_URL env variable will be used by AWS
{:connection_mode => :per_thread}
Expand Down

0 comments on commit 4027730

Please sign in to comment.