[Libvirt-cim] [PATCH 2 of 3] [TEST] #2 Add generic poll function to poll for guest state
Deepti B Kalakeri
deeptik at linux.vnet.ibm.com
Fri Jun 27 10:25:19 UTC 2008
+1 for me.
Kaitlin Rupert wrote:
> # HG changeset patch
> # User Kaitlin Rupert <karupert at us.ibm.com>
> # Date 1214156795 25200
> # Node ID a379b9abb12cffae8e19c5db0e312df0581b9541
> # Parent 59fce67164a22315bb712f692dfd93314c4f30e0
> [TEST] #2 Add generic poll function to poll for guest state.
>
> Updates from patch 1 to 2:
> -Added timeout as a parameter - still has defualt value of 30
> -Added a check to verify the Name of the CS instance returned matches the name of the guest we're polling for.
>
> Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>
>
> diff -r 59fce67164a2 -r a379b9abb12c suites/libvirt-cim/lib/XenKvmLib/common_util.py
> --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Thu Jun 05 19:37:57 2008 -0700
> +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Sun Jun 22 10:46:35 2008 -0700
> @@ -23,6 +23,7 @@
> import os
> import pywbem
> import random
> +from time import sleep
> from distutils.file_util import move_file
> from XenKvmLib.test_xml import *
> from XenKvmLib.test_doms import *
> @@ -135,6 +136,32 @@
> return 1
>
> return 0
> +
> +def poll_for_state_change(server, virt, dom, exp_state, timeout=30):
> + cs = computersystem.get_cs_class(virt)
> +
> + try:
> + for i in range(1, (timeout + 1)):
> + sleep(1)
> + dom_cs = cs(server, name=dom)
> + if dom_cs is None or dom_cs.Name != dom:
> + logger.error("CS instance not returned for %s." % dom)
> + return FAIL
> +
> + if dom_cs.EnabledState == exp_state:
> + break
> +
> + except Exception, detail:
> + logger.error("Exception: %s" % detail)
> + return FAIL
> +
> + if dom_cs.EnabledState != exp_state:
> + logger.error("EnabledState is %i instead of %i." % (dom_cs.EnabledState,
> + exp_state))
> + logger.error("Try to increase the timeout and run the test again")
> + return FAIL
> +
> + return PASS
>
> def get_host_info(server, virt="Xen"):
> status = PASS
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim
>
More information about the Libvirt-cim
mailing list