You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by ma...@apache.org on 2013/01/09 14:58:22 UTC

[2/4] git commit: Deltacloud: adds storage_snapshot create/delete in mock driver

Deltacloud: adds storage_snapshot create/delete in mock driver

also fixes for create route display of new snapshot


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/12a2543d
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/12a2543d
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/12a2543d

Branch: refs/heads/master
Commit: 12a2543d915e714a8ccb5a2ca5d9ffeefdfb77b4
Parents: dfd0eb7
Author: marios <ma...@redhat.com>
Authored: Tue Jan 8 18:54:29 2013 +0200
Committer: marios <ma...@redhat.com>
Committed: Wed Jan 9 15:53:45 2013 +0200

----------------------------------------------------------------------
 .../deltacloud/collections/storage_snapshots.rb    |    6 +++-
 server/lib/deltacloud/drivers/mock/mock_driver.rb  |   20 +++++++++++++++
 2 files changed, 25 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/12a2543d/server/lib/deltacloud/collections/storage_snapshots.rb
----------------------------------------------------------------------
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
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/12a2543d/server/lib/deltacloud/drivers/mock/mock_driver.rb
----------------------------------------------------------------------
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)