You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by Francesco Vollero <fv...@redhat.com> on 2011/10/11 16:39:40 UTC
Added to vm_action exception that throw backend errors
As per Jira DTACLOUD-88 I added a support to let deltacloud throw error messages taken from RHEVm backend
Re: [PATCH core] Fix rhevm client to manage possible errors on backend side for vm_action
Posted by Michal Fojtik <mf...@redhat.com>.
On Oct 11, 2011, at 4:39 PM, Francesco Vollero wrote:
ACK.
-- Michal
>
> Signed-off-by: Francesco Vollero <fv...@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
>
------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org
[PATCH core] Fix rhevm client to manage possible errors on backend side for vm_action
Posted by Francesco Vollero <fv...@redhat.com>.
Signed-off-by: Francesco Vollero <fv...@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