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(a)linux.vnet.ibm.com