[PATCH 0 of 3] Modifying rasd.py to include support for StoragevolRASD.

# HG changeset patch # User Deepti B.Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1249366441 25200 # Node ID a95d4b521cf64765ef1f441d9cdb0f82fd6c37b2 # Parent c1d8168e6ff0a7883fac582d19af5e68ad979bbc [TEST] Modifying rasd.py lib to support StorageVolRASD. Tested with KVM on F10 and current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r c1d8168e6ff0 -r a95d4b521cf6 suites/libvirt-cim/lib/XenKvmLib/rasd.py --- a/suites/libvirt-cim/lib/XenKvmLib/rasd.py Thu Jul 30 22:40:39 2009 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/rasd.py Mon Aug 03 23:14:01 2009 -0700 @@ -47,6 +47,8 @@ dccn = 'DisplayController' pdcn = 'PointingDevice' +libvirt_rasd_storagepool_changes = 934 + def rasd_init_list(vsxml, virt, t_disk, t_dom, t_mac, t_mem, server): """ Creating the lists that will be used for comparisons. @@ -319,6 +321,8 @@ exp_base_num = 4 exp_cdrom = 4 + # StoragePoolRASD record 1 for each of Min, Max, Default, and Incr + exp_storagevol_rasd = 4 exp_len = exp_base_num if id == "DiskPool/0": @@ -351,6 +355,9 @@ volumes = enum_volumes(virt, ip, id[1]) exp_len = (volumes * exp_base_num) + exp_cdrom + if rev >= libvirt_rasd_storagepool_changes and virt != 'LXC': + exp_len += exp_storagevol_rasd + return exp_len def get_exp_net_rasd_len(virt, rev, id):

# HG changeset patch # User Deepti B.Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1249366870 25200 # Node ID 99510f152e670db0948e26add79869f266b826e5 # Parent a95d4b521cf64765ef1f441d9cdb0f82fd6c37b2 [TEST] Fixing HostSystem/03_hs_to_settdefcap.py Tested with KVM on F10 and current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r a95d4b521cf6 -r 99510f152e67 suites/libvirt-cim/cimtest/HostSystem/03_hs_to_settdefcap.py --- a/suites/libvirt-cim/cimtest/HostSystem/03_hs_to_settdefcap.py Mon Aug 03 23:14:01 2009 -0700 +++ b/suites/libvirt-cim/cimtest/HostSystem/03_hs_to_settdefcap.py Mon Aug 03 23:21:10 2009 -0700 @@ -48,11 +48,12 @@ from XenKvmLib.vxml import XenXML, KVMXML, get_class from XenKvmLib.classes import get_typed_class from CimTest.Globals import logger, CIM_ERROR_ASSOCIATORNAMES -from XenKvmLib.const import do_main +from XenKvmLib.const import do_main, get_provider_version from CimTest.ReturnCodes import PASS, FAIL from XenKvmLib.test_xml import testxml from XenKvmLib.test_doms import destroy_and_undefine_all -from XenKvmLib.rasd import get_exp_template_rasd_len +from XenKvmLib.rasd import get_exp_template_rasd_len, \ + libvirt_rasd_storagepool_changes sup_types = ['Xen', 'KVM', 'XenFV', 'LXC'] test_dom = "domgst_test" @@ -203,13 +204,20 @@ rtype = { "%s_MemResourceAllocationSettingData" % virt : 4 } else: rtype = { - "%s_DiskResourceAllocationSettingData" % virt : 17, \ - "%s_DiskPoolResourceAllocationSettingData" % virt : 17, \ - "%s_MemResourceAllocationSettingData" % virt : 4, \ - "%s_NetResourceAllocationSettingData" % virt : 10, \ - "%s_NetPoolResourceAllocationSettingData" % virt : 10, \ + "%s_DiskResourceAllocationSettingData" % virt : 17, + "%s_DiskPoolResourceAllocationSettingData" % virt : 17, + "%s_MemResourceAllocationSettingData" % virt : 4, + "%s_NetResourceAllocationSettingData" % virt : 10, + "%s_NetPoolResourceAllocationSettingData" % virt : 10, "%s_ProcResourceAllocationSettingData" % virt : 3 } + + curr_cim_rev, changeset = get_provider_version(virt, server) + if curr_cim_rev >= libvirt_rasd_storagepool_changes: + sto_vol_cn = 'StorageVolumeResourceAllocationSettingData' + storagevol_rasd_cn = get_typed_class(virt, sto_vol_cn) + rtype[storagevol_rasd_cn] = 32768 + try: for ap in alloccap: assoc_info = Associators(server, @@ -244,7 +252,8 @@ def check_rasd_vals(inst, rt): try: if inst['ResourceType'] != rt: - logger.error("In ResourceType for %s ", rt) + logger.error("ResourceType Mismatch, Got '%s' Expected '%s' ", + inst['ResourceType'], rt) return FAIL except Exception, detail: logger.error("Error checking RASD attribute values %s", detail)

} + + curr_cim_rev, changeset = get_provider_version(virt, server) + if curr_cim_rev >= libvirt_rasd_storagepool_changes: + sto_vol_cn = 'StorageVolumeResourceAllocationSettingData' + storagevol_rasd_cn = get_typed_class(virt, sto_vol_cn) + rtype[storagevol_rasd_cn] = 32768
Instead of setting the value 32768 here, can you create a variable in const.py, that way this value has more meaning. We should have done the same for the other values, but that's something we can clean up later. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
} + + curr_cim_rev, changeset = get_provider_version(virt, server) + if curr_cim_rev >= libvirt_rasd_storagepool_changes: + sto_vol_cn = 'StorageVolumeResourceAllocationSettingData' + storagevol_rasd_cn = get_typed_class(virt, sto_vol_cn) + rtype[storagevol_rasd_cn] = 32768
Instead of setting the value 32768 here, can you create a variable in const.py, that way this value has more meaning.
We should have done the same for the other values, but that's something we can clean up later.
done. -- Thanks and Regards, Deepti B. Kalakeri IBM Linux Technology Center deeptik@linux.vnet.ibm.com

# HG changeset patch # User Deepti B.Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1249366976 25200 # Node ID 09572d5c821abbe37abd9f9a773345c4fe6266aa # Parent 99510f152e670db0948e26add79869f266b826e5 [TEST] Fixing SettingsDefineCapabilities/01_forward.py Tested with KVM on F10 and current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 99510f152e67 -r 09572d5c821a suites/libvirt-cim/cimtest/SettingsDefineCapabilities/01_forward.py --- a/suites/libvirt-cim/cimtest/SettingsDefineCapabilities/01_forward.py Mon Aug 03 23:21:10 2009 -0700 +++ b/suites/libvirt-cim/cimtest/SettingsDefineCapabilities/01_forward.py Mon Aug 03 23:22:56 2009 -0700 @@ -59,11 +59,13 @@ from XenKvmLib import enumclass from XenKvmLib.xm_virt_util import virsh_version from CimTest.ReturnCodes import PASS, FAIL, SKIP -from CimTest.Globals import logger, CIM_ERROR_GETINSTANCE, CIM_ERROR_ASSOCIATORS -from XenKvmLib.const import do_main, default_pool_name, default_network_name +from CimTest.Globals import logger, CIM_ERROR_GETINSTANCE, \ + CIM_ERROR_ASSOCIATORS +from XenKvmLib.const import do_main, default_pool_name, default_network_name, \ + get_provider_version from XenKvmLib.classes import get_typed_class -from XenKvmLib.common_util import print_field_error -from XenKvmLib.rasd import get_exp_template_rasd_len +from XenKvmLib.rasd import get_exp_template_rasd_len, \ + libvirt_rasd_storagepool_changes platform_sup = ['Xen', 'KVM', 'XenFV', 'LXC'] @@ -86,7 +88,7 @@ sys.exit(FAIL) return instance -def init_list(virt, pool): +def init_list(virt, server, pool): """ Creating the lists that will be used for comparisons. """ @@ -98,7 +100,6 @@ if virt == 'LXC': instlist = [ pool[1].InstanceID ] - cllist = [ memrasd ] rtype = { memrasd : 4 } else: instlist = [ @@ -107,20 +108,27 @@ pool[2].InstanceID, pool[3].InstanceID ] - cllist = [ diskrasd, memrasd, netrasd, procrasd ] + rtype = { diskrasd : 17, memrasd : 4, netrasd : 10, procrasd : 3 } + + curr_cim_rev, changeset = get_provider_version(virt, server) + if curr_cim_rev >= libvirt_rasd_storagepool_changes: + sto_vol_cn = 'StorageVolumeResourceAllocationSettingData' + storagevol_rasd_cn = get_typed_class(virt, sto_vol_cn) + rtype[storagevol_rasd_cn] = 32768 + rangelist = { "Default" : 0, "Minimum" : 1, "Maximum" : 2, "Increment" : 3 } - return instlist, cllist, rtype, rangelist + return instlist, rtype, rangelist def get_pool_info(virt, server, devid, poolname=""): pool_cname = get_typed_class(virt, poolname) @@ -147,21 +155,21 @@ return PASS, pool_set -def verify_rasd_fields(loop, assoc_info, cllist, rtype, rangelist): +def verify_rasd_fields(assoc_info, rtype, rangelist): for inst in assoc_info: - if inst.classname != cllist[loop]: - print_field_error("Classname", inst.classname, cllist[loop]) + if not inst.classname in rtype.keys(): + logger.error("Classname Mismatch, '%s' not in '%s'", + inst.classname, rtype.keys()) return FAIL - if inst['ResourceType'] != rtype[cllist[loop]]: - print_field_error("ResourceType", inst['ResourceType'], - rtype[cllist[loop]]) + if inst['ResourceType'] != rtype[inst.classname]: + logger.error("ResourceType Mismatch, got '%s' expected '%s'", + inst['ResourceType'], rtype[inst.classname]) return FAIL return PASS def verify_sdc_with_ac(virt, server, pool): - loop = 0 - instlist, cllist, rtype, rangelist = init_list(virt, pool) + instlist, rtype, rangelist = init_list(virt, server, pool) assoc_cname = get_typed_class(virt, "SettingsDefineCapabilities") cn = get_typed_class(virt, "AllocationCapabilities") for instid in sorted(instlist): @@ -176,12 +184,9 @@ " of %i", assoc_cname, len(assoc_info), exp_len) status = FAIL break - status = verify_rasd_fields(loop, assoc_info, cllist, rtype, - rangelist) + status = verify_rasd_fields(assoc_info, rtype, rangelist) if status != PASS: break - else: - loop = loop + 1 except Exception, detail: logger.error(CIM_ERROR_ASSOCIATORS, assoc_cname)

+ + curr_cim_rev, changeset = get_provider_version(virt, server) + if curr_cim_rev >= libvirt_rasd_storagepool_changes: + sto_vol_cn = 'StorageVolumeResourceAllocationSettingData' + storagevol_rasd_cn = get_typed_class(virt, sto_vol_cn) + rtype[storagevol_rasd_cn] = 32768
Same here, can you use a const value?
@@ -176,12 +184,9 @@ " of %i", assoc_cname, len(assoc_info), exp_len) status = FAIL break - status = verify_rasd_fields(loop, assoc_info, cllist, rtype, - rangelist) + status = verify_rasd_fields(assoc_info, rtype, rangelist) if status != PASS: break - else: - loop = loop + 1
except Exception, detail: logger.error(CIM_ERROR_ASSOCIATORS, assoc_cname)
I like the changes here to get rid of the loop. Make the test a little cleaner I think. Thanks! -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
+ + curr_cim_rev, changeset = get_provider_version(virt, server) + if curr_cim_rev >= libvirt_rasd_storagepool_changes: + sto_vol_cn = 'StorageVolumeResourceAllocationSettingData' + storagevol_rasd_cn = get_typed_class(virt, sto_vol_cn) + rtype[storagevol_rasd_cn] = 32768
Same here, can you use a const value?
@@ -176,12 +184,9 @@ " of %i", assoc_cname, len(assoc_info), exp_len) status = FAIL break - status = verify_rasd_fields(loop, assoc_info, cllist, rtype, - rangelist) + status = verify_rasd_fields(assoc_info, rtype, rangelist) if status != PASS: break - else: - loop = loop + 1 except Exception, detail: logger.error(CIM_ERROR_ASSOCIATORS, assoc_cname)
I like the changes here to get rid of the loop. Make the test a little cleaner I think.
Thanks!
done. -- Thanks and Regards, Deepti B. Kalakeri IBM Linux Technology Center deeptik@linux.vnet.ibm.com
participants (3)
-
Deepti B Kalakeri
-
Deepti B. Kalakeri
-
Kaitlin Rupert