incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michal Fojtik <mfoj...@redhat.com>
Subject Re: [PATCH core] Fix rhevm client to manage possible errors on backend side for vm_action
Date Tue, 11 Oct 2011 15:59:22 GMT
On Oct 11, 2011, at 4:39 PM, Francesco Vollero wrote:

ACK.

  -- Michal

> 
> 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
> 

------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org


Mime
View raw message