
Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1232382714 28800 # Node ID a5a4d35749d1d9ed8604ea4879e12828c7f5b169 # Parent 57f3bc7c3105bb779b41e19b1c03a1e5f214cec1 [TEST] #2 Add some error checking when detecting hypervisor version
Updates: -In libvirt or hypervisior version cannot be determined, print error message to console.
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r 57f3bc7c3105 -r a5a4d35749d1 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 Mon Jan 19 08:31:54 2009 -0800 @@ -50,8 +50,17 @@ 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]
Using splitlines() so many times and then subscripting it is a little confusing. Any specific reason for using it like this ? Here is an alternative for above: if virsh_ver != "Unknown": libvirt, l2, l3, hyper = virsh_ver.splitlines() if libvirt.find("libvir"): libvirt_ver = libvirt.split()[4] if hyper.find("hypervisor"): tok1 = hyper.split(":") hyp_ver = tok1[1]
+ + if libvirt_ver == "Unknown": + print "\nUnable to determine libvirt version\n" + + if hyp_ver == "Unknown": + print "\nUnable to determine hypervisior version\n"
return libvirt_ver, hyp_ver
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Thanks and Regards, Deepti B. Kalakeri IBM Linux Technology Center deeptik@linux.vnet.ibm.com