Gracefully handle non-XML output in GlusterFS execution module. (#34492)

* Gracefully handle non-XML command output.

* Omit gluster command usage line.

* Remove unnecessary import.
This commit is contained in:
zer0def 2016-07-06 23:12:30 +02:00 committed by Nicole Thomas
parent 75299456be
commit 6ce7cb9616

View file

@ -76,7 +76,11 @@ def _gluster_xml(cmd):
result = __salt__['cmd.run'](
'gluster --xml --mode=script', stdin="{0}\n".format(cmd)
)
root = ET.fromstring(_gluster_output_cleanup(result))
try:
root = ET.fromstring(_gluster_output_cleanup(result))
except ET.ParseError:
raise CommandExecutionError('\n'.join(result.splitlines()[:-1]))
if int(root.find('opRet').text) != 0:
raise CommandExecutionError(root.find('opErrstr').text)