+1 from me =)

libvirt-cim-bounces@redhat.com wrote on 2008-08-01 06:26:05:

> # HG changeset patch
> # User Kaitlin Rupert <karupert@us.ibm.com>
> # Date 1217542638 25200
> # Node ID d0c5bdff331b674690f973a70d4ef00878e484f4
> # Parent  365e478e317b6559dd8869051aeda8d54d358686
> Add function to poll for a guest
>
> This function is a work around to deal with a stale data issue seen
> with libvirt on RHEL 5.x.
>
> Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
>
> diff -r 365e478e317b -r d0c5bdff331b suites/libvirt-
> cim/lib/XenKvmLib/common_util.py
> --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py   Thu Jul 31
> 15:19:33 2008 -0700
> +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py   Thu Jul 31
> 15:17:18 2008 -0700
> @@ -33,10 +33,12 @@
>  from pywbem.cim_obj import CIMInstanceName
>  from XenKvmLib.devices import CIM_Instance
>  from XenKvmLib.classes import get_typed_class
> -from CimTest.Globals import logger, log_param, CIM_ERROR_ENUMERATE
> +from CimTest.Globals import logger, log_param, CIM_ERROR_ENUMERATE, \
> +                            CIM_ERROR_GETINSTANCE
>  from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
> -from VirtLib.live import diskpool_list, virsh_version, net_list
> +from VirtLib.live import diskpool_list, virsh_version, net_list, domain_list
>  from XenKvmLib.vxml import PoolXML, NetXML
> +from XenKvmLib.enumclass import getInstance
>  
>  test_dpath = "foo"
>  disk_file = '/etc/libvirt/diskpool.conf'
> @@ -57,7 +59,7 @@
>              return (1, cs)
>  
>      except Exception, detail:
> -        logger.error(Globals.CIM_ERROR_GETINSTANCE,
> +        logger.error(CIM_ERROR_GETINSTANCE,
>                       get_typed_class(virt, 'ComputerSystem'))
>          logger.error("Exception: %s", detail)
>          return (1, cs)
> @@ -397,3 +399,18 @@
>  
>      return PASS
>  
> +def check_virsh_poll(ip, virt, dom_name):
> +    cs = None
> +
> +    dom_list = domain_list(ip, virt)
> +    if dom_name in dom_list:
> +        timeout = 10
> +
> +        for i in range(0, timeout):
> +            rc, cs = get_cs_instance(dom_name, ip, virt)
> +            if rc == 0:
> +                return cs
> +
> +            sleep(1)
> +            
> +    return cs
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim@redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim