You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by rl...@redhat.com on 2013/03/01 20:14:07 UTC

[PATCH 1/2] DTACLOUD-498 - nit in mock driver create/delete blobs - update bucket size

From: marios <ma...@redhat.com>

https://issues.apache.org/jira/browse/DTACLOUD-498

Signed-off-by: marios <ma...@redhat.com>
TrackedAt: http://tracker-mfojtik.rhcloud.com/patch/03b3210c6e63a36f3881904468dc00e34d858aad
---
 server/lib/deltacloud/drivers/mock/mock_driver.rb |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/server/lib/deltacloud/drivers/mock/mock_driver.rb b/server/lib/deltacloud/drivers/mock/mock_driver.rb
index 23eeaf6..7d7b17b 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver.rb
@@ -499,6 +499,7 @@ module Deltacloud::Drivers::Mock
           :content => blob_data
         })
       end
+      update_bucket_size(bucket_id, :plus
       Blob.new(@client.store(:blobs, blob))
     end
 
@@ -509,6 +510,7 @@ module Deltacloud::Drivers::Mock
       check_credentials(credentials)
       safely do
         raise "NotExistentBlob" unless @client.load_collection(:blobs, blob_id)
+        update_bucket_size(bucket_id, :minus
         @client.destroy(:blobs, blob_id)
       end
     end
@@ -608,6 +610,18 @@ module Deltacloud::Drivers::Mock
       StorageVolume.new(volume)
     end
 
+    def update_bucket_size(id, change)
+      bucket = @client.load_collection(:buckets, id)
+      raise 'BucketNotExist' if bucket.nil?
+      bucket[:size] = case change
+        when :plus then bucket[:size].to_i + 1
+        when :minus then  bucket[:size].to_i - 1
+        else
+          raise "unkown update operation for bucket!"
+      end
+      @client.store(:buckets, bucket)
+    end
+
     exceptions do
 
       on /AuthFailure/ do
-- 
1.7.7.6