deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 2/2] Core: Report HTTP status 202 after reboot operation (DTACLOUD-162)
Date Tue, 20 Mar 2012 10:44:02 GMT
From: Michal Fojtik <mfojtik@redhat.com>

Previously the 'reboot' operation returns various response codes for different
drivers. The code '204' (No Content) was returned for VSphere because the
'reboot' operation does not return full instance object.  However for EC2 it
returns '200' (OK) because in this driver the reboot operation returns full
instance object.

Now all 'reboot' operations in all drivers should return the code 202 (Accepted),
because the operation does not finish and the reboot operation is statefull.
If driver support retrieval of instance object after reboot, the full instance
body is returned, otherwise the Location header will point client to updated
instance.

Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 .../lib/deltacloud/helpers/application_helper.rb   |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/server/lib/deltacloud/helpers/application_helper.rb b/server/lib/deltacloud/helpers/application_helper.rb
index e368103..bdcbd73 100644
--- a/server/lib/deltacloud/helpers/application_helper.rb
+++ b/server/lib/deltacloud/helpers/application_helper.rb
@@ -133,9 +133,13 @@ module ApplicationHelper
       return report_error(405)
     end
 
-    @instance = driver.send(:"#{name}_instance", credentials, params["id"])
+    @instance = driver.send(:"#{name}_instance", credentials, params[:id])
 
-    if name == :destroy or @instance.class!=Instance
+    if name == :reboot
+      status 202
+    end
+
+    if name == :destroy
       respond_to do |format|
         format.xml { return 204 }
         format.json { return 204 }
@@ -143,6 +147,11 @@ module ApplicationHelper
       end
     end
 
+    if @instance.class != Instance
+      response['Location'] = instance_url(params[:id])
+      halt
+    end
+
     respond_to do |format|
       format.xml { haml :"instances/show" }
       format.html { haml :"instances/show" }
-- 
1.7.9.1


Mime
View raw message