Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP5:GA
fence-agents.14954
fence_vmware_rest-improve-exception-handling-in...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File fence_vmware_rest-improve-exception-handling-in-send_command.patch of Package fence-agents.14954
From 020f48a309bcad659dc493960d2b39e8e1243085 Mon Sep 17 00:00:00 2001 From: Thomas Abraham <tabraham@suse.com> Date: Mon, 20 Apr 2020 20:28:43 -0400 Subject: [PATCH] fence_vmware_rest: improve exception handling in send_command() If an exception occurs, simply raise it. pycurl's perform() method can generate a pycurl.error object, which does not support indexing and attempting to do so will generate an exception that hides the original exception. Also, don't assume that the remote will return a JSON formatted response. If it doesn't, a exception will occur accessing result which will not raise the intended exception. --- agents/vmware_rest/fence_vmware_rest.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/agents/vmware_rest/fence_vmware_rest.py b/agents/vmware_rest/fence_vmware_rest.py index d07bc10d..1505ffe6 100644 --- a/agents/vmware_rest/fence_vmware_rest.py +++ b/agents/vmware_rest/fence_vmware_rest.py @@ -135,7 +135,11 @@ def send_command(conn, command, method="GET"): result = json.loads(result) if rc != 200: - raise Exception("{}: {}".format(rc, result["value"]["messages"][0]["default_message"])) + if len(result) > 0: + raise Exception("{}: {}".format(rc, + result["value"]["messages"][0]["default_message"])) + else: + raise Exception("Remote returned {} for request to {}".format(rc, url)) logging.debug("url: {}".format(url)) logging.debug("method: {}".format(method))
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor