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 A707C95FC for ; Mon, 5 Mar 2012 13:00:45 +0000 (UTC) Received: (qmail 38632 invoked by uid 500); 5 Mar 2012 13:00:45 -0000 Delivered-To: apmail-deltacloud-dev-archive@deltacloud.apache.org Received: (qmail 38586 invoked by uid 500); 5 Mar 2012 13:00:45 -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 38564 invoked by uid 99); 5 Mar 2012 13:00:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Mar 2012 13:00:44 +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 (athena.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; Mon, 05 Mar 2012 13:00:38 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q25D0A7x026512 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 5 Mar 2012 08:00:16 -0500 Received: from dhcp-29-121.brq.redhat.com (dhcp-29-121.brq.redhat.com [10.34.29.121]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q25D092Q013768 for ; Mon, 5 Mar 2012 08:00:09 -0500 From: mfojtik@redhat.com To: dev@deltacloud.apache.org Subject: [PATCH core 1/2] RHEV-M: Raise 400 (Bad Request) when no API_PROVIDER is set Date: Mon, 5 Mar 2012 14:01:16 +0100 Message-Id: <1330952477-56605-1-git-send-email-mfojtik@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-Virus-Checked: Checked by ClamAV on apache.org From: Michal Fojtik Previously Deltacloud API respond with code 500, related to the 'split' method used to divide API_PROVIDER to URL and Datacenter when started without our with empty API_PROVIDER. With this patch, this error is properly captured and reported as 400 (Bad Request). Appropriate error XML and message is provided to the client. Signed-off-by: Michal fojtik --- .../lib/deltacloud/drivers/rhevm/rhevm_driver.rb | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb index 10ffef3..0d4e63f 100644 --- a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +++ b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb @@ -205,8 +205,9 @@ class RHEVMDriver < Deltacloud::BaseDriver private def new_client(credentials) - url, datacenter = api_provider.split(';') safely do + raise 'No API provider set for this request.' unless api_provider + url, datacenter = api_provider.split(';') OVIRT::Client.new(credentials.user, credentials.password, url, datacenter) end end @@ -327,7 +328,7 @@ class RHEVMDriver < Deltacloud::BaseDriver exceptions do - on /Bad Request/ do + on /(Bad Request|No API provider set)/ do status 400 end -- 1.7.9.1