[PATCH 0 of 4] [TEST] Moving the init_list() to rasd.py

Moving the init_list() fn for RASD related tc to lib. Modifying the affected tc to use the new rasd_init_list().

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1213615823 25200 # Node ID 36a1ac9fce4185f796f0a07b7f31c107b94f3ed7 # Parent 6900d7da2228de4e48cb9919b61dcdda7af500c9 [TEST] #2 Moving the init_list() to rasd.py Changes from patch 1 to 2: ------------------------- 1) Removed the globals used. 2) Modified rasd_init_list() to also return the list of rasd_values indices. Patch 1 -------- 1) Most of the tc use init_list() fn to verify the RASD values, hence moved it to rasd.py. 2) Added the logic to pick up the networktype used by the guest while creating to verify the RASD values. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 6900d7da2228 -r 36a1ac9fce41 suites/libvirt-cim/lib/XenKvmLib/rasd.py --- a/suites/libvirt-cim/lib/XenKvmLib/rasd.py Fri Jun 13 14:41:52 2008 +0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/rasd.py Mon Jun 16 04:30:23 2008 -0700 @@ -21,29 +21,104 @@ # import sys -from CimTest import Globals from CimTest.Globals import log_param, logger from CimTest.ReturnCodes import FAIL, PASS +from XenKvmLib.const import CIM_REV +from XenKvmLib import vxml +from XenKvmLib.classes import get_typed_class + pasd_cn = 'ProcResourceAllocationSettingData' nasd_cn = 'NetResourceAllocationSettingData' dasd_cn = 'DiskResourceAllocationSettingData' masd_cn = 'MemResourceAllocationSettingData' +proccn = 'Processor' +memcn = 'Memory' +netcn = 'NetworkPort' +diskcn = 'LogicalDisk' + + +mem_units_rev = 529 +proc_instid_rev = 590 + +def rasd_init_list(vsxml, virt, t_disk, t_dom, t_mac, t_mem): + """ + Creating the lists that will be used for comparisons. + """ + rasd_values = { } + proc_cn = get_typed_class(virt, proccn) + mem_cn = get_typed_class(virt, memcn) + net_cn = get_typed_class(virt, netcn) + disk_cn = get_typed_class(virt, diskcn) + + in_list = { 'proc' : proc_cn, + 'mem' : mem_cn, + 'net' : net_cn, + 'disk' : disk_cn + } + try: + + disk_path = vsxml.xml_get_disk_source() + + if CIM_REV < mem_units_rev: + alloc_units = "MegaBytes" + else: + alloc_units = "KiloBytes" + + if CIM_REV < proc_instid_rev: + proc_id = '%s/%s' %(t_dom, 0) + else: + proc_id = '%s/%s' %(t_dom, "proc") + + + rasd_values = { + proc_cn : { + "InstanceID" : proc_id, + "ResourceType" : 3, + }, + disk_cn : { + "InstanceID" : '%s/%s' %(t_dom, t_disk), + "ResourceType" : 17, + "Address" : disk_path, + }, + net_cn : { + "InstanceID" : '%s/%s' %(t_dom, t_mac), + "ResourceType" : 10 , + "ntype" : [ 'bridge', 'user', + 'network', 'ethernet'] + }, + mem_cn : { + "InstanceID" : '%s/%s' %(t_dom, "mem"), + "ResourceType" : 4, + "AllocationUnits" : alloc_units, + "VirtualQuantity" : (t_mem * 1024), + } + } + except Exception, details: + logger.error("Exception: In fn rasd_init_list %s", details) + return FAIL, rasd_values, in_list + + nettype = vsxml.xml_get_net_type() + if not nettype in rasd_values[net_cn]['ntype']: + logger.info("Adding the %s net type", nettype) + rasd_values[net_cn]['ntype'].append(nettype) + + return PASS, rasd_values, in_list def CCN_err(assoc_info, list): - Globals.logger.error("%s Mismatch", 'CreationClassName') - Globals.logger.error("Returned %s instead of %s", \ - assoc_info['CreationClassName'], list['CreationClassName']) + logger.error("%s Mismatch", 'CreationClassName') + logger.error("Returned %s instead of %s", + assoc_info['CreationClassName'], list['CreationClassName']) def RType_err(assoc_info, list): - Globals.logger.error("%s Mismatch", 'ResourceType') - Globals.logger.error("Returned %s instead of %s", \ - assoc_info['ResourceType'], list['ResourceType']) + logger.error("%s Mismatch", 'ResourceType') + logger.error("Returned %s instead of %s", + assoc_info['ResourceType'], list['ResourceType']) def InstId_err(assoc_info, list): - Globals.logger.error("%s Mismatch", 'InstanceID') - Globals.logger.error("Returned %s instead of %s", \ - assoc_info['InstanceID'], list['InstanceID']) + logger.error("%s Mismatch", 'InstanceID') + logger.error("Returned %s instead of %s", + assoc_info['InstanceID'], list['InstanceID']) def verify_procrasd_values(assoc_info, procrasd_list): status = PASS @@ -63,12 +138,10 @@ if assoc_info['ResourceType'] != netrasd_list['ResourceType']: RType_err(assoc_info, netrasd_list) status = FAIL - if assoc_info['NetworkType'] != netrasd_list['ntype1'] and \ - assoc_info['NetworkType'] != netrasd_list['ntype2']: - Globals.logger.error("%s Mismatch", 'NetworkType') - Globals.logger.error("Returned %s instead of %s or %s", \ - assoc_info['NetworkType'], netrasd_list['ntype1'], - netrasd_list['ntype2']) + if not assoc_info['NetworkType'] in netrasd_list['ntype']: + logger.error("%s Mismatch", 'NetworkType') + logger.error("Returned '%s' instead of returning one of %s types", + assoc_info['NetworkType'], netrasd_list['ntype']) status = FAIL return status @@ -81,9 +154,9 @@ RType_err(assoc_info, diskrasd_list) status = FAIL if assoc_info['Address'] != diskrasd_list['Address']: - Globals.logger.error("%s Mismatch", 'Address') - Globals.logger.error("Returned %s instead of %s ", \ - assoc_info['Address'], diskrasd_list['Address']) + logger.error("%s Mismatch", 'Address') + logger.error("Returned %s instead of %s ", + assoc_info['Address'], diskrasd_list['Address']) status = FAIL return status @@ -96,13 +169,15 @@ RType_err(assoc_info, memrasd_list) status = FAIL if assoc_info['AllocationUnits'] != memrasd_list['AllocationUnits']: - Globals.logger.error("%s Mismatch", 'AllocationUnits') - Globals.logger.error("Returned %s instead of %s ", \ - assoc_info['AllocationUnits'], memrasd_list['AllocationUnits']) + logger.error("%s Mismatch", 'AllocationUnits') + logger.error("Returned %s instead of %s ", + assoc_info['AllocationUnits'], + memrasd_list['AllocationUnits']) status = FAIL if assoc_info['VirtualQuantity'] != memrasd_list['VirtualQuantity']: - Globals.logger.error("%s mismatch", 'VirtualQuantity') - Globals.logger.error("Returned %s instead of %s ", \ - assoc_info['VirtualQuantity'], memrasd_list['VirtualQuantity']) + logger.error("%s mismatch", 'VirtualQuantity') + logger.error("Returned %s instead of %s ", + assoc_info['VirtualQuantity'], + memrasd_list['VirtualQuantity']) status = FAIL return status

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1213615884 25200 # Node ID 15b3d305bec5e26313bf96824a670afe91aae357 # Parent 36a1ac9fce4185f796f0a07b7f31c107b94f3ed7 [TEST] #2 Fixing the 02_hostsystem_to_rasd.py tc of HostSystem. Changes from Patch 1 to 2: -------------------------- 1) Updated the return value of the rasd_init_list(). Patch 1: -------- 1) Fixing the tc failure bcs of the modifications that was done to default network type. 2) Using the rasd_init_list() fn of the rasd.py . Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 36a1ac9fce41 -r 15b3d305bec5 suites/libvirt-cim/cimtest/HostSystem/02_hostsystem_to_rasd.py --- a/suites/libvirt-cim/cimtest/HostSystem/02_hostsystem_to_rasd.py Mon Jun 16 04:30:23 2008 -0700 +++ b/suites/libvirt-cim/cimtest/HostSystem/02_hostsystem_to_rasd.py Mon Jun 16 04:31:24 2008 -0700 @@ -57,7 +57,7 @@ CIM_ERROR_ASSOCIATORS from CimTest.ReturnCodes import PASS, FAIL from XenKvmLib.rasd import verify_procrasd_values, verify_netrasd_values, \ -verify_diskrasd_values, verify_memrasd_values +verify_diskrasd_values, verify_memrasd_values, rasd_init_list from XenKvmLib.const import CIM_REV sup_types = ['Xen', 'KVM', 'XenFV'] @@ -69,47 +69,6 @@ test_mac = "00:11:22:33:44:aa" rev = 529 proc_instid_rev = 590 - -def init_list(vsxml, virt="Xen"): - """ - Creating the lists that will be used for comparisons. - """ - disk_path = vsxml.xml_get_disk_source() - proc_cn = get_typed_class(virt, "Processor") - mem_cn = get_typed_class(virt, "Memory") - net_cn = get_typed_class(virt, "NetworkPort") - disk_cn = get_typed_class(virt, "LogicalDisk") - - rasd_values = { - proc_cn : { - "InstanceID" : '%s/%s' %(test_dom, "proc"), - "ResourceType" : 3, - }, - disk_cn : { - "InstanceID" : '%s/%s' %(test_dom, test_disk), - "ResourceType" : 17, - "Address" : disk_path, - }, - net_cn : { - "InstanceID" : '%s/%s' %(test_dom,test_mac), - "ResourceType" : 10 , - "ntype1": "bridge", - "ntype2": "ethernet", - }, - mem_cn : { - "InstanceID" : '%s/%s' %(test_dom, "mem"), - "ResourceType" : 4, - "AllocationUnits" : "KiloBytes", - "VirtualQuantity" : (test_mem * 1024), - } - } - if CIM_REV < rev: - rasd_values[mem_cn]['AllocationUnits'] = "MegaBytes" - - if CIM_REV < proc_instid_rev: - rasd_values[proc_cn]['InstanceID'] = '%s/%s' %(test_dom, 0) - - return rasd_values def setup_env(server, virt="Xen"): vsxml_info = None @@ -185,7 +144,13 @@ classname_keyvalue = sd_assoc_info[i]['CreationClassName'] deviceid = sd_assoc_info[i]['DeviceID'] in_setting_define_state[classname_keyvalue] = deviceid - rasd_values = init_list(vsxml, virt) + + status, rasd_values, in_list = rasd_init_list(vsxml, virt, + test_disk, test_dom, + test_mac, test_mem) + if status != PASS: + return status + an = get_typed_class(virt, 'SettingsDefineState') sccn = get_typed_class(virt, 'ComputerSystem') for cn, devid in sorted(in_setting_define_state.items()):

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1213616987 25200 # Node ID 943322cb9721cdd9b3dc0e247f7119cda05dcb28 # Parent 15b3d305bec5e26313bf96824a670afe91aae357 [TEST] #2 Updating the 41_cs_to_settingdefinestate.py tc of ComputerSystem. Changes: ------- Patch 2 to 1: ------------ 1) Addressed the indentation comments. 2) updated the rasd_init_list() for return values. Will update the tc for XenFV,KVM later. Patch1 ------- 1) Updated the tc to use vxml fn(). 2) Updated the tc to use rasd_init_list() fn of rasd.py. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 15b3d305bec5 -r 943322cb9721 suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py --- a/suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py Mon Jun 16 04:31:24 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py Mon Jun 16 04:49:47 2008 -0700 @@ -59,15 +59,17 @@ import sys from VirtLib import utils from XenKvmLib import computersystem -from XenKvmLib.test_xml import testxml, disk_path -from XenKvmLib.test_doms import test_domain_function, destroy_and_undefine_all +from XenKvmLib.vxml import get_class +from XenKvmLib.classes import get_typed_class +from XenKvmLib.test_doms import destroy_and_undefine_all from XenKvmLib.assoc import Associators, AssociatorNames from CimTest.Globals import logger, CIM_ERROR_ASSOCIATORNAMES, \ CIM_ERROR_ASSOCIATORS from CimTest.Globals import do_main from CimTest.ReturnCodes import PASS, FAIL +from XenKvmLib import rasd from XenKvmLib.rasd import verify_procrasd_values, verify_netrasd_values, \ -verify_diskrasd_values, verify_memrasd_values +verify_diskrasd_values, verify_memrasd_values, rasd_init_list sup_types = ['Xen'] @@ -75,55 +77,18 @@ test_vcpus = 1 test_mem = 128 test_mac = "00:11:22:33:44:aa" -test_disk = 'xvda' -vstype = 'Xen' +test_disk = "xvda" - -def rasd_init_list(): +def vssd_init_list(virt): """ Creating the lists that will be used for comparisons. """ - proc_rasd = { - "InstanceID" : '%s/%s' %(test_dom, "proc"),\ - "ResourceType" : 3,\ - } - - disk_rasd = { - "InstanceID" : '%s/%s' %(test_dom, test_disk), \ - "ResourceType" : 17, \ - "Address" : disk_path, \ - } - net_rasd = { - "InstanceID" : '%s/%s' %(test_dom,test_mac), \ - "ResourceType" : 10 , \ - "ntype1": "bridge", \ - "ntype2": "ethernet", \ - } - mem_rasd = { - "InstanceID" : '%s/%s' %(test_dom, "mem"), \ - "ResourceType" : 4, \ - "AllocationUnits" : "KiloBytes",\ - "VirtualQuantity" : (test_mem * 1024), \ - } - rasd_values = { "Xen_Processor" : proc_rasd, \ - "Xen_LogicalDisk" : disk_rasd, \ - "Xen_NetworkPort" : net_rasd, \ - "Xen_Memory" : mem_rasd - } - return rasd_values - - -def vssd_init_list(): - """ - Creating the lists that will be used for comparisons. - """ - vssd_values = { 'Caption' : "Virtual System", \ - 'InstanceID' : '%s:%s' % (vstype, test_dom), \ + 'InstanceID' : '%s:%s' % (virt, test_dom), \ 'ElementName' : test_dom, \ 'VirtualSystemIdentifier' : test_dom, \ - 'VirtualSystemType' : vstype, \ + 'VirtualSystemType' : virt, \ 'Classname' : "Xen_VirtualSystemSettingData" } @@ -142,19 +107,23 @@ } return cs_values -def setup_env(server): +def setup_env(server, virt): + vsxml_info = None status = PASS destroy_and_undefine_all(server) - test_xml = testxml(test_dom, mem = test_mem, \ - vcpus = test_vcpus, \ - mac = test_mac, \ - disk = test_disk) + virt_xml = get_class(virt) + vsxml_info = virt_xml(test_dom, mem = test_mem, + vcpus=test_vcpus, + mac = test_mac, + disk = test_disk) - ret = test_domain_function(test_xml, server, cmd = "create") + ret = vsxml_info.create(server) if not ret: logger.error("Failed to create the dom: %s", test_dom) status = FAIL - return status + + return status, vsxml_info + def print_err(err, detail, cn): logger.error(err % cn) @@ -168,7 +137,7 @@ logger.error(err) logger.error(detail) -def get_inst_from_list(server, cn, cs_list, exp_val): +def get_inst_from_list(server, vsxml, cn, cs_list, exp_val): status = PASS ret = -1 inst = None @@ -179,12 +148,12 @@ if ret != PASS: logger.error("%s with %s was not returned" % (cn, exp_val)) - test_domain_function(test_dom, server, "destroy") + vsxml.destroy(server) status = FAIL return status, inst -def get_associatornames_info(server, cn, an, qcn, name): +def get_associatornames_info(server, vsxml, cn, an, qcn, name): status = PASS assoc_info = [] try: @@ -201,11 +170,11 @@ status = FAIL if status != PASS: - test_domain_function(test_dom, server, "destroy") + vsxml.destroy(server) return status, assoc_info -def get_associators_info(server, cn, an, qcn, instid): +def get_associators_info(server, vsxml, cn, an, qcn, instid): status = PASS assoc_info = [] try: @@ -223,17 +192,19 @@ status = FAIL if status != PASS: - test_domain_function(test_dom, server, "destroy") + vsxml.destroy(server) return status, assoc_info def check_len(an, assoc_list_info, qcn, exp_len): if len(assoc_list_info) != exp_len: - logger.error("%s returned %i %s objects" % (an, len(assoc_list_info), qcn)) + logger.error("%s returned %i %s objects", an, + len(assoc_list_info), qcn) return FAIL return PASS -def get_setdefstate_verify_RASD_build_vssdc_input(server, sd_assoc_info): +def get_SDS_verify_RASD_build_vssdc_input(server, virt, vsxml, + test_disk, sd_assoc_info): status = PASS in_setting_define_state = {} in_vssdc = {} @@ -254,7 +225,12 @@ return FAIL, in_setting_define_state # Get the rasd values that will be used to compare with the Xen_SettingsDefineState # output. - rasd_values = rasd_init_list() + status, rasd_values, in_list = rasd_init_list(vsxml, virt, test_disk, + test_dom, test_mac, + test_mem) + if status != PASS: + return status + sccn = "Xen_ComputerSystem" an = "Xen_SettingsDefineState" for cn, devid in sorted(in_setting_define_state.items()): @@ -350,21 +326,23 @@ @do_main(sup_types) def main(): server = main.options.ip - status = setup_env(server) + virt = main.options.virt + status, vsxml = setup_env(server, virt) if status != PASS: return status cs_enum = computersystem.enumerate(server) if len(cs_enum) == 0: - test_domain_function(test_dom, server, "destroy") + vsxml.destroy(server) return status cn = cs_enum[0].CreationClassName status, cs_dom = get_inst_from_list(server, + vsxml, cn, cs_enum, test_dom) if status != PASS: - test_domain_function(test_dom, server, "destroy") + vsxml.destroy(server) return status # Creating the cs info list which will be used later for comparison. @@ -372,41 +350,44 @@ if cs_values['EnabledState'] != 2 : logger.error("Improper EnabledState value set for domain %s", test_dom) logger.error("Should have been 2 instead of %s", cs_values['EnabledState']) - test_domain_function(test_dom, server, "destroy") + vsxml.destroy(server) return FAIL cn = cs_dom.CreationClassName an = 'Xen_SystemDevice' qcn = 'Logical Devices' name = test_dom - status, sd_assoc_info = get_associatornames_info(server, cn, an, qcn, name) + status, sd_assoc_info = get_associatornames_info(server, vsxml, + cn, an, qcn, name) if status != PASS or len(sd_assoc_info) == 0: return status - status, in_vssdc_list = get_setdefstate_verify_RASD_build_vssdc_input(server, \ - sd_assoc_info) + status, in_vssdc_list = get_SDS_verify_RASD_build_vssdc_input(server, virt, + vsxml, test_disk, + sd_assoc_info) if status != PASS or len(in_vssdc_list) == 0 : - test_domain_function(test_dom, server, "destroy") + vsxml.destroy(server) return status # Verifying that the in_vssdc_list contains 4 entries one each for mem rasd, # network rasd, processor rasd and disk rasd. exp_len = 4 if check_len(an, in_vssdc_list, qcn, exp_len) != PASS: - test_domain_function(test_dom, server, "destroy") + vsxml.destroy(server) return FAIL # Get the vssd values which will be used for verifying the Xen_VirtualSystemSettingData # output from the Xen_VirtualSystemSettingDataComponent results. - vssd_values = vssd_init_list() + vssd_values = vssd_init_list(virt) an = 'Xen_VirtualSystemSettingDataComponent' qcn = 'Xen_VirtualSystemSettingData' for cn, instid in sorted((in_vssdc_list.items())): - status, vssd_assoc_info = get_associators_info(server, cn, an, qcn, instid) + status, vssd_assoc_info = get_associators_info(server, vsxml, cn, an, qcn, + instid) if status != PASS or len(vssd_assoc_info) == 0: break status = verify_VSSD_values(vssd_assoc_info, vssd_values, an, qcn) if status != PASS: break if status != PASS: - test_domain_function(test_dom, server, "destroy") + vsxml.destroy(server) return status # Since the Xen_VirtualSystemSettingDataComponent returns similar output when queried with # every RASD, we are taking the output of the last associtaion query as inputs for @@ -415,13 +396,13 @@ an = 'Xen_SettingsDefineState' qcn = 'Xen_ComputerSystem' instid = vssd_assoc_info[0]['InstanceID'] - status, cs_assoc_info = get_associators_info(server, cn, an, qcn, instid) + status, cs_assoc_info = get_associators_info(server, vsxml, cn, an, qcn, instid) if status != PASS or len(cs_assoc_info) == 0: return status # verify the results of Xen_SettingsDefineState with the cs_values list that was # built using the output of the enumeration on Xen_ComputerSystem. status = verify_CS_values(cs_assoc_info, cs_values, an, qcn) - test_domain_function(test_dom, server, "destroy") + vsxml.destroy(server) return status if __name__ == "__main__": sys.exit(main())

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1213617321 25200 # Node ID 5cf86e67c88b493c8cbe5e8de9ed03884128ed3a # Parent 943322cb9721cdd9b3dc0e247f7119cda05dcb28 [TEST] #2 Updating the tc to use the rasd_init_list() fn of rasd.py. Changes:
From Patch 1 to 2;
1) updated the rasd_init_list() return values. Patch 1: ------- Updating the tc to use the rasd_init_list() fn of rasd.py. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 943322cb9721 -r 5cf86e67c88b suites/libvirt-cim/cimtest/RASD/01_verify_rasd_fields.py --- a/suites/libvirt-cim/cimtest/RASD/01_verify_rasd_fields.py Mon Jun 16 04:49:47 2008 -0700 +++ b/suites/libvirt-cim/cimtest/RASD/01_verify_rasd_fields.py Mon Jun 16 04:55:21 2008 -0700 @@ -57,6 +57,9 @@ from XenKvmLib.const import CIM_REV from CimTest.Globals import logger from CimTest.ReturnCodes import PASS, FAIL +from XenKvmLib import rasd +from XenKvmLib.rasd import verify_procrasd_values, verify_netrasd_values, \ +verify_diskrasd_values, verify_memrasd_values, rasd_init_list sup_types = ['Xen', 'KVM', 'XenFV', 'LXC'] @@ -64,44 +67,18 @@ test_vcpus = 1 test_mem = 128 test_mac = "00:11:22:33:44:aa" -prev = 531 -mrev = 529 - -def init_list(xml, disk, virt="Xen"): - """ - Creating the lists that will be used for comparisons. - """ - procrasd = { - "InstanceID" : '%s/%s' % (test_dom, "proc"), - "ResourceType" : 3, - "CreationClassName" : get_typed_class(virt, rasd.pasd_cn)} - netrasd = { - "InstanceID" : '%s/%s' % (test_dom,test_mac), - "ResourceType" : 10 , - "ntype1" : "bridge", - "ntype2" : "ethernet", - "CreationClassName" : get_typed_class(virt, rasd.nasd_cn)} - address = xml.xml_get_disk_source() - diskrasd = { - "InstanceID" : '%s/%s' % (test_dom, disk), - "ResourceType" : 17, - "Address" : address, - "CreationClassName" : get_typed_class(virt, rasd.dasd_cn)} - memrasd = { - "InstanceID" : '%s/%s' % (test_dom, "mem"), - "ResourceType" : 4, - "AllocationUnits" : "KiloBytes", - "VirtualQuantity" : (test_mem * 1024), - "CreationClassName" : get_typed_class(virt, rasd.masd_cn)} - if CIM_REV < prev: - procrasd['InstanceID'] = '%s/0' % test_dom - if CIM_REV < mrev: - memrasd['AllocationUnits'] = 'MegaBytes' - - return procrasd, netrasd, diskrasd, memrasd def assoc_values(assoc_info, xml, disk, virt="Xen"): - procrasd, netrasd, diskrasd, memrasd = init_list(xml, disk, virt) + status, rasd_values, in_list = rasd_init_list(xml, virt, disk, test_dom, + test_mac, test_mem) + if status != PASS: + return status + + procrasd = rasd_values['%s' %in_list['proc']] + netrasd = rasd_values['%s' %in_list['net']] + diskrasd = rasd_values['%s' %in_list['disk']] + memrasd = rasd_values['%s' %in_list['mem']] + if virt == 'LXC': proc_status = 0 disk_status = 0 diff -r 943322cb9721 -r 5cf86e67c88b suites/libvirt-cim/cimtest/RASD/02_enum.py --- a/suites/libvirt-cim/cimtest/RASD/02_enum.py Mon Jun 16 04:49:47 2008 -0700 +++ b/suites/libvirt-cim/cimtest/RASD/02_enum.py Mon Jun 16 04:55:21 2008 -0700 @@ -37,6 +37,10 @@ from XenKvmLib.const import CIM_REV from CimTest.Globals import logger from CimTest.ReturnCodes import PASS, FAIL +from XenKvmLib import rasd +from XenKvmLib.rasd import verify_procrasd_values, verify_netrasd_values, \ +verify_diskrasd_values, verify_memrasd_values, rasd_init_list + sup_types = ['Xen', 'KVM', 'XenFV', 'LXC'] @@ -44,41 +48,6 @@ test_vcpus = 1 test_mem = 128 test_mac = "00:11:22:33:44:aa" -prev = 531 -mrev = 529 - -def init_list(virt): - """ - Creating the lists that will be used for comparisons. - """ - proc = { - "InstanceID" : '%s/%s' % (test_dom, "proc"), - "ResourceType" : 3, - "CreationClassName" : get_typed_class(virt, rasd.pasd_cn)} - net = { - "InstanceID" : '%s/%s' % (test_dom,test_mac), - "ResourceType" : 10 , - "ntype1" : "bridge", - "ntype2" : "ethernet", - "CreationClassName" : get_typed_class(virt, rasd.nasd_cn)} - address = vsxml.xml_get_disk_source() - disk = { - "InstanceID" : '%s/%s' % (test_dom, test_disk), - "ResourceType" : 17, - "Address" : address, - "CreationClassName" : get_typed_class(virt, rasd.dasd_cn)} - mem = { - "InstanceID" : '%s/%s' % (test_dom, "mem"), - "ResourceType" : 4, - "AllocationUnits" : "KiloBytes", - "VirtualQuantity" : (test_mem * 1024), - "CreationClassName" : get_typed_class(virt, rasd.masd_cn)} - if CIM_REV < prev: - proc['InstanceID'] = '%s/0' % test_dom - if CIM_REV < mrev: - mem['AllocationUnits'] = 'MegaBytes' - - return proc, net, disk, mem def get_inst_from_list(server, classname, rasd_list, filter_name, exp_val): status = PASS @@ -125,7 +94,7 @@ for rasd_instance in rasd_values_info: CCName = rasd_instance.classname if rasd.pasd_cn in CCName : - status = rasd.verify_procrasd_values(rasd_instance, procrasd,) + status = rasd.verify_procrasd_values(rasd_instance, procrasd) elif rasd.nasd_cn in CCName : status = rasd.verify_netrasd_values(rasd_instance, netrasd) elif rasd.dasd_cn in CCName: @@ -159,7 +128,7 @@ class_list = [get_typed_class(virt, rasd.masd_cn)] else: vsxml = virtxml(test_dom, mem=test_mem, vcpus = test_vcpus, - mac = test_mac, disk = test_disk) + mac = test_mac, disk = test_disk) vsxml.set_vbridge(server) class_list = [ get_typed_class(virt, rasd.dasd_cn), get_typed_class(virt, rasd.masd_cn), @@ -176,8 +145,17 @@ logger.error("Exception : %s", details) return FAIL - status = PASS - procrasd, netrasd, diskrasd, memrasd = init_list(virt) + status, rasd_values_list, in_list = rasd_init_list(vsxml, virt, test_disk, + test_dom, test_mac, + test_mem) + if status != PASS: + return status + + procrasd = rasd_values_list['%s' %in_list['proc']] + netrasd = rasd_values_list['%s' %in_list['net']] + diskrasd = rasd_values_list['%s' %in_list['disk']] + memrasd = rasd_values_list['%s' %in_list['mem']] + # For each loop # 1) Enumerate one RASD type
participants (1)
-
Deepti B. Kalakeri