[Libvirt-cim] [PATCH 1 of 2] Add function to poll for a guest

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Fri Aug 1 18:14:18 UTC 2008


Dan Smith wrote:
> KR> +def check_virsh_poll(ip, virt, dom_name):
> KR> +    cs = None
> KR> +
> KR> +    dom_list = domain_list(ip, virt)
> KR> +    if dom_name in dom_list:
> KR> +        timeout = 10 
> KR> +
> KR> +        for i in range(0, timeout):
> KR> +            rc, cs = get_cs_instance(dom_name, ip, virt)
> KR> +            if rc == 0:
> KR> +                return cs 
> KR> +
> KR> +            sleep(1)
> KR> +            
> KR> +    return cs 
> 
> How many iterations does this normally have to go through to get fresh
> data?

6 - 7 iterations - seems pretty consistent in my testing.

> 
> I suppose it's a reasonable band-aid for now.
> 

In the future, most of these tests will use the provider to create the 
guest (not virsh), so I think this problem will go away on its own in time.

Although, we'll want to have some tests that use virsh, just to make 
sure the providers handle guests created outside of the providers.  So 
we'll need this (or something like this) in those cases.

-- 
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list