aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2022-01-26 09:44:01 +0100
committerJake Hunsaker <jhunsake@redhat.com>2022-01-26 09:04:51 -0500
commit790d6d65879f64f2f5ca760db4242cd3a61693a5 (patch)
treeda0b4c2f9c42fdaf9ebae944a6c705f207a0f956
parent210b83e1d1164d29b1f6198675b8b596c4af8336 (diff)
downloadsos-790d6d65879f64f2f5ca760db4242cd3a61693a5.tar.gz
[virsh] Catch parsing exception
In case virsh output is malformed or missing 'Name' otherwise, catch parsing exception and continue in next for loop iteration. Resolves: #2836 Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
-rw-r--r--sos/report/plugins/virsh.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/sos/report/plugins/virsh.py b/sos/report/plugins/virsh.py
index 08f9a848..2ce1df15 100644
--- a/sos/report/plugins/virsh.py
+++ b/sos/report/plugins/virsh.py
@@ -48,7 +48,11 @@ class LibvirtClient(Plugin, IndependentPlugin):
if k_list['status'] == 0:
k_lines = k_list['output'].splitlines()
# the 'Name' column position changes between virsh cmds
- pos = k_lines[0].split().index('Name')
+ # catch the rare exceptions when 'Name' is not found
+ try:
+ pos = k_lines[0].split().index('Name')
+ except Exception:
+ continue
for j in filter(lambda x: x, k_lines[2:]):
n = j.split()[pos]
self.add_cmd_output('%s %s-dumpxml %s' % (cmd, k, n),