deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@redhat.com
Subject [PATCH 2/4] Deltacloud: adds storage_snapshot create/delete in mock driver
Date Tue, 08 Jan 2013 17:21:38 GMT
From: marios <marios@redhat.com>

also fixes for create route display of new snapshot

Signed-off-by: marios <marios@redhat.com>
---
 .../lib/deltacloud/collections/storage_snapshots.rb  |  6 +++++-
 server/lib/deltacloud/drivers/mock/mock_driver.rb    | 20 ++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/server/lib/deltacloud/collections/storage_snapshots.rb b/server/lib/deltacloud/collections/storage_snapshots.rb
index 5d5ac53..dca253a 100644
--- a/server/lib/deltacloud/collections/storage_snapshots.rb
+++ b/server/lib/deltacloud/collections/storage_snapshots.rb
@@ -31,7 +31,11 @@ module Deltacloud::Collections
           @storage_snapshot = driver.create_storage_snapshot(credentials, params)
           status 201  # Created
           response['Location'] = storage_snapshot_url(@storage_snapshot.id)
-          show(:storage_snapshot)
+          respond_to do |format|
+            format.xml { haml :"storage_snapshots/show" }
+            format.html { haml :"storage_snapshots/show" }
+            format.json { xml_to_json "storage_snapshots/show" }
+          end
         end
       end
 
diff --git a/server/lib/deltacloud/drivers/mock/mock_driver.rb b/server/lib/deltacloud/drivers/mock/mock_driver.rb
index 38cb042..b12ca57 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver.rb
@@ -314,6 +314,26 @@ module Deltacloud::Drivers::Mock
       snapshots
     end
 
+    def create_storage_snapshot(credentials, opts={})
+      check_credentials(credentials)
+      id = "store_snapshot_#{Time.now.to_i}"
+      snapshot = {
+            :id => id,
+            :created => Time.now.to_s,
+            :state => "COMPLETED",
+            :storage_volume_id => opts[:volume_id],
+      }
+      snapshot.merge!({:name=>opts[:name]}) if opts[:name]
+      snapshot.merge!({:description=>opts[:description]}) if opts[:description]
+      @client.store(:storage_snapshots, snapshot)
+      StorageSnapshot.new(snapshot)
+    end
+
+    def destroy_storage_snapshot(credentials, opts={})
+      check_credentials(credentials)
+      @client.destroy(:storage_snapshots, opts[:id])
+    end
+
     def keys(credentials, opts={})
       check_credentials(credentials)
       result = @client.build_all(Key)
-- 
1.7.11.7


Mime
View raw message