1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-02-24 17:57:48 +03:00

lvmdbusd: Bubble up invalid JSON

If we get invalid JSON, lets bubble that up to the user.
This commit is contained in:
Tony Asleson 2016-11-16 15:45:05 -06:00
parent 61f6be7d2b
commit a1805cf336

View File

@ -202,12 +202,20 @@ class LVMShellProxy(object):
# Parse the report to see what happened
if report and len(report):
json_result = json.loads(report)
if 'log' in json_result:
if json_result['log'][-1:][0]['log_ret_code'] == '1':
rc = 0
else:
error_msg = self.get_error_msg()
try:
json_result = json.loads(report)
if 'log' in json_result:
if json_result['log'][-1:][0]['log_ret_code'] == '1':
rc = 0
else:
error_msg = self.get_error_msg()
except ValueError:
# The json is bad?, lets dump out for debug
with open('/tmp/json_bad', 'w') as debug:
debug.write(report)
# Bubble up the invalid json.
error_msg = "Invalid json %s" % report
if debug or rc != 0:
log_error(('CMD: %s' % cmd))