incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michal Fojtik <mfoj...@redhat.com>
Subject Re: [PATCH] dynamic driver switching for eucalyptus
Date Thu, 07 Apr 2011 11:38:39 GMT
On Apr 7, 2011, at 8:57 AM, sang-min.park@eucalyptus.com wrote:

ACK.

  -- Michal

> From: Sang-Min Park <spark@eucalyptus.com>
> 
> ---
> server/lib/deltacloud/drivers/ec2/ec2_driver.rb    |    2 +
> .../drivers/eucalyptus/eucalyptus_driver.rb        |   25 ++++++++++++++-----
> 2 files changed, 20 insertions(+), 7 deletions(-)
> 
> diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
> index 302aac2..2a2d092 100644
> --- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
> +++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
> @@ -539,6 +539,8 @@ module Deltacloud
>         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.
> diff --git a/server/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb b/server/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb
> index 59db7e6..413f206 100644
> --- a/server/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb
> +++ b/server/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb
> @@ -141,13 +141,24 @@ module Deltacloud
> 
>         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}
> -- 
> 1.7.1
> 

------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org


Mime
View raw message