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

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Fri Sep 12 21:09:25 UTC 2008


>  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 at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list