deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 1/2] RHEV-M: Raise 400 (Bad Request) when no API_PROVIDER is set
Date Mon, 05 Mar 2012 13:01:16 GMT
From: Michal Fojtik <mfojtik@redhat.com>

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 <mfojtik@redhat.com>
---
 .../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


Mime
View raw message