
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1232643309 28800 # Node ID 9436d51e3f6f699ccba16cb6183095f0f4dabdfc # Parent 79d847b2acf889cc83d62003e9cbf8617b1272aa [TEST] #3 Add some error checking when detecting hypervisor version Updates from 2 to 3: -Simplfy the splitline logic. Updates from 1 to 2: -In libvirt or hypervisior version cannot be determined, print error message to console. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 79d847b2acf8 -r 9436d51e3f6f suites/libvirt-cim/lib/XenKvmLib/reporting.py --- a/suites/libvirt-cim/lib/XenKvmLib/reporting.py Mon Jan 19 09:10:19 2009 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/reporting.py Thu Jan 22 08:55:09 2009 -0800 @@ -45,13 +45,24 @@ cmd = "virsh version" virsh_ver = get_cmd_val(cmd, ip) if virsh_ver != "Unknown": - if len(virsh_ver.splitlines()) == 4: - if virsh_ver.splitlines()[0].find("libvir"): - libvirt_ver = virsh_ver.splitlines()[0].split()[4] + libvirt, tok1, tok2, hypervisor = virsh_ver.splitlines() + if libvirt.find("libvir"): + libvirt_ver = libvirt.split()[4] - if virsh_ver.splitlines()[3].find("hypervisor"): - hyp_ver = virsh_ver.splitlines()[3].split("hypervisor")[1] - hyp_ver = hyp_ver.split(": ")[1] + if hypervisor.find("hypervisor"): + tok = hypervisor.split("hypervisor") + #We need these checks here, because sometimes hypervisor is found, + #but the rest of the version info isn't available + if len(tok) > 1: + tok = tok[1].split(": ") + if len(tok) > 1: + hyp_ver = tok[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