incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r1041921 - /incubator/deltacloud/trunk/server/lib/deltacloud/drivers/azure/azure_driver.rb
Date Fri, 03 Dec 2010 17:26:43 GMT
Author: marios
Date: Fri Dec  3 17:26:43 2010
New Revision: 1041921

URL: http://svn.apache.org/viewvc?rev=1041921&view=rev
Log:
Adds create_blob and delete_blob for the Microsoft Azure driver

Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/azure/azure_driver.rb

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/azure/azure_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/azure/azure_driver.rb?rev=1041921&r1=1041920&r2=1041921&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/azure/azure_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/azure/azure_driver.rb Fri Dec
 3 17:26:43 2010
@@ -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::BaseDriv
 # 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.downcase!
     bucket = nil
     azure_connect(credentials)
     safely do
@@ -87,6 +91,33 @@ class AzureDriver < Deltacloud::BaseDriv
       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)



Mime
View raw message