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] Adds create_blob and delete_blob for the Microsoft Azure driver
Date Fri, 03 Dec 2010 11:40:21 GMT
On 02/12/10 19:08 +0200, marios@redhat.com wrote:

Hi,

I'm not going to test this with live Azure (don't have an Account ;)
just 1 inline code comment:

Otherwise code looks sane to me, ACK.

   -- Michal

>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

You can use name.downcase! here.

>     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
>

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

Mime
View raw message