[PATCH] [TEST] #3 Fix LogicalDisk - 02_nodevs.py

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1221184469 25200 # Node ID 7efdd4ae22828154d19c0daf53dd5ee5d8942eb2 # Parent 12931170a223bf6194177be33dfad154d7cb21e9 [TEST] #3 Fix LogicalDisk - 02_nodevs.py Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r 12931170a223 -r 7efdd4ae2282 suites/libvirt-cim/cimtest/LogicalDisk/02_nodevs.py --- a/suites/libvirt-cim/cimtest/LogicalDisk/02_nodevs.py Wed Sep 10 18:58:22 2008 -0700 +++ b/suites/libvirt-cim/cimtest/LogicalDisk/02_nodevs.py Thu Sep 11 18:54:29 2008 -0700 @@ -25,7 +25,8 @@ import sys import pywbem -from VirtLib import live +from time import sleep +from XenKvmLib import enumclass from XenKvmLib import devices from CimTest.Globals import logger, CIM_ERROR_ENUMERATE from XenKvmLib.const import do_main @@ -35,17 +36,18 @@ test_dom = "test_domain" def clean_system(host, virt='Xen'): - l = live.domain_list(host, virt) - - if virt == "XenFV" or virt == "Xen": - if len(l) > 1: - return False + timer_count = 10 + for count in range(0, timer_count): + keys = ['Name', 'CreationClassName'] + l = enumclass.enumerate(host, 'ComputerSystem', keys, virt) + if virt == "XenFV" or virt == "Xen": + if len(l) == 0: + return True + sleep(1) + if count == 9 and len(l) != 0: + return SKIP else: return True - elif len(l) > 0: - return False - else: - return True @do_main(sup_types) def main():

def clean_system(host, virt='Xen'): - l = live.domain_list(host, virt) - - if virt == "XenFV" or virt == "Xen": - if len(l) > 1: - return False + timer_count = 10 + for count in range(0, timer_count): + keys = ['Name', 'CreationClassName'] + l = enumclass.enumerate(host, 'ComputerSystem', keys, virt) + if virt == "XenFV" or virt == "Xen": + if len(l) == 0: + return True + sleep(1) + if count == 9 and len(l) != 0: + return SKIP
In all other cases, the function returns a boolean. So, you won't want to return SKIP here.
else: return True - elif len(l) > 0: - return False - else: - return True
If you remove these lines, then for KVM and LXC, you're always returning True. What you have is close - how about something like: def clean_system(host, virt='Xen'): timer_count = 10 for count in range(0, timer_count): keys = ['Name', 'CreationClassName'] l = enumclass.enumerate(host, 'ComputerSystem', keys, virt) if len(l) == 0: return True if virt == "XenFV" or virt == "Xen": sleep(1) else: break return False You only need to poll in the Xen/XenFV case. Otherwise, you can break from the loop and return a failure. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

libvirt-cim-bounces@redhat.com wrote on 2008-09-13 05:09:25:
def clean_system(host, virt='Xen'): - l = live.domain_list(host, virt) - - if virt == "XenFV" or virt == "Xen": - if len(l) > 1: - return False + timer_count = 10 + for count in range(0, timer_count): + keys = ['Name', 'CreationClassName'] + l = enumclass.enumerate(host, 'ComputerSystem', keys, virt) + if virt == "XenFV" or virt == "Xen": + if len(l) == 0: + return True + sleep(1) + if count == 9 and len(l) != 0: + return SKIP
In all other cases, the function returns a boolean. So, you won't want to return SKIP here.
else: return True - elif len(l) > 0: - return False - else: - return True
If you remove these lines, then for KVM and LXC, you're always returning
True.
What you have is close - how about something like:
def clean_system(host, virt='Xen'): timer_count = 10 for count in range(0, timer_count): keys = ['Name', 'CreationClassName'] l = enumclass.enumerate(host, 'ComputerSystem', keys, virt) if len(l) == 0: return True
if virt == "XenFV" or virt == "Xen": sleep(1) else: break
return False
You only need to poll in the Xen/XenFV case. Otherwise, you can break from the loop and return a failure.
#4 patch on the way. Thanks!
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
participants (3)
-
Guo Lian Yun
-
Kaitlin Rupert
-
yunguol@cn.ibm.com