incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@redhat.com
Subject [PATCH 1/2] Adds streaming PUT blob for rax (initialise the http,request objects for use with the BlobStreamIO class)
Date Thu, 16 Jun 2011 16:21:11 GMT
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"
+    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


Mime
View raw message