[Libvirt-cim] [PATCH] [TEST] Update CS 06_paused_active_suspend.py to use cim_() functions
Deepti B Kalakeri
deeptik at linux.vnet.ibm.com
Tue Dec 30 10:54:10 UTC 2008
Kaitlin Rupert wrote:
> # HG changeset patch
> # User Kaitlin Rupert <karupert at us.ibm.com>
> # Date 1230073744 28800
> # Node ID f95c0c4d4ef6d807262ba06f5087caa80156d917
> # Parent a9826c20a65bc16c2c205b183e4fa8eafde08d30
> [TEST] Update CS 06_paused_active_suspend.py to use cim_() functions.
>
> This test has been re-written so it is now easier to read and flows better.
>
> Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>
>
> diff -r a9826c20a65b -r f95c0c4d4ef6 suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py
> --- a/suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py Tue Dec 23 15:03:40 2008 -0800
> +++ b/suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py Tue Dec 23 15:09:04 2008 -0800
> @@ -26,7 +26,7 @@
> # information related to this is captured in the RequestedState Property
> # of the VS.
> # The test is considered to be successful if RequestedState Property
> -# has a value of "9" when the VS is moved from active to suspend state.
> +# has a value of "9" when the VS is moved from active to paused state.
> #
> # List of Valid state values (Refer to VSP spec doc Table 2 for more)
> # ---------------------------------
> @@ -35,27 +35,22 @@
> # Defined | 3
> # Active | 2
> # Paused | 9
> -# Suspended | 6
> #
> #
> # Date :18-10-2007
>
> import sys
> -from XenKvmLib import vxml
> -from VirtLib import utils
> -from XenKvmLib.test_doms import destroy_and_undefine_all
> +from XenKvmLib.vxml import get_class
> from CimTest.Globals import logger
> from XenKvmLib.const import do_main
> -from XenKvmLib.common_util import call_request_state_change, \
> -poll_for_state_change
> from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
> +from XenKvmLib.classes import get_typed_class
> +from XenKvmLib.enumclass import GetInstance
>
> sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
> test_dom = "DomST1"
> -mem = 128 # MB
> START_STATE = 2
> FINAL_STATE = 9
>
We can use const.CIM_ENABLE and const.CIM_PAUSE for START_STATE and
FINAL_STATE respectively.
> -TIME = "00000000000000.000000:000"
> bug_libvirt = "00011"
>
> @do_main(sup_types)
> @@ -65,69 +60,57 @@
> server = options.ip
> virt = options.virt
>
> - destroy_and_undefine_all(server)
> -
> - cxml = vxml.get_class(virt)(test_dom, mem)
> + cxml = get_class(virt)(test_dom)
>
> #Create VS
> + pause_failed = False
> try:
> - ret = cxml.create(server)
> + ret = cxml.cim_define(server)
> if not ret:
> - logger.error("VS '%s' was not created" % test_dom)
> - return status
> + raise Exception("VS '%s' was not defined" % test_dom)
> +
> + status = cxml.cim_start(server)
> + if status != PASS:
> + raise Exception("Unable start dom '%s'" % test_dom)
> +
> + cs_class = get_typed_class(virt, 'ComputerSystem')
> + keys = { 'Name' : test_dom, 'CreationClassName' : cs_class }
> +
> + dom_cs = GetInstance(server, cs_class, keys)
> + if dom_cs.Name != test_dom:
> + raise Exception("Instance matching %s was not returned" % test_dom)
> +
> + if int(dom_cs.EnabledState) != int(START_STATE):
> + raise Exception("%s start state is %s, exp %s" % (test_dom,
> + dom_cs.EnabledState, START_STATE))
>
The below piece of code is repeated :
cs = GetInstance(options.ip, cs_class, keys)
if cs.Name != test_dom:
raise Exception("VS '%s' is not available" % test_dom)
if int(cs.EnabledState) != int(START_STATE):
raise Exception("%s start state is %s, exp %s" % (test_dom,
cs.EnabledState, START_STATE))
We can put this in a fn like check_state() , any thoughts ??
Thanks and Regards,
Deepti.
More information about the Libvirt-cim
mailing list