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

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1213188838 25200 # Node ID 9fb67711f2dfe3010d20862f36160b5a91b36c49 # 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 9fb67711f2df 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 Wed Jun 11 05:53:58 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 @@ def verify_netrasd_values(assoc_info, ne 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 @@ def verify_diskrasd_values(assoc_info, d 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 @@ def verify_memrasd_values(assoc_info, me 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 1213188838 25200 # Node ID 9fb67711f2dfe3010d20862f36160b5a91b36c49 # 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 9fb67711f2df suites/libvirt-cim/lib/XenKvmLib/rasd.py
This is a good idea, since this is done is several places. However, this patch conflicts with Daisy's patch to add support for containers. Maybe you can roll her changes into this patch?
+ + + 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), + } + }
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Deepti B. Kalakeri
-
Kaitlin Rupert