[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 1213262959 25200 # Node ID 6b52040f1dd92532abca3a7698d406f1bc369c7a # Parent b9100cec9aedb9f9243d753111a9a856e9480335 [TEST] Moving the init_list() to rasd.py 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 b9100cec9aed -r 6b52040f1dd9 suites/libvirt-cim/lib/XenKvmLib/rasd.py --- a/suites/libvirt-cim/lib/XenKvmLib/rasd.py Wed Jun 11 03:38:49 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/rasd.py Thu Jun 12 02:29:19 2008 -0700 @@ -21,28 +21,96 @@ # 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' +global proc_cn, mem_cn, net_cn, disk_cn + + +mem_units_rev = 529 +proc_instid_rev = 590 + +def rasd_init_list(vsxml, virt, test_disk, test_dom, test_mac, test_mem): + """ + Creating the lists that will be used for comparisons. + """ + global proc_cn, mem_cn, net_cn, disk_cn + 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") + 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' %(test_dom, 0) + else: + proc_id = '%s/%s' %(test_dom, "proc") + + + rasd_values = { + proc_cn : { + "InstanceID" : proc_id, + "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 , + "ntype" : [ 'bridge', 'user', + 'network', 'ethernet'] + }, + mem_cn : { + "InstanceID" : '%s/%s' %(test_dom, "mem"), + "ResourceType" : 4, + "AllocationUnits" : alloc_units, + "VirtualQuantity" : (test_mem * 1024), + } + } + except Exception, details: + logger.error("Exception: In fn rasd_init_list %s", details) + return FAIL, rasd_values + + 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 def CCN_err(assoc_info, list): - Globals.logger.error("%s Mismatch", 'CreationClassName') - Globals.logger.error("Returned %s instead of %s", \ + 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", \ + 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", \ + 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): @@ -63,12 +131,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,8 +147,8 @@ 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 ", \ + logger.error("%s Mismatch", 'Address') + logger.error("Returned %s instead of %s ", \ assoc_info['Address'], diskrasd_list['Address']) status = FAIL return status @@ -96,13 +162,13 @@ 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 ", \ + 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 ", \ + logger.error("%s mismatch", 'VirtualQuantity') + logger.error("Returned %s instead of %s ", \ assoc_info['VirtualQuantity'], memrasd_list['VirtualQuantity']) status = FAIL return status

Deepti B. Kalakeri wrote:
# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1213262959 25200 # Node ID 6b52040f1dd92532abca3a7698d406f1bc369c7a # Parent b9100cec9aedb9f9243d753111a9a856e9480335 [TEST] Moving the init_list() to rasd.py
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 b9100cec9aed -r 6b52040f1dd9 suites/libvirt-cim/lib/XenKvmLib/rasd.py --- a/suites/libvirt-cim/lib/XenKvmLib/rasd.py Wed Jun 11 03:38:49 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/rasd.py Thu Jun 12 02:29:19 2008 -0700 @@ -21,28 +21,96 @@ #
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' +global proc_cn, mem_cn, net_cn, disk_cn
No need to define these as global.
+ + +mem_units_rev = 529 +proc_instid_rev = 590 + +def rasd_init_list(vsxml, virt, test_disk, test_dom, test_mac, test_mem): + """ + Creating the lists that will be used for comparisons. + """ + global proc_cn, mem_cn, net_cn, disk_cn
Same here. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1213263044 25200 # Node ID facf3365deb1a39cc11c6d252674407eb4b93f88 # Parent 6b52040f1dd92532abca3a7698d406f1bc369c7a [TEST] Fixing the 02_hostsystem_to_rasd.py tc of HostSystem. 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 6b52040f1dd9 -r facf3365deb1 suites/libvirt-cim/cimtest/HostSystem/02_hostsystem_to_rasd.py --- a/suites/libvirt-cim/cimtest/HostSystem/02_hostsystem_to_rasd.py Thu Jun 12 02:29:19 2008 -0700 +++ b/suites/libvirt-cim/cimtest/HostSystem/02_hostsystem_to_rasd.py Thu Jun 12 02:30:44 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,12 @@ 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 = 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 1213263209 25200 # Node ID dfb6d5b51653712ed15387b76e3ddf89098d92d2 # Parent facf3365deb1a39cc11c6d252674407eb4b93f88 [TEST] Updating the 41_cs_to_settingdefinestate.py tc of ComputerSystem. 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 facf3365deb1 -r dfb6d5b51653 suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py --- a/suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py Thu Jun 12 02:30:44 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py Thu Jun 12 02:33:29 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,43 +77,7 @@ test_vcpus = 1 test_mem = 128 test_mac = "00:11:22:33:44:aa" -test_disk = 'xvda' vstype = 'Xen' - - -def rasd_init_list(): - """ - 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(): """ @@ -142,19 +108,27 @@ } 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) + if virt == "Xen": + test_disk = "xvda" + else: + test_disk = "hda" + 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, test_disk + def print_err(err, detail, cn): logger.error(err % cn) @@ -168,7 +142,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 +153,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 +175,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 +197,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_setdefstate_verify_RASD_build_vssdc_input(server, virt, vsxml, test_disk, + sd_assoc_info): status = PASS in_setting_define_state = {} in_vssdc = {} @@ -254,7 +230,11 @@ 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 = 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 +330,23 @@ @do_main(sup_types) def main(): server = main.options.ip - status = setup_env(server) + virt = main.options.virt + status, vsxml, test_disk = 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,26 +354,30 @@ 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_setdefstate_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. @@ -399,14 +385,15 @@ 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 +402,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())

sup_types = ['Xen']
@@ -75,43 +77,7 @@ test_vcpus = 1 test_mem = 128 test_mac = "00:11:22:33:44:aa" -test_disk = 'xvda' vstype = 'Xen'
Instead of vstype, you can use options.virt
+ if virt == "Xen": + test_disk = "xvda" + else: + test_disk = "hda"
Test currently only supports Xen - no need to modify this, just curious if you plan to modify this to support XenFV or KVM in the future.
+ virt_xml = get_class(virt) + vsxml_info = virt_xml(test_dom, mem = test_mem, + vcpus=test_vcpus, + mac = test_mac, + disk = test_disk)
Strange indentation here.
-def get_setdefstate_verify_RASD_build_vssdc_input(server, sd_assoc_info): +def get_setdefstate_verify_RASD_build_vssdc_input(server, virt, vsxml, test_disk, + sd_assoc_info):
Strange indentation here as well.
- status, in_vssdc_list = get_setdefstate_verify_RASD_build_vssdc_input(server, \ - sd_assoc_info) + status, in_vssdc_list = get_setdefstate_verify_RASD_build_vssdc_input(server, + virt, + vsxml, + test_disk, + sd_assoc_info)
And here too. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1213263349 25200 # Node ID bb5f359be87cb3883b45301c8c7a056278d453a0 # Parent dfb6d5b51653712ed15387b76e3ddf89098d92d2 [TEST] 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 dfb6d5b51653 -r bb5f359be87c suites/libvirt-cim/cimtest/RASD/01_verify_rasd_fields.py --- a/suites/libvirt-cim/cimtest/RASD/01_verify_rasd_fields.py Thu Jun 12 02:33:29 2008 -0700 +++ b/suites/libvirt-cim/cimtest/RASD/01_verify_rasd_fields.py Thu Jun 12 02:35:49 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 = rasd_init_list(xml, virt, disk, test_dom, + test_mac, test_mem) + if status != PASS: + return status + + procrasd = rasd_values['%s' %rasd.proc_cn] + netrasd = rasd_values['%s' %rasd.net_cn] + diskrasd = rasd_values['%s' %rasd.disk_cn] + memrasd = rasd_values['%s' %rasd.mem_cn] + if virt == 'LXC': proc_status = 0 disk_status = 0 diff -r dfb6d5b51653 -r bb5f359be87c suites/libvirt-cim/cimtest/RASD/02_enum.py --- a/suites/libvirt-cim/cimtest/RASD/02_enum.py Thu Jun 12 02:33:29 2008 -0700 +++ b/suites/libvirt-cim/cimtest/RASD/02_enum.py Thu Jun 12 02:35:49 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: @@ -176,8 +145,15 @@ logger.error("Exception : %s", details) return FAIL - status = PASS - procrasd, netrasd, diskrasd, memrasd = init_list(virt) + status, rasd_values_list = rasd_init_list(vsxml, virt, test_disk, test_dom, + test_mac, test_mem) + if status != PASS: + return status + + procrasd = rasd_values_list['%s' %rasd.proc_cn] + netrasd = rasd_values_list['%s' %rasd.net_cn] + diskrasd = rasd_values_list['%s' %rasd.disk_cn] + memrasd = rasd_values_list['%s' %rasd.mem_cn] # For each loop # 1) Enumerate one RASD type diff -r dfb6d5b51653 -r bb5f359be87c suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py --- a/suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py Thu Jun 12 02:33:29 2008 -0700 +++ b/suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py Thu Jun 12 02:35:49 2008 -0700 @@ -51,8 +51,9 @@ from XenKvmLib import assoc from XenKvmLib.vxml import get_class from XenKvmLib.classes import get_typed_class +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 from XenKvmLib.const import CIM_REV sup_types = ['Xen', 'KVM', 'XenFV', 'LXC'] @@ -87,44 +88,6 @@ logger.error("Exception : %s", details) return FAIL, vsxml_info return PASS, vsxml_info - -def init_list(virt): - """ - Creating the lists that will be used for comparisons. - """ - procrasd = { - "InstanceID" : '%s/%s' %(test_dom, "proc"), - "ResourceType" : 3, - "CreationClassName": get_typed_class(virt, 'ProcResourceAllocationSettingData') - } - if CIM_REV < proc_rev: - procrasd['InstanceID'] = '%s/%s' %(test_dom, "0") - - netrasd = { - "InstanceID" : '%s/%s' %(test_dom,test_mac), - "ResourceType" : 10 , - "ntype1": "bridge", - "ntype2": "ethernet", - "CreationClassName": get_typed_class(virt, 'NetResourceAllocationSettingData') - } - - address = vsxml.xml_get_disk_source() - diskrasd = { - "InstanceID" : '%s/%s' %(test_dom, test_disk), - "ResourceType" : 17, - "Address" : address, - "CreationClassName": get_typed_class(virt, 'DiskResourceAllocationSettingData') - } - memrasd = { - "InstanceID" : '%s/%s' %(test_dom, "mem"), - "ResourceType" : 4, - "AllocationUnits" : "KiloBytes", - "VirtualQuantity" : (test_mem * 1024), - "CreationClassName": get_typed_class(virt, 'MemResourceAllocationSettingData') - } - if CIM_REV < mem_rev: - memrasd['AllocationUnits'] = "MegaBytes" - return procrasd, netrasd, diskrasd, memrasd def get_inst_from_list(classname, vssd_list, filter_name, exp_val): status = PASS @@ -199,7 +162,16 @@ return status, vssdc_assoc_info def verify_rasd_values(rasd_values_info): - procrasd, netrasd, diskrasd, memrasd = init_list(virt) + status, rasd_values = rasd_init_list(vsxml, virt, test_disk, test_dom, + test_mac, test_mem) + if status != PASS: + return status + + procrasd = rasd_values['%s' %rasd.proc_cn] + netrasd = rasd_values['%s' %rasd.net_cn] + diskrasd = rasd_values['%s' %rasd.disk_cn] + memrasd = rasd_values['%s' %rasd.mem_cn] + try: for rasd_instance in rasd_values_info: CCName = rasd_instance.classname

Deepti B. Kalakeri wrote:
# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1213263349 25200 # Node ID bb5f359be87cb3883b45301c8c7a056278d453a0 # Parent dfb6d5b51653712ed15387b76e3ddf89098d92d2 [TEST] 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 dfb6d5b51653 -r bb5f359be87c suites/libvirt-cim/cimtest/RASD/01_verify_rasd_fields.py
Will need to modify this so it doesn't depend on global proc_cn (etc) values.
diff -r dfb6d5b51653 -r bb5f359be87c suites/libvirt-cim/cimtest/RASD/02_enum.py
Will also need to modify this so it doesn't depend on global proc_cn (etc) values.
- status = PASS - procrasd, netrasd, diskrasd, memrasd = init_list(virt) + status, rasd_values_list = rasd_init_list(vsxml, virt, test_disk, test_dom, + test_mac, test_mem)
Unusually indentation here.
diff -r dfb6d5b51653 -r bb5f359be87c suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py
Will also need to modify this so it doesn't depend on global proc_cn (etc) values. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Deepti B. Kalakeri
-
Kaitlin Rupert