
# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1252590021 14400 # Node ID 53b05fc42fbc04ce45eea4a09ad84881fbcf6d3e # Parent 30196cc506c07d81642c94a01fc65b34421c0714 [TEST] Adding verification for DestroySystem() of the domain. Tested with KVM and current sources on SLES11. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 30196cc506c0 -r 53b05fc42fbc suites/libvirt-cim/cimtest/VirtualSystemManagementService/02_destroysystem.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/02_destroysystem.py Wed Sep 02 05:11:16 2009 -0700 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/02_destroysystem.py Thu Sep 10 09:40:21 2009 -0400 @@ -27,8 +27,9 @@ from VirtLib import utils from XenKvmLib.xm_virt_util import domain_list, active_domain_list from XenKvmLib import vsms, vxml +from XenKvmLib.common_util import poll_for_state_change from XenKvmLib.classes import get_typed_class -from XenKvmLib.const import do_main +from XenKvmLib.const import do_main, CIM_DISABLE from CimTest.Globals import logger from CimTest.ReturnCodes import PASS, FAIL @@ -45,44 +46,49 @@ service = vsms.get_vsms_class(options.virt)(options.ip) cxml = vxml.get_class(options.virt)(default_dom) - ret = cxml.cim_define(options.ip) - if not ret: - logger.error("Failed to define the dom: %s", default_dom) - return FAIL - ret = cxml.start(options.ip) - if not ret: - logger.error("Failed to start the dom: %s", default_dom) - cleanup_env(options.ip, cxml) - return FAIL - classname = get_typed_class(options.virt, 'ComputerSystem') - cs_ref = CIMInstanceName(classname, keybindings = { - 'Name':default_dom, - 'CreationClassName':classname}) - list_before = domain_list(options.ip, options.virt) - if default_dom not in list_before: - logger.error("Domain not in domain list") - cleanup_env(options.ip, cxml) - return FAIL + try: + ret = cxml.cim_define(options.ip) + if not ret: + logger.error("Failed to define the dom: %s", default_dom) + return FAIL + + ret = cxml.cim_start(options.ip) + if ret: + logger.error("Failed to start the dom: %s", default_dom) + cxml.undefine(options.ip) + return FAIL + + list_before = domain_list(options.ip, options.virt) + if default_dom not in list_before: + raise Exception("Domain not in domain list") - try: - service.DestroySystem(AffectedSystem=cs_ref) + ret = cxml.cim_destroy(options.ip) + if not ret: + raise Exception("Failed to destroy dom '%s'" % default_dom) + + list_after = domain_list(options.ip, options.virt) + + if default_dom in list_after: + raise Exception("Domain '%s' not destroyed: provider didn't " \ + "return error" % default_dom) + + status, dom_cs = poll_for_state_change(options.ip, options.virt, + default_dom, CIM_DISABLE) + if status != PASS: + raise Exception("RequestedState for dom '%s' is not '%s'"\ + % (default_dom, CIM_DISABLE)) + + ret = cxml.undefine(options.ip) + if not ret: + logger.error("Failed to undefine domain '%s'", default_dom) + return FAIL + except Exception, details: - logger.error('Unknow exception happened') logger.error(details) cleanup_env(options.ip, cxml) return FAIL - list_after = domain_list(options.ip, options.virt) - - if default_dom in list_after: - logger.error("Domain %s not destroyed: provider didn't return error", - default_dom) - cleanup_env(options.ip, cxml) - status = FAIL - else: - status = PASS - return status