incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@redhat.com
Subject [PATCH] Better response for the storage_volume attach and detach operations
Date Thu, 28 Jul 2011 22:45:29 GMT
From: marios <marios@redhat.com>


Signed-off-by: marios <marios@redhat.com>
---
 server/server.rb |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/server/server.rb b/server/server.rb
index f1a03f0..f4232fc 100644
--- a/server/server.rb
+++ b/server/server.rb
@@ -623,8 +623,15 @@ collection :storage_volumes do
     param :instance_id,:string,  :required
     param :device,     :string,  :required
     control do
-      driver.attach_storage_volume(credentials, params)
-      redirect(storage_volume_url(params[:id]))
+      @storage_volume = driver.attach_storage_volume(credentials, params)
+      respond_to do |format|
+        format.html{ redirect(storage_volume_url(params[:id]))}
+        format.xml do
+          response.status = 202
+          haml :"storage_volumes/show"
+        end
+        format.json {convert_to_json(:storage_volume, @storage_volume)}
+      end
     end
   end
 
@@ -634,9 +641,15 @@ collection :storage_volumes do
     param :id,         :string,  :required
     control do
       volume = driver.storage_volume(credentials, :id => params[:id])
-      driver.detach_storage_volume(credentials, :id => volume.id, :instance_id => volume.instance_id,
-                                   :device => volume.device)
-      redirect(storage_volume_url(params[:id]))
+      @storage_volume =  driver.detach_storage_volume(credentials, :id => volume.id, :instance_id
=> volume.instance_id, :device => volume.device)
+      respond_to do |format|
+        format.html{ redirect(storage_volume_url(params[:id]))}
+        format.xml do
+          response.status = 202
+          haml :"storage_volumes/show"
+        end
+        format.json {convert_to_json(:storage_volume, @storage_volume)}
+      end
     end
   end
 
-- 
1.7.3.4


Mime
View raw message