
+1 Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1233682625 28800 # Node ID b5e7e1cf87f88b2baa21645b5d2bed2286ffb0ca # Parent fa1424f9b3f4ae005b4fcc34e18858035cc8f102 [TEST] #2 Update VSMS 12_referenced_config.py to use cim_() function.
Also re-wrote part of this test to fix the overall test flow.
Updates: -Added comment -Ensured cleanup only occurs when guest has been started / defined -Use cs instance Name and CCN
Thanks for the description here =)
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r fa1424f9b3f4 -r b5e7e1cf87f8 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 Tue Feb 03 09:37:05 2009 -0800 @@ -19,21 +19,27 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# Purpose: +# Verify DefineSystem() properly uses the settings of the referenced passed in +# for the ReferenceConfiguration parameter. +# +# Steps: +# 1) Define and start a guest +# 2) Get the reference of the guest +# 3) Define a second guest using the reference of the first guest +# 4) Verify the settings of the second guest +
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,36 +47,27 @@
mac = "aa:aa:aa:00:00:00"
-REQUESTED_STATE = 2 -TIME = "00000000000000.000000:000" +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, None
-def setup_first_guest(ip, virt): - status = create_using_definesystem(test_dom, ip, virt=virt) - if status != PASS: - 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 + return FAIL, "define"
- return PASS + return PASS, "start"
def get_vssd_ref(ip, virt): rc, cs = get_cs_instance(test_dom, ip, virt) if rc != 0: return None
- 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, cs.CreationClassName, Name=cs.Name, + CreationClassName=cs.CreationClassName)
if len(vssd) != 1: logger.error("Returned %i vssd insts for '%s'", len(vssd), test_dom) @@ -78,26 +75,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, None + + return PASS, "define"
def get_dom_macs(server, dom, virt): mac_list = [] @@ -117,33 +121,34 @@ @do_main(sup_types) def main(): options = main.options + virt = options.virt + ip = options.ip + + cxml = get_class(virt)(test_dom) + cxml2 = get_class(virt)(test_dom2) + + guest1_setup = None + guest2_setup = None
try: - status = setup_first_guest(options.ip, options.virt) + status, guest1_setup = setup_first_guest(ip, virt, cxml) if status != PASS: raise Exception("Unable to start %s" % test_dom)
- ref = get_vssd_ref(options.ip, options.virt) + ref = get_vssd_ref(ip, virt) 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, guest2_setup = setup_second_guest(ip, virt, cxml2, ref) if status != PASS: raise Exception("Unable to define %s" % test_dom2)
- dom1_mac_list = get_dom_macs(options.ip, test_dom, options.virt) + dom1_mac_list = get_dom_macs(ip, test_dom, virt) if len(dom1_mac_list) != 1: raise Exception("%s has %d macs, expected 1" % (test_dom, len(dom1_mac_list)))
- dom2_mac_list = get_dom_macs(options.ip, test_dom2, options.virt) + dom2_mac_list = get_dom_macs(ip, test_dom2, virt) if len(dom2_mac_list) != 2: raise Exception("%s has %d macs, expected 2" % (test_dom2, len(dom2_mac_list))) @@ -159,8 +164,14 @@ 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) + if guest1_setup == "start": + cxml.cim_destroy(ip) + + if guest1_setup == "define": + cxml.undefine(ip) + + if guest2_setup == "define": + cxml2.undefine(ip)
return status
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Thanks and Regards, Deepti B. Kalakeri IBM Linux Technology Center deeptik@linux.vnet.ibm.com