incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@redhat.com
Subject [PATCH] Adds create_blob and delete_blob for the Microsoft Azure driver
Date Thu, 02 Dec 2010 17:08:55 GMT
From: marios <marios@redhat.com>

---
 .../lib/deltacloud/drivers/azure/azure_driver.rb   |   33 +++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/server/lib/deltacloud/drivers/azure/azure_driver.rb b/server/lib/deltacloud/drivers/azure/azure_driver.rb
index c197214..9342823 100644
--- a/server/lib/deltacloud/drivers/azure/azure_driver.rb
+++ b/server/lib/deltacloud/drivers/azure/azure_driver.rb
@@ -17,8 +17,9 @@
 # under the License.
 
 #Windows Azure (WAZ) gem at http://github.com/johnnyhalife/waz-storage
-require 'waz-blobs'
 require 'deltacloud/base_driver'
+require 'waz-blobs'
+
 module Deltacloud
   module Drivers
     module Azure
@@ -46,6 +47,9 @@ class AzureDriver < Deltacloud::BaseDriver
 # Create bucket
 #--
   def create_bucket(credentials, name, opts)
+    #for whatever reason, bucket names MUST be lowercase... 
+    #http://msdn.microsoft.com/en-us/library/dd135715.aspx
+    name = name.downcase
     bucket = nil
     azure_connect(credentials)
     safely do
@@ -87,6 +91,33 @@ class AzureDriver < Deltacloud::BaseDriver
       yield WAZ::Blobs::Container.find(bucket_id)[blob_id].value
   end
 
+#--
+# Create Blob
+#--
+  def create_blob(credentials, bucket_id, blob_id, blob_data, opts=nil)
+    azure_connect(credentials)
+    #get a handle to the bucket in order to put there
+    the_bucket = WAZ::Blobs::Container.find(bucket_id)
+    the_bucket.store(blob_id, blob_data[:tempfile], blob_data[:type])
+    Blob.new( { :id => blob_id,
+                :bucket => bucket_id,
+                :content_lengh => blob_data[:tempfile].length,
+                :content_type => blob_data[:type],
+                :last_modified => ''
+            } )
+  end
+  
+#--
+# Delete Blob
+#--
+  def delete_blob(credentials, bucket_id, blob_id, opts=nil)
+    azure_connect(credentials)
+    #get a handle to bucket and blob, and destroy!
+    the_bucket = WAZ::Blobs::Container.find(bucket_id)
+    the_blob = the_bucket[blob_id]
+    the_blob.destroy!
+  end
+
   private
 
   def azure_connect(credentials)
-- 
1.7.2.3


Mime
View raw message