incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francesco Vollero <fvoll...@redhat.com>
Subject [PATCH core] Fix rhevm client to manage possible errors on backend side for vm_action
Date Tue, 11 Oct 2011 14:39:41 GMT

Signed-off-by: Francesco Vollero <fvollero@redhat.com>
---
 .../lib/deltacloud/drivers/rhevm/rhevm_client.rb   |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb b/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
index 435d3f5..c7b671b 100644
--- a/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
+++ b/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
@@ -75,7 +75,18 @@ module RHEVM
       if action==:delete
         RHEVM::client(@api_entrypoint)["/vms/%s" % id].delete(headers)
       else
-        xml_response = Client::parse_response(RHEVM::client(@api_entrypoint)["/vms/%s/%s"
% [id, action]].post('<action/>', headers))
+        begin
+          client_response = RHEVM::client(@api_entrypoint)["/vms/%s/%s" % [id, action]].post('<action/>',
headers)
+        rescue
+          if $!.is_a?(RestClient::BadRequest)
+            fault = (Nokogiri::XML($!.http_body)/'//fault/detail')
+            fault = fault.text.gsub(/\[|\]/, '') if fault
+          end
+          fault ||= $!.message
+          raise RHEVMBackendException::new(fault)
+        end
+        xml_response = Client::parse_response(client_response)
+
         return false if (xml_response/'action/status').first.text.strip.upcase!="COMPLETE"
       end
       return true
-- 
1.7.4.4


Mime
View raw message