[PATCH] [TEST] Add some error checking when detecting hypervisor version

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1232140666 28800 # Node ID 2500265f6c78b23eaddaffe3595bb2dee127cc13 # Parent 57f3bc7c3105bb779b41e19b1c03a1e5f214cec1 [TEST] Add some error checking when detecting hypervisor version Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 57f3bc7c3105 -r 2500265f6c78 suites/libvirt-cim/lib/XenKvmLib/reporting.py --- a/suites/libvirt-cim/lib/XenKvmLib/reporting.py Fri Jan 16 11:51:26 2009 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/reporting.py Fri Jan 16 13:17:46 2009 -0800 @@ -50,8 +50,11 @@ libvirt_ver = virsh_ver.splitlines()[0].split()[4] if virsh_ver.splitlines()[3].find("hypervisor"): - hyp_ver = virsh_ver.splitlines()[3].split("hypervisor")[1] - hyp_ver = hyp_ver.split(": ")[1] + tok = virsh_ver.splitlines()[3].split("hypervisor") + if len(tok) > 1: + tok = tok[1].split(": ") + if len(tok) > 1: + hyp_ver = tok[1] return libvirt_ver, hyp_ver

libvirt-cim-bounces@redhat.com wrote on 2009-01-17 05:17:57:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1232140666 28800 # Node ID 2500265f6c78b23eaddaffe3595bb2dee127cc13 # Parent 57f3bc7c3105bb779b41e19b1c03a1e5f214cec1 [TEST] Add some error checking when detecting hypervisor version
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r 57f3bc7c3105 -r 2500265f6c78 suites/libvirt- cim/lib/XenKvmLib/reporting.py --- a/suites/libvirt-cim/lib/XenKvmLib/reporting.py Fri Jan 16 11: 51:26 2009 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/reporting.py Fri Jan 16 13: 17:46 2009 -0800 @@ -50,8 +50,11 @@ libvirt_ver = virsh_ver.splitlines()[0].split()[4]
if virsh_ver.splitlines()[3].find("hypervisor"): - hyp_ver = virsh_ver.splitlines()[3].split("hypervisor")[1] - hyp_ver = hyp_ver.split(": ")[1] + tok = virsh_ver.splitlines()[3].split("hypervisor") + if len(tok) > 1: + tok = tok[1].split(": ") + if len(tok) > 1: + hyp_ver = tok[1]
return libvirt_ver, hyp_ver
+1 from me. It's better to print out error log if len(tok)<= 1.
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

virsh_ver.splitlines()[3].split("hypervisor")[1]
- hyp_ver = hyp_ver.split(": ")[1] + tok = virsh_ver.splitlines()[3].split("hypervisor") + if len(tok) > 1: + tok = tok[1].split(": ") + if len(tok) > 1: + hyp_ver = tok[1]
return libvirt_ver, hyp_ver
+1 from me. It's better to print out error log if len(tok)<= 1.
I can resend with some additional logging. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Guo Lian Yun
-
Kaitlin Rupert