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 1/2] Adds streaming PUT blob for rax (initialise the http,request objects for use with the BlobStreamIO class)
Date Mon, 20 Jun 2011 08:07:58 GMT
On Jun 16, 2011, at 6:21 PM, marios@redhat.com wrote:

ACK.

(one stylistic inliner ;-)

  -- Michal

> From: marios <marios@redhat.com>
> 
> 
> Signed-off-by: marios <marios@redhat.com>
> ---
> .../drivers/rackspace/rackspace_driver.rb          |   28 ++++++++++++++++++++
> 1 files changed, 28 insertions(+), 0 deletions(-)
> 
> diff --git a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
> index d09e0de..c8bf0b2 100644
> --- a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
> +++ b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
> @@ -318,6 +318,34 @@ class RackspaceDriver < Deltacloud::BaseDriver
>     end
>   end
> 
> +  #params: {:user,:password,:bucket,:blob,:content_type,:content_length,:metadata}
> +  def blob_stream_connection(params)
> +    #create a cloudfiles connection object to get the authtoken
> +    cf, cf_host, cf_path, cf_authtoken = nil
> +    safely do
> +      cf = CloudFiles::Connection.new(:username => params[:user],
> +                                :api_key => params[:password])
> +      cf_authtoken = cf.authtoken
> +      cf_host = cf.storagehost
> +      cf_path = cf.storagepath
> +    end
> +    provider = "https://#{cf_host}"
> +    uri = URI.parse(provider)
> +    http = Net::HTTP.new(uri.host, uri.port )
> +    http.use_ssl = true
> +    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
> +    request = Net::HTTP::Put.new("#{cf_path}/#{params[:bucket]}/#{params[:blob]}")
> +    request['Host'] = "#{cf_host}"
> +    request['X-Auth-Token'] = "#{cf_authtoken}"
> +    request['Content-Type'] = params[:content_type]
> +    request['Content-Length'] = params[:content_length]
> +    request['Expect'] = "100-continue"

This syntax:

request = {
  'Host' => #{cf_host},
  'X-Auth-Token' => #{cf_authtoken},
  'Content-Type' => params[:content_type],
  'Content-Length' => params[:content_length],
  'Expect' => '100-continue'
}

looks better for me, but this is just stylistic stuff, your code is perfectly OK.

> +    metadata = params[:metadata] || {}
> +    BlobHelper::rename_metadata_headers(metadata, 'X-Object-Meta-')
> +    metadata.each{|k,v| request[k] = v}
> +    return http, request
> +  end
> +
> private
> 
> 
> -- 
> 1.7.3.4
> 

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


Mime
View raw message