deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [3/4] git commit: Core: Report HTTP status 202 after reboot operation (DTACLOUD-162)
Date Tue, 20 Mar 2012 13:26:06 GMT
Core: Report HTTP status 202 after reboot operation (DTACLOUD-162)

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.


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

Branch: refs/heads/master
Commit: 180042b8e402b632728edf8457a2e236960bc879
Parents: 82e8328
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Tue Mar 20 11:38:30 2012 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Tue Mar 20 11:43:25 2012 +0100

----------------------------------------------------------------------
 .../lib/deltacloud/helpers/application_helper.rb   |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/180042b8/server/lib/deltacloud/helpers/application_helper.rb
----------------------------------------------------------------------
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" }


Mime
View raw message