You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2011/10/11 17:58:15 UTC
svn commit: r1181859 -
/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
Author: mfojtik
Date: Tue Oct 11 15:58:15 2011
New Revision: 1181859
URL: http://svn.apache.org/viewvc?rev=1181859&view=rev
Log:
Fix rhevm client to manage possible errors on backend side for vm_action
Signed-off-by: Francesco Vollero <fv...@redhat.com>
Modified:
incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb?rev=1181859&r1=1181858&r2=1181859&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb Tue Oct 11 15:58:15 2011
@@ -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