You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by Michal Fojtik <mf...@redhat.com> on 2010/09/30 16:32:13 UTC

Re: ['PATCH'] updates mock driver with basic blobstore functions (get+post+delete buckets, get blobs). Also some yaml for mocking buckets/blobs.

On 24/09/10 17:32 +0100, mandreou@redhat.com wrote:
>---
> .../drivers/mock/data/buckets/blobs/blob1.yml      |    5 +
> .../drivers/mock/data/buckets/blobs/blob2.yml      |    5 +
> .../drivers/mock/data/buckets/blobs/blob3.yml      |    5 +
> .../drivers/mock/data/buckets/blobs/blob4.yml      |    5 +
> .../drivers/mock/data/buckets/blobs/blob5.yml      |    5 +
> .../drivers/mock/data/buckets/bucket1.yml          |    2 +
> .../drivers/mock/data/buckets/bucket2.yml          |    2 +
> server/lib/deltacloud/drivers/mock/mock_driver.rb  |   78 +++++++++++++++++++-
> 8 files changed, 106 insertions(+), 1 deletions(-)
> create mode 100644 server/lib/deltacloud/drivers/mock/data/buckets/blobs/blob1.yml
> create mode 100644 server/lib/deltacloud/drivers/mock/data/buckets/blobs/blob2.yml
> create mode 100644 server/lib/deltacloud/drivers/mock/data/buckets/blobs/blob3.yml
> create mode 100644 server/lib/deltacloud/drivers/mock/data/buckets/blobs/blob4.yml
> create mode 100644 server/lib/deltacloud/drivers/mock/data/buckets/blobs/blob5.yml
> create mode 100644 server/lib/deltacloud/drivers/mock/data/buckets/bucket1.yml
> create mode 100644 server/lib/deltacloud/drivers/mock/data/buckets/bucket2.yml
>
>+  def buckets(credentials, opts=nil)
>+    check_credentials(credentials)
>+    buckets=[]
>+     Dir[ "#{@storage_root}/buckets/*.yml" ].each do |bucket_file|
>+      bucket = YAML.load( File.read( bucket_file ) )
>+      bucket[:id] = File.basename( bucket_file, ".yml" )
>+      bucket[:name] = bucket[:id]
>+      buckets << Bucket.new( bucket )
>+    end
>+    buckets = filter_on( buckets, :id, opts )
>+    buckets
>+  end
>+
>+#--
>+# Create bucket
>+#--
>+  def create_bucket(credentials, name, opts=nil)
>+    check_credentials(credentials)
>+    bucket = {
>+      :name=>name,
>+      :size=>'0',
>+      :blob_list=>[]
>+    }
>+    File.open( "#{@storage_root}/buckets/#{name}.yml", 'w' ) {|b| YAML.dump( bucket, b )}

Just minor hint: You could use File.join(@storage_root, buckets, "#{name}.yml")
to avoid incompatibilities on Windows for example ;-)

>+# Blobs
>+#--
>+  def blobs(credentials, opts = nil)
>+    check_credentials(credentials)
>+    blobs=[]
>+    Dir[ "#{@storage_root}/buckets/blobs/*.yml" ].each do |blob_file|
>+      blob = YAML.load( File.read( blob_file ) )
>+      blob[:id] = File.basename( blob_file, ".yml" )
>+      blob[:name] = blob[:id]
>+      blobs << Blob.new( blob )
>+    end
>+    blobs = filter_on( blobs, :id, opts )
>+    blobs
>+  end

Looks good, and applied cleanely. ACK.

  -- Michal

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