
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1233605070 28800 # Node ID 4327fd7361d8107c8f7fc827d62162e9151ff6dd # Parent fa1424f9b3f4ae005b4fcc34e18858035cc8f102 [TEST] Update VSMS 12_referenced_config.py to use cim_() function. Also re-wrote part of this test to fix the overall test flow. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r fa1424f9b3f4 -r 4327fd7361d8 suites/libvirt-cim/cimtest/VirtualSystemManagementService/12_referenced_config.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/12_referenced_config.py Mon Feb 02 12:02:30 2009 -0800 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/12_referenced_config.py Mon Feb 02 12:04:30 2009 -0800 @@ -21,19 +21,15 @@ # import sys -import pywbem -from XenKvmLib.common_util import create_using_definesystem, \ - call_request_state_change, \ - poll_for_state_change, get_cs_instance -from XenKvmLib import vsms -from VirtLib import utils +from XenKvmLib.common_util import get_cs_instance from CimTest.Globals import logger from XenKvmLib.const import do_main from CimTest.ReturnCodes import FAIL, PASS -from XenKvmLib.test_doms import destroy_and_undefine_domain -from XenKvmLib.classes import get_typed_class +from XenKvmLib.classes import get_typed_class, inst_to_mof from XenKvmLib.assoc import AssociatorNames from XenKvmLib.test_xml import dumpxml +from XenKvmLib.vxml import get_class +from XenKvmLib.rasd import get_default_rasds sup_types = ['Xen', 'XenFV', 'KVM'] test_dom = 'rstest_domain' @@ -41,21 +37,13 @@ mac = "aa:aa:aa:00:00:00" -REQUESTED_STATE = 2 -TIME = "00000000000000.000000:000" - -def setup_first_guest(ip, virt): - status = create_using_definesystem(test_dom, ip, virt=virt) - if status != PASS: +def setup_first_guest(ip, virt, cxml): + ret = cxml.cim_define(ip) + if not ret: logger.error("Unable to define %s using DefineSystem()" % test_dom) return FAIL - rc = call_request_state_change(test_dom, ip, REQUESTED_STATE, TIME, virt) - if rc != 0: - logger.error("Unable to start %s" % test_dom) - return FAIL - - status, cs = poll_for_state_change(ip, virt, test_dom, REQUESTED_STATE) + status = cxml.cim_start(ip) if status != PASS: logger.error("Unable to start %s" % test_dom) return FAIL @@ -70,7 +58,7 @@ cn = "ComputerSystem" ccn = get_typed_class(virt, cn) an = get_typed_class(virt, 'SettingsDefineState') - vssd = AssociatorNames(ip, an, ccn, Name = test_dom, CreationClassName = ccn) + vssd = AssociatorNames(ip, an, ccn, Name=test_dom, CreationClassName=ccn) if len(vssd) != 1: logger.error("Returned %i vssd insts for '%s'", len(vssd), test_dom) @@ -78,26 +66,33 @@ return vssd[0] -def get_vssd_rasd(virt): - vssd, def_rasd = vsms.default_vssd_rasd_str(dom_name=test_dom2, - net_type='network', - net_mac=mac, virt=virt) +def setup_second_guest(ip, virt, cxml2, ref): + nrasd_cn = get_typed_class(virt, "NetResourceAllocationSettingData") - rasd = [] - for inst in def_rasd: - cn = get_typed_class(virt, "NetResourceAllocationSettingData") - if cn in inst: - rasd.append(inst) + rasds = get_default_rasds(ip, virt) - params = {} + rasd_list = {} - if len(rasd) != 1: - return params + for rasd in rasds: + if rasd.classname == nrasd_cn: + rasd['Address'] = mac + rasd['NetworkType'] = "network" + rasd_list[nrasd_cn] = inst_to_mof(rasd) + else: + rasd_list[rasd.classname] = None - params['vssd'] = vssd - params['rasd'] = rasd + if rasd_list[nrasd_cn] is None: + logger.error("Unable to get template NetRASD") + return FAIL - return params + cxml2.set_res_settings(rasd_list) + + ret = cxml2.cim_define(ip, ref_conf=ref) + if not ret: + logger.error("Unable to define %s using DefineSystem()" % test_dom2) + return FAIL + + return PASS def get_dom_macs(server, dom, virt): mac_list = [] @@ -118,8 +113,10 @@ def main(): options = main.options + cxml = get_class(options.virt)(test_dom) + cxml2 = get_class(options.virt)(test_dom2) try: - status = setup_first_guest(options.ip, options.virt) + status = setup_first_guest(options.ip, options.virt, cxml) if status != PASS: raise Exception("Unable to start %s" % test_dom) @@ -127,14 +124,7 @@ if ref is None: raise Exception("Unable to get %s reference" % test_dom) - define_params = get_vssd_rasd(options.virt) - if len(define_params) != 2: - raise Exception("Unable to build VSSD and RASD instances for %s" % \ - test_dom2) - - status = create_using_definesystem(test_dom2, options.ip, - params=define_params, ref_config=ref, - virt=options.virt) + status = setup_second_guest(options.ip, options.virt, cxml2, ref) if status != PASS: raise Exception("Unable to define %s" % test_dom2) @@ -159,8 +149,9 @@ logger.error(details) status = FAIL - destroy_and_undefine_domain(test_dom, options.ip, options.virt) - destroy_and_undefine_domain(test_dom2, options.ip, options.virt) + cxml.cim_destroy(options.ip) + cxml.undefine(options.ip) + cxml2.undefine(options.ip) return status