Return-Path: X-Original-To: apmail-deltacloud-dev-archive@www.apache.org Delivered-To: apmail-deltacloud-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 395589961 for ; Tue, 20 Mar 2012 10:43:25 +0000 (UTC) Received: (qmail 61797 invoked by uid 500); 20 Mar 2012 10:43:25 -0000 Delivered-To: apmail-deltacloud-dev-archive@deltacloud.apache.org Received: (qmail 61759 invoked by uid 500); 20 Mar 2012 10:43:24 -0000 Mailing-List: contact dev-help@deltacloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltacloud.apache.org Delivered-To: mailing list dev@deltacloud.apache.org Received: (qmail 61599 invoked by uid 99); 20 Mar 2012 10:43:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Mar 2012 10:43:24 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of mfojtik@redhat.com designates 209.132.183.28 as permitted sender) Received: from [209.132.183.28] (HELO mx1.redhat.com) (209.132.183.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Mar 2012 10:43:17 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2KAgt8K022109 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 20 Mar 2012 06:42:55 -0400 Received: from dhcp-29-121.brq.redhat.com (dhcp-29-121.brq.redhat.com [10.34.29.121]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q2KAgrqn029326 for ; Tue, 20 Mar 2012 06:42:55 -0400 From: mfojtik@redhat.com To: dev@deltacloud.apache.org Subject: [PATCH core 2/2] Core: Report HTTP status 202 after reboot operation (DTACLOUD-162) Date: Tue, 20 Mar 2012 11:44:02 +0100 Message-Id: <1332240242-30064-2-git-send-email-mfojtik@redhat.com> In-Reply-To: <1332240242-30064-1-git-send-email-mfojtik@redhat.com> References: <1332240242-30064-1-git-send-email-mfojtik@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-Virus-Checked: Checked by ClamAV on apache.org From: Michal Fojtik 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 --- .../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