[PATCH] [TEST] Making use of the lib fn conf_file(), cleanup_restore() and create_diskpool_file()

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1208960298 -19800 # Node ID 70e13e2a2abf57a666c8e4d5029d06ecd017ea69 # Parent 0123ff5809dc099c0b7840fce65eca5bce0921e6 [TEST] Making use of the lib fn conf_file(), cleanup_restore() and create_diskpool_file(). Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 0123ff5809dc -r 70e13e2a2abf suites/libvirt-cim/cimtest/ElementAllocatedFromPool/02_reverse.py --- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/02_reverse.py Wed Apr 23 19:40:48 2008 +0530 +++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/02_reverse.py Wed Apr 23 19:48:18 2008 +0530 @@ -59,6 +59,9 @@ from XenKvmLib.test_xml import testxml_b from XenKvmLib.test_xml import testxml_bridge from XenKvmLib.test_doms import test_domain_function, destroy_and_undefine_all from VirtLib.live import network_by_bridge +from XenKvmLib.common_util import cleanup_restore, test_dpath, \ +create_diskpool_file + sup_types = ['Xen'] @@ -68,42 +71,9 @@ test_mem = 128 test_mem = 128 test_vcpus = 4 test_disk = "xvdb" -test_dpath = "foo" -disk_file = '/tmp/diskpool.conf' -back_disk_file = disk_file + "." + "02_reverse" diskid = "%s/%s" % ("DiskPool", test_dpath) memid = "%s/%s" % ("MemoryPool", 0) procid = "%s/%s" % ("ProcessorPool", 0) - -def conf_file(): - """ - Creating diskpool.conf file. - """ - try: - f = open(disk_file, 'w') - f.write('%s %s' % (test_dpath, '/')) - f.close() - except Exception,detail: - Globals.logger.error("Exception: %s", detail) - status = SKIP - sys.exit(status) - -def clean_up_restore(ip): - """ - Restoring back the original diskpool.conf - file. - """ - try: - if os.path.exists(back_disk_file): - os.remove(disk_file) - move_file(back_disk_file, disk_file) - except Exception, detail: - Globals.logger.error("Exception: %s", detail) - status = SKIP - ret = test_domain_function(test_dom, ip, \ - cmd = "destroy") - sys.exit(status) - def get_or_bail(ip, id, pool_class): """ @@ -116,10 +86,9 @@ def get_or_bail(ip, id, pool_class): except Exception, detail: Globals.logger.error(Globals.CIM_ERROR_GETINSTANCE, '%s', pool_class) Globals.logger.error("Exception: %s", detail) - clean_up_restore(ip) + cleanup_restore() status = FAIL - ret = test_domain_function(test_dom, ip, \ - cmd = "destroy") + ret = test_domain_function(test_dom, ip, cmd = "destroy") sys.exit(status) return instance @@ -133,19 +102,19 @@ def init_list(ip, disk, mem, net, proc): """ pllist = { - "Xen_DiskPool" : disk.InstanceID, \ - "Xen_MemoryPool" : mem.InstanceID, \ - "Xen_NetworkPool" : net.InstanceID, \ + "Xen_DiskPool" : disk.InstanceID, + "Xen_MemoryPool" : mem.InstanceID, + "Xen_NetworkPool" : net.InstanceID, "Xen_ProcessorPool": proc.InstanceID } cllist = [ - "Xen_LogicalDisk", \ - "Xen_Memory", \ - "Xen_NetworkPort", \ + "Xen_LogicalDisk", + "Xen_Memory", + "Xen_NetworkPort", "Xen_Processor" ] - prop_list = ["%s/%s" % (test_dom, test_disk), test_disk, \ - "%s/%s" % (test_dom, "mem"), test_mem, \ + prop_list = ["%s/%s" % (test_dom, test_disk), test_disk, + "%s/%s" % (test_dom, "mem"), test_mem, "%s/%s" % (test_dom, test_mac), test_mac ] proc_prop = [] @@ -166,8 +135,8 @@ def get_spec_fields_list(inst_list, fiel global status specific_fields = { } if (len(inst_list)) != 1: - Globals.logger.error("Got %s record for Memory/Network/LogicalDisk instead of \ -1", len(inst_list)) + Globals.logger.error("Got %s record for Memory/Network/LogicalDisk \ + instead of 1", len(inst_list)) status = FAIL return # verifying the Name field for LogicalDisk @@ -181,7 +150,7 @@ 1", len(inst_list)) else: field_value = ((int(inst_list[0]['NumberOfBlocks'])*4096)/1024) specific_fields = { - "field_name" : field_name,\ + "field_name" : field_name, "field_value" : field_value } except Exception, detail: @@ -254,43 +223,39 @@ def main(): Globals.logger.error("Failed to Create the dom: %s", test_dom) return FAIL - # Taking care of already existing diskconf file - # Creating diskpool.conf if it does not exist - # Otherwise backing up the prev file and create new one. - os.system("rm -f %s" % back_disk_file ) - if not (os.path.exists(disk_file)): - conf_file() - else: - move_file(disk_file, back_disk_file) - conf_file() + # Verify DiskPool on machine + status = create_diskpool_file() + if status != PASS: + ret = test_domain_function(test_dom, server, cmd = "destroy") + return status + try : - disk = get_or_bail(server, id=diskid, \ - pool_class=enumclass.Xen_DiskPool) - mem = get_or_bail(server, id = memid, \ + disk = get_or_bail(server, id=diskid, pool_class=enumclass.Xen_DiskPool) + mem = get_or_bail(server, id = memid, pool_class=enumclass.Xen_MemoryPool) netid = "%s/%s" % ("NetworkPool", virt_network) - net = get_or_bail(server, id = netid, \ + net = get_or_bail(server, id = netid, pool_class=enumclass.Xen_NetworkPool) - proc = get_or_bail(server, id = procid, \ + proc = get_or_bail(server, id = procid, pool_class=enumclass.Xen_ProcessorPool) except Exception, detail: Globals.logger.error("Exception: %s", detail) - clean_up_restore(server) + cleanup_restore() status = FAIL - ret = test_domain_function(test_dom, server, \ - cmd = "destroy") + ret = test_domain_function(test_dom, server, cmd = "destroy") return status - pllist, cllist, prop_list, proc_prop = init_list(server, disk, mem, net, proc) + pllist, cllist, prop_list, proc_prop = init_list(server, disk, mem, net, + proc) # Looping through the pllist to get association for various pools. for cn, instid in sorted(pllist.items()): try: - assoc_info = assoc.Associators(server, \ - "Xen_ElementAllocatedFromPool", \ - cn, \ - InstanceID = instid) + assoc_info = assoc.Associators(server, + "Xen_ElementAllocatedFromPool", + cn, + InstanceID = instid) # Verifying the Creation Class name for all the records returned for each # pool class queried inst_list = get_inst_for_dom(assoc_info) @@ -300,16 +265,16 @@ the specified domain: %s", test_dom) status = FAIL break - assoc_values(assoc_list=inst_list, field="CreationClassName", \ - list=cllist, \ - index=loop) + assoc_values(assoc_list=inst_list, field="CreationClassName", + list=cllist, + index=loop) # verifying the DeviceID if inst_list[0]['CreationClassName'] == 'Xen_Processor': # The DeviceID for the processor varies from 0 to (vcpu - 1 ) list_index = 0 - assoc_values(assoc_list=inst_list, field="DeviceID", \ - list=proc_prop, \ - index=list_index) + assoc_values(assoc_list=inst_list, field="DeviceID", + list=proc_prop, + index=list_index) else: # For LogicalDisk, Memory and NetworkPort if inst_list[0]['CreationClassName'] == 'Xen_LogicalDisk': @@ -318,40 +283,41 @@ the specified domain: %s", test_dom) list_index = 2 else: list_index = 4 # NetworkPort - assoc_values(assoc_list=inst_list, field="DeviceID", \ - list=prop_list, \ - index=list_index) + assoc_values(assoc_list=inst_list, field="DeviceID", + list=prop_list, + index=list_index) if inst_list[0]['CreationClassName'] == 'Xen_LogicalDisk': # verifying the Name field for LogicalDisk - specific_fields = get_spec_fields_list(inst_list,field_name="Name") + specific_fields = get_spec_fields_list(inst_list, field_name="Name") list_index = 1 elif inst_list[0]['CreationClassName'] == 'Xen_Memory': # verifying the NumberOfBlocks allocated for Memory - specific_fields = get_spec_fields_list(inst_list,field_name="NumberOfBlocks") + specific_fields = get_spec_fields_list(inst_list, + field_name="NumberOfBlocks") list_index = 3 else: # verifying the NetworkAddresses for the NetworkPort - specific_fields = get_spec_fields_list(inst_list,field_name="NetworkAddresses") + specific_fields = get_spec_fields_list(inst_list, + field_name="NetworkAddresses") list_index = 5 # NetworkPort - assoc_values(assoc_list=inst_list, field="Other", \ - list=prop_list, \ - index=list_index, \ - specific_fields_list=specific_fields) + assoc_values(assoc_list=inst_list, field="Other", + list=prop_list, + index=list_index, + specific_fields_list=specific_fields) if status != PASS: break else: # The loop variable is used to index the cllist to verify the creationclassname loop = loop + 1 except Exception, detail: - Globals.logger.error(Globals.CIM_ERROR_ASSOCIATORS, \ + Globals.logger.error(Globals.CIM_ERROR_ASSOCIATORS, 'Xen_ElementAllocatedFromPool') Globals.logger.error("Exception: %s", detail) - clean_up_restore(server) + cleanup_restore() status = FAIL - ret = test_domain_function(test_dom, server, \ - cmd = "destroy") - clean_up_restore(server) + ret = test_domain_function(test_dom, server, cmd = "destroy") + cleanup_restore() return status if __name__ == "__main__": sys.exit(main()) diff -r 0123ff5809dc -r 70e13e2a2abf suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py --- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py Wed Apr 23 19:40:48 2008 +0530 +++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py Wed Apr 23 19:48:18 2008 +0530 @@ -40,18 +40,17 @@ from CimTest.Globals import do_main, pla from CimTest.Globals import do_main, platform_sup from XenKvmLib.vxml import get_class from XenKvmLib.classes import get_typed_class +from XenKvmLib.common_util import cleanup_restore, test_dpath, \ +create_diskpool_file bug_no = "88651" test_dom = "hd_domain" test_mac = "00:11:22:33:44:aa" test_vcpus = 1 -id1 = "DiskPool/foo" +id1 = "DiskPool/test_dpath" id2 = "MemoryPool/0" id3 = "NetworkPool/xenbr0" id4 = "ProcessorPool/0" -test_dpath = "foo" -disk_file = '/tmp/diskpool.conf' -back_disk_file = disk_file + "." + "02_reverse" expr_values = { "invalid_keyname" : { 'rc' : pywbem.CIM_ERR_FAILED, \ @@ -62,34 +61,6 @@ expr_values = { 'desc' : 'No such instance' } } - -def conf_file(): - """ - Creating diskpool.conf file. - """ - try: - f = open(disk_file, 'w') - f.write('%s %s' % (test_dpath, '/')) - f.close() - except Exception,detail: - Globals.logger.error("Exception: %s", detail) - status = FAIL - sys.exit(status) - -def clean_up_restore(ip): - """ - Restoring back the original diskpool.conf - file. - """ - try: - if os.path.exists(back_disk_file): - os.remove(disk_file) - move_file(back_disk_file, disk_file) - except Exception, detail: - Globals.logger.error("Exception: %s", detail) - status = FAIL - vsxml.undefine(ip) - sys.exit(status) def err_invalid_ccname(): # This is used to verify the that the @@ -212,14 +183,12 @@ def main(): vsxml = get_class(virt)(test_dom, vcpus = test_vcpus, mac = test_mac, \ disk = test_disk) - if (os.path.exists(back_disk_file)): - os.unlink(back_disk_file) + # Verify DiskPool on machine + status = create_diskpool_file() + if status != PASS: + ret = test_domain_function(test_dom, server, cmd = "destroy") + return status - if not (os.path.exists(disk_file)): - conf_file() - else: - move_file(disk_file, back_disk_file) - conf_file() ret = vsxml.define(options.ip) if not ret: Globals.logger.error("Failed to define the dom: %s", test_dom) @@ -240,7 +209,7 @@ def main(): if ret: Globals.logger.error("------FAILED: Invalid CCName.------") return ret - clean_up_restore(options.ip) + cleanup_restore() vsxml.undefine(options.ip) return PASS if __name__ == "__main__": diff -r 0123ff5809dc -r 70e13e2a2abf suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py --- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py Wed Apr 23 19:40:48 2008 +0530 +++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py Wed Apr 23 19:48:18 2008 +0530 @@ -41,6 +41,8 @@ from CimTest.Globals import do_main, pla from CimTest.Globals import do_main, platform_sup from XenKvmLib.vxml import get_class from XenKvmLib.classes import get_typed_class +from XenKvmLib.common_util import cleanup_restore, test_dpath, \ +create_diskpool_file sup_types = ['Xen', 'KVM', 'XenFV'] bug_no = "88651" @@ -49,49 +51,16 @@ test_mac = "00:11:22:33:44:aa" test_mac = "00:11:22:33:44:aa" test_vcpus = 1 exp_list = [ - {'desc' : "No such instance (SystemName)", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, \ - {'desc' : "No DeviceID specified", 'rc' : pywbem.CIM_ERR_FAILED}, \ - {'desc' : "No such instance", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, \ - {'desc' : "One or more parameter values passed to the method were invalid", \ - 'rc' : pywbem.CIM_ERR_INVALID_PARAMETER}, \ - {'desc' : "No such instance (CreationClassName)", 'rc' : pywbem.CIM_ERR_NOT_FOUND }, \ - {'desc' : "No such instance (SystemCreationClassName)", 'rc' : \ - pywbem.CIM_ERR_NOT_FOUND }, + {'desc' : "No such instance (SystemName)", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, + {'desc' : "No DeviceID specified", 'rc' : pywbem.CIM_ERR_FAILED}, + {'desc' : "No such instance", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, + {'desc' : "CIM_ERR_INVALID_PARAMETER", + 'rc' : pywbem.CIM_ERR_INVALID_PARAMETER}, + {'desc' : "No such instance (CreationClassName)", + 'rc' : pywbem.CIM_ERR_NOT_FOUND }, + {'desc' : "No such instance (SystemCreationClassName)", + 'rc' : pywbem.CIM_ERR_NOT_FOUND }, ] - - -test_dpath = "foo" -disk_file = '/tmp/diskpool.conf' -back_disk_file = disk_file + "." + "02_reverse" - - -def conf_file(): - """ - Creating diskpool.conf file. - """ - try: - f = open(disk_file, 'w') - f.write('%s %s' % (test_dpath, '/')) - f.close() - except Exception,detail: - Globals.logger.error("Exception: %s", detail) - status = FAIL - sys.exit(status) - -def clean_up_restore(ip): - """ - Restoring back the original diskpool.conf - file. - """ - try: - if os.path.exists(back_disk_file): - os.remove(disk_file) - move_file(back_disk_file, disk_file) - except Exception, detail: - Globals.logger.error("Exception: %s", detail) - status = FAIL - vsxml.undefine(ip) - sys.exit(status) def try_assoc(conn, exp_ret, dev_dom_name, invalid_keyname_list, test_vals, log_msg): @@ -102,9 +71,9 @@ def try_assoc(conn, exp_ret, dev_dom_nam procid = "%s/%s" % (dev_dom_name, 0) lelist = { - get_typed_class(virt, "LogicalDisk") : diskid, \ - get_typed_class(virt, "NetworkPort") : netid, \ - get_typed_class(virt, "Memory" ) : memid, \ + get_typed_class(virt, "LogicalDisk") : diskid, + get_typed_class(virt, "NetworkPort") : netid, + get_typed_class(virt, "Memory" ) : memid, get_typed_class(virt, "Processor" ) : procid } @@ -125,9 +94,9 @@ def try_assoc(conn, exp_ret, dev_dom_nam else: snkeyname = "SystemName" - test_keys = { devkeyname : devkeyname, \ - ccnkeyname : ccnkeyname, \ - sccnkeyname : sccnkeyname, \ + test_keys = { devkeyname : devkeyname, + ccnkeyname : ccnkeyname, + sccnkeyname : sccnkeyname, snkeyname : snkeyname } for cn, devid in sorted(lelist.items()): @@ -142,10 +111,10 @@ def try_assoc(conn, exp_ret, dev_dom_nam else: ccn = cn - keys = { test_keys[devkeyname] : dev_id, \ - test_keys[ccnkeyname] : ccn, \ - test_keys[sccnkeyname] : test_vals['sccn'], \ - test_keys[snkeyname] : test_vals['sn'] + keys = { test_keys[devkeyname] : dev_id, + test_keys[ccnkeyname] : ccn, + test_keys[sccnkeyname] : test_vals['sccn'], + test_keys[snkeyname] : test_vals['sn'] } if test_vals['cn'] != "valid": @@ -154,8 +123,8 @@ def try_assoc(conn, exp_ret, dev_dom_nam inst_cn = cn instanceref = CIMInstanceName(inst_cn, keybindings=keys) try: - assoc_info = conn.AssociatorNames(instanceref, \ - AssocClass=assoc_classname) + assoc_info = conn.AssociatorNames(instanceref, + AssocClass=assoc_classname) except pywbem.CIMError, (err_no, desc): if err_no == exp_ret['rc'] and desc.find(exp_ret['desc']) >= 0: logger.info("Got expected exception where ") @@ -196,22 +165,21 @@ def err_invalid_sysname_keyname(conn, ex # # # - test_keys = { 'DeviceID' : "valid", \ - 'CreationClassName' : "valid", \ - 'SystemCreationClassName' : "valid", \ - 'SystemName' : "invalid" \ + test_keys = { 'DeviceID' : "valid", + 'CreationClassName' : "valid", + 'SystemCreationClassName' : "valid", + 'SystemName' : "invalid" } - test_vals = { 'devid' : "valid", \ - 'sccn' : get_typed_class(virt, "ComputerSystem"), \ - 'sn' : test_dom, \ - 'ccn' : "valid", \ + test_vals = { 'devid' : "valid", + 'sccn' : get_typed_class(virt, "ComputerSystem"), + 'sn' : test_dom, + 'ccn' : "valid", 'cn' : "valid" } log_msg = "Invalid SystemName Key Name was supplied." - return try_assoc(conn, exp_ret, test_dom, test_keys, \ - test_vals, log_msg) + return try_assoc(conn, exp_ret, test_dom, test_keys, test_vals, log_msg) def err_invalid_sysname_keyvalue(conn, exp_ret): @@ -232,22 +200,21 @@ def err_invalid_sysname_keyvalue(conn, e # # Similarly we check for Memory,Network,Processor. # - test_keys = { 'DeviceID' : "valid", \ - 'CreationClassName' : "valid", \ - 'SystemCreationClassName' : "valid", \ - 'SystemName' : "valid" \ + test_keys = { 'DeviceID' : "valid", + 'CreationClassName' : "valid", + 'SystemCreationClassName' : "valid", + 'SystemName' : "valid" } - test_vals = { 'devid' : "valid", \ - 'sccn' : get_typed_class(virt, "ComputerSystem"), \ - 'sn' : "invalid", \ - 'ccn' : "valid", \ + test_vals = { 'devid' : "valid", + 'sccn' : get_typed_class(virt, "ComputerSystem"), + 'sn' : "invalid", + 'ccn' : "valid", 'cn' : "valid" } log_msg = "Non-existing SystemName was supplied." - return try_assoc(conn, exp_ret, test_dom, test_keys, \ - test_vals, log_msg) + return try_assoc(conn, exp_ret, test_dom, test_keys, test_vals, log_msg) def err_invalid_devid_keyname(conn, exp_ret): # This is used to verify the that the @@ -271,22 +238,21 @@ def err_invalid_devid_keyname(conn, exp_ # # - test_keys = { 'DeviceID' : "invalid", \ - 'CreationClassName' : "valid", \ - 'SystemCreationClassName' : "valid", \ - 'SystemName' : "valid" \ + test_keys = { 'DeviceID' : "invalid", + 'CreationClassName' : "valid", + 'SystemCreationClassName' : "valid", + 'SystemName' : "valid" } - test_vals = { 'devid' : "valid", \ - 'sccn' : get_typed_class(virt, "ComputerSystem"), \ - 'sn' : test_dom, \ - 'ccn' : "valid", \ + test_vals = { 'devid' : "valid", + 'sccn' : get_typed_class(virt, "ComputerSystem"), + 'sn' : test_dom, + 'ccn' : "valid", 'cn' : "valid" } log_msg = "Invalid deviceid keyname was supplied." - return try_assoc(conn, exp_ret, test_dom, test_keys, \ - test_vals, log_msg) + return try_assoc(conn, exp_ret, test_dom, test_keys, test_vals, log_msg) def err_invalid_devid_keyvalue(conn, exp_ret): @@ -309,22 +275,22 @@ def err_invalid_devid_keyvalue(conn, exp # Similarly we check for Network. # # - test_keys = { 'DeviceID' : "valid", \ - 'CreationClassName' : "valid", \ - 'SystemCreationClassName' : "valid", \ - 'SystemName' : "valid" \ + test_keys = { 'DeviceID' : "valid", + 'CreationClassName' : "valid", + 'SystemCreationClassName' : "valid", + 'SystemName' : "valid" } - test_vals = { 'devid' : "invalid", \ - 'sccn' : get_typed_class(virt, "ComputerSystem"), \ - 'sn' : test_dom, \ - 'ccn' : "valid", \ + test_vals = { 'devid' : "invalid", + 'sccn' : get_typed_class(virt, "ComputerSystem"), + 'sn' : test_dom, + 'ccn' : "valid", 'cn' : "valid" } log_msg = "Invalid deviceid keyvalue was supplied." - return try_assoc(conn, exp_ret, test_dom_invalid, test_keys, \ - test_vals, log_msg) + return try_assoc(conn, exp_ret, test_dom_invalid, test_keys, test_vals, + log_msg) def err_invalid_classname(conn, exp_ret): @@ -348,22 +314,21 @@ def err_invalid_classname(conn, exp_ret) # Similarly we check for Memory,Network,Processor. # # - test_keys = { 'DeviceID' : "valid", \ - 'CreationClassName' : "valid", \ - 'SystemCreationClassName' : "valid", \ - 'SystemName' : "valid" \ + test_keys = { 'DeviceID' : "valid", + 'CreationClassName' : "valid", + 'SystemCreationClassName' : "valid", + 'SystemName' : "valid" } - test_vals = { 'devid' : "valid", \ - 'sccn' : get_typed_class(virt, "ComputerSystem"), \ - 'sn' : test_dom, \ - 'ccn' : "valid", \ + test_vals = { 'devid' : "valid", + 'sccn' : get_typed_class(virt, "ComputerSystem"), + 'sn' : test_dom, + 'ccn' : "valid", 'cn' : "invalid" } log_msg = "Invalid classname value was supplied." - return try_assoc(conn, exp_ret, test_dom, test_keys, \ - test_vals, log_msg) + return try_assoc(conn, exp_ret, test_dom, test_keys, test_vals, log_msg) def err_invalid_creationclassname_keyname(conn, exp_ret): @@ -388,22 +353,21 @@ def err_invalid_creationclassname_keynam # Similarly we check for Memory,Network,Processor. # - test_keys = { 'DeviceID' : "valid", \ - 'CreationClassName' : "invalid", \ - 'SystemCreationClassName' : "valid", \ - 'SystemName' : "valid" \ + test_keys = { 'DeviceID' : "valid", + 'CreationClassName' : "invalid", + 'SystemCreationClassName' : "valid", + 'SystemName' : "valid" } - test_vals = { 'devid' : "valid", \ - 'sccn' : get_typed_class(virt, "ComputerSystem"), \ - 'sn' : test_dom, \ - 'ccn' : "valid", \ + test_vals = { 'devid' : "valid", + 'sccn' : get_typed_class(virt, "ComputerSystem"), + 'sn' : test_dom, + 'ccn' : "valid", 'cn' : "valid" } log_msg = "Invalid creationclassname keyname was supplied." - return try_assoc(conn, exp_ret, test_dom, test_keys, \ - test_vals, log_msg) + return try_assoc(conn, exp_ret, test_dom, test_keys, test_vals, log_msg) def err_invalid_creationclassname_keyvalue(conn, exp_ret): @@ -426,22 +390,21 @@ def err_invalid_creationclassname_keyval # Similarly we check for Memory,Network,Processor. # - test_keys = { 'DeviceID' : "valid", \ - 'CreationClassName' : "valid", \ - 'SystemCreationClassName' : "valid", \ - 'SystemName' : "valid" \ + test_keys = { 'DeviceID' : "valid", + 'CreationClassName' : "valid", + 'SystemCreationClassName' : "valid", + 'SystemName' : "valid" } - test_vals = { 'devid' : "valid", \ - 'sccn' : get_typed_class(virt, "ComputerSystem"), \ - 'sn' : test_dom, \ - 'ccn' : "invalid", \ + test_vals = { 'devid' : "valid", + 'sccn' : get_typed_class(virt, "ComputerSystem"), + 'sn' : test_dom, + 'ccn' : "invalid", 'cn' : "valid" } log_msg = "Invalid creatioclassname keyvalue was supplied." - return try_assoc(conn, exp_ret, test_dom, test_keys, \ - test_vals, log_msg) + return try_assoc(conn, exp_ret, test_dom, test_keys, test_vals, log_msg) def err_invalid_syscreationclassname_keyname(conn, exp_ret): @@ -464,22 +427,21 @@ def err_invalid_syscreationclassname_key # Similarly we check for Memory,Network,Processor. # - test_keys = { 'DeviceID' : "valid", \ - 'CreationClassName' : "valid", \ - 'SystemCreationClassName' : "invalid", \ - 'SystemName' : "valid" \ + test_keys = { 'DeviceID' : "valid", + 'CreationClassName' : "valid", + 'SystemCreationClassName' : "invalid", + 'SystemName' : "valid" } - test_vals = { 'devid' : "valid", \ - 'sccn' : get_typed_class(virt, "ComputerSystem"), \ - 'sn' : test_dom, \ - 'ccn' : "valid", \ + test_vals = { 'devid' : "valid", + 'sccn' : get_typed_class(virt, "ComputerSystem"), + 'sn' : test_dom, + 'ccn' : "valid", 'cn' : "valid" } log_msg = "Invalid system creatioclassname keyvalue was supplied." - return try_assoc(conn, exp_ret, test_dom, test_keys, \ - test_vals, log_msg) + return try_assoc(conn, exp_ret, test_dom, test_keys, test_vals, log_msg) def err_invalid_syscreationclassname_keyvalue(conn, exp_ret): @@ -502,22 +464,21 @@ def err_invalid_syscreationclassname_key # Similarly we check for Memory,Network,Processor. # - test_keys = { 'DeviceID' : "valid", \ - 'CreationClassName' : "valid", \ - 'SystemCreationClassName' : "valid", \ - 'SystemName' : "valid" \ + test_keys = { 'DeviceID' : "valid", + 'CreationClassName' : "valid", + 'SystemCreationClassName' : "valid", + 'SystemName' : "valid" } - test_vals = { 'devid' : "valid", \ - 'sccn' : "invalid", \ - 'sn' : test_dom, \ - 'ccn' : "valid", \ + test_vals = { 'devid' : "valid", + 'sccn' : "invalid", + 'sn' : test_dom, + 'ccn' : "valid", 'cn' : "valid" } log_msg = "Invalid system creatioclassname keyvalue was supplied." - return try_assoc(conn, exp_ret, test_dom, test_keys, \ - test_vals, log_msg) + return try_assoc(conn, exp_ret, test_dom, test_keys, test_vals, log_msg) @do_main(platform_sup) def main(): @@ -539,14 +500,11 @@ def main(): destroy_and_undefine_all(options.ip) vsxml = get_class(virt)(test_dom, vcpus = test_vcpus, mac = test_mac, \ disk = test_disk) - if (os.path.exists(back_disk_file)): - os.unlink(back_disk_file) + # Verify DiskPool on machine + status = create_diskpool_file() + if status != PASS: + return status - if not (os.path.exists(disk_file)): - conf_file() - else: - move_file(disk_file, back_disk_file) - conf_file() bridge = vsxml.set_vbridge(options.ip) ret = vsxml.define(options.ip) if not ret: @@ -599,7 +557,7 @@ Keyname.------") Globals.logger.error("------FAILED: Invalid System creationclassname\ Keyvalue.------") return ret - clean_up_restore(options.ip) + cleanup_restore() vsxml.undefine(options.ip) return PASS if __name__ == "__main__":

Deepti B. Kalakeri wrote:
# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1208960298 -19800 # Node ID 70e13e2a2abf57a666c8e4d5029d06ecd017ea69 # Parent 0123ff5809dc099c0b7840fce65eca5bce0921e6 [TEST] Making use of the lib fn conf_file(), cleanup_restore() and create_diskpool_file().
Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com>
Looks good Deepti - just a few comments.
diff -r 0123ff5809dc -r 70e13e2a2abf suites/libvirt-cim/cimtest/ElementAllocatedFromPool/02_reverse.py
global status specific_fields = { } if (len(inst_list)) != 1: - Globals.logger.error("Got %s record for Memory/Network/LogicalDisk instead of \ -1", len(inst_list)) + Globals.logger.error("Got %s record for Memory/Network/LogicalDisk \ + instead of 1", len(inst_list))
Instead, you can do the following: Globals.logger.error("Got %s record for Memory/Network/LogicalDisk" " instead of 1", len(inst_list)) The block below has some strange indenting.
try : - disk = get_or_bail(server, id=diskid, \ - pool_class=enumclass.Xen_DiskPool) - mem = get_or_bail(server, id = memid, \ + disk = get_or_bail(server, id=diskid, pool_class=enumclass.Xen_DiskPool) + mem = get_or_bail(server, id = memid, pool_class=enumclass.Xen_MemoryPool) netid = "%s/%s" % ("NetworkPool", virt_network) - net = get_or_bail(server, id = netid, \ + net = get_or_bail(server, id = netid, pool_class=enumclass.Xen_NetworkPool) - proc = get_or_bail(server, id = procid, \ + proc = get_or_bail(server, id = procid, pool_class=enumclass.Xen_ProcessorPool)
except Exception, detail: Globals.logger.error("Exception: %s", detail) - clean_up_restore(server) + cleanup_restore() status = FAIL - ret = test_domain_function(test_dom, server, \ - cmd = "destroy") + ret = test_domain_function(test_dom, server, cmd = "destroy") return status
- pllist, cllist, prop_list, proc_prop = init_list(server, disk, mem, net, proc) + pllist, cllist, prop_list, proc_prop = init_list(server, disk, mem, net, + proc)
# Looping through the pllist to get association for various pools. for cn, instid in sorted(pllist.items()): try: - assoc_info = assoc.Associators(server, \ - "Xen_ElementAllocatedFromPool", \ - cn, \ - InstanceID = instid) + assoc_info = assoc.Associators(server, + "Xen_ElementAllocatedFromPool", + cn, + InstanceID = instid) # Verifying the Creation Class name for all the records returned for each # pool class queried inst_list = get_inst_for_dom(assoc_info) @@ -300,16 +265,16 @@ the specified domain: %s", test_dom) status = FAIL break
- assoc_values(assoc_list=inst_list, field="CreationClassName", \ - list=cllist, \ - index=loop) + assoc_values(assoc_list=inst_list, field="CreationClassName", + list=cllist, + index=loop) # verifying the DeviceID if inst_list[0]['CreationClassName'] == 'Xen_Processor': # The DeviceID for the processor varies from 0 to (vcpu - 1 ) list_index = 0 - assoc_values(assoc_list=inst_list, field="DeviceID", \ - list=proc_prop, \ - index=list_index) + assoc_values(assoc_list=inst_list, field="DeviceID", + list=proc_prop, + index=list_index) else: # For LogicalDisk, Memory and NetworkPort if inst_list[0]['CreationClassName'] == 'Xen_LogicalDisk': @@ -318,40 +283,41 @@ the specified domain: %s", test_dom) list_index = 2 else: list_index = 4 # NetworkPort - assoc_values(assoc_list=inst_list, field="DeviceID", \ - list=prop_list, \ - index=list_index) + assoc_values(assoc_list=inst_list, field="DeviceID", + list=prop_list, + index=list_index) if inst_list[0]['CreationClassName'] == 'Xen_LogicalDisk': # verifying the Name field for LogicalDisk - specific_fields = get_spec_fields_list(inst_list,field_name="Name") + specific_fields = get_spec_fields_list(inst_list, field_name="Name") list_index = 1 elif inst_list[0]['CreationClassName'] == 'Xen_Memory': # verifying the NumberOfBlocks allocated for Memory - specific_fields = get_spec_fields_list(inst_list,field_name="NumberOfBlocks") + specific_fields = get_spec_fields_list(inst_list, + field_name="NumberOfBlocks") list_index = 3 else: # verifying the NetworkAddresses for the NetworkPort - specific_fields = get_spec_fields_list(inst_list,field_name="NetworkAddresses") + specific_fields = get_spec_fields_list(inst_list, + field_name="NetworkAddresses") list_index = 5 # NetworkPort - assoc_values(assoc_list=inst_list, field="Other", \ - list=prop_list, \ - index=list_index, \ - specific_fields_list=specific_fields) + assoc_values(assoc_list=inst_list, field="Other", + list=prop_list, + index=list_index, + specific_fields_list=specific_fields) if status != PASS:
diff -r 0123ff5809dc -r 70e13e2a2abf suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py exp_list = [ - {'desc' : "No such instance (SystemName)", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, \ - {'desc' : "No DeviceID specified", 'rc' : pywbem.CIM_ERR_FAILED}, \ - {'desc' : "No such instance", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, \ - {'desc' : "One or more parameter values passed to the method were invalid", \ - 'rc' : pywbem.CIM_ERR_INVALID_PARAMETER}, \ - {'desc' : "No such instance (CreationClassName)", 'rc' : pywbem.CIM_ERR_NOT_FOUND }, \ - {'desc' : "No such instance (SystemCreationClassName)", 'rc' : \ - pywbem.CIM_ERR_NOT_FOUND }, + {'desc' : "No such instance (SystemName)", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, + {'desc' : "No DeviceID specified", 'rc' : pywbem.CIM_ERR_FAILED}, + {'desc' : "No such instance", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, + {'desc' : "CIM_ERR_INVALID_PARAMETER", + 'rc' : pywbem.CIM_ERR_INVALID_PARAMETER}, + {'desc' : "No such instance (CreationClassName)", + 'rc' : pywbem.CIM_ERR_NOT_FOUND }, + {'desc' : "No such instance (SystemCreationClassName)", + 'rc' : pywbem.CIM_ERR_NOT_FOUND }, ]
These changes cause this to fail on F9 with a release rpm. Would be good to branch this test so that it passes on both the release rpm and on current sources.
- return try_assoc(conn, exp_ret, test_dom_invalid, test_keys, \ - test_vals, log_msg) + return try_assoc(conn, exp_ret, test_dom_invalid, test_keys, test_vals, + log_msg)
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
Deepti B. Kalakeri wrote:
# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1208960298 -19800 # Node ID 70e13e2a2abf57a666c8e4d5029d06ecd017ea69 # Parent 0123ff5809dc099c0b7840fce65eca5bce0921e6 [TEST] Making use of the lib fn conf_file(), cleanup_restore() and create_diskpool_file().
Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com>
Looks good Deepti - just a few comments.
diff -r 0123ff5809dc -r 70e13e2a2abf suites/libvirt-cim/cimtest/ElementAllocatedFromPool/02_reverse.py
global status specific_fields = { } if (len(inst_list)) != 1: - Globals.logger.error("Got %s record for Memory/Network/LogicalDisk instead of \ -1", len(inst_list)) + Globals.logger.error("Got %s record for Memory/Network/LogicalDisk \ + instead of 1", len(inst_list))
Instead, you can do the following:
Globals.logger.error("Got %s record for Memory/Network/LogicalDisk" " instead of 1", len(inst_list))
The block below has some strange indenting.
I applied the same patch which I submitted on the other day . I tried using the hg export .I dont find any prob with the indentation with this patch :(
try : - disk = get_or_bail(server, id=diskid, \ - pool_class=enumclass.Xen_DiskPool) - mem = get_or_bail(server, id = memid, \ + disk = get_or_bail(server, id=diskid, pool_class=enumclass.Xen_DiskPool) + mem = get_or_bail(server, id = memid, pool_class=enumclass.Xen_MemoryPool) netid = "%s/%s" % ("NetworkPool", virt_network) - net = get_or_bail(server, id = netid, \ + net = get_or_bail(server, id = netid, pool_class=enumclass.Xen_NetworkPool) - proc = get_or_bail(server, id = procid, \ + proc = get_or_bail(server, id = procid, pool_class=enumclass.Xen_ProcessorPool) except Exception, detail: Globals.logger.error("Exception: %s", detail) - clean_up_restore(server) + cleanup_restore() status = FAIL - ret = test_domain_function(test_dom, server, \ - cmd = "destroy") + ret = test_domain_function(test_dom, server, cmd = "destroy") return status
- pllist, cllist, prop_list, proc_prop = init_list(server, disk, mem, net, proc) + pllist, cllist, prop_list, proc_prop = init_list(server, disk, mem, net, + proc)
# Looping through the pllist to get association for various pools. for cn, instid in sorted(pllist.items()): try: - assoc_info = assoc.Associators(server, \ - "Xen_ElementAllocatedFromPool", \ - cn, \ - InstanceID = instid) + assoc_info = assoc.Associators(server, + "Xen_ElementAllocatedFromPool", + cn, + InstanceID = instid) # Verifying the Creation Class name for all the records returned for each # pool class queried inst_list = get_inst_for_dom(assoc_info) @@ -300,16 +265,16 @@ the specified domain: %s", test_dom) status = FAIL break
- assoc_values(assoc_list=inst_list, field="CreationClassName", \ - list=cllist, \ - index=loop) + assoc_values(assoc_list=inst_list, field="CreationClassName", + list=cllist, + index=loop) # verifying the DeviceID if inst_list[0]['CreationClassName'] == 'Xen_Processor': # The DeviceID for the processor varies from 0 to (vcpu - 1 ) list_index = 0 - assoc_values(assoc_list=inst_list, field="DeviceID", \ - list=proc_prop, \ - index=list_index) + assoc_values(assoc_list=inst_list, field="DeviceID", + list=proc_prop, + index=list_index) else: # For LogicalDisk, Memory and NetworkPort if inst_list[0]['CreationClassName'] == 'Xen_LogicalDisk': @@ -318,40 +283,41 @@ the specified domain: %s", test_dom) list_index = 2 else: list_index = 4 # NetworkPort - assoc_values(assoc_list=inst_list, field="DeviceID", \ - list=prop_list, \ - index=list_index) + assoc_values(assoc_list=inst_list, field="DeviceID", + list=prop_list, + index=list_index) if inst_list[0]['CreationClassName'] == 'Xen_LogicalDisk': # verifying the Name field for LogicalDisk - specific_fields = get_spec_fields_list(inst_list,field_name="Name") + specific_fields = get_spec_fields_list(inst_list, field_name="Name") list_index = 1 elif inst_list[0]['CreationClassName'] == 'Xen_Memory': # verifying the NumberOfBlocks allocated for Memory - specific_fields = get_spec_fields_list(inst_list,field_name="NumberOfBlocks") + specific_fields = get_spec_fields_list(inst_list, + field_name="NumberOfBlocks") list_index = 3 else: # verifying the NetworkAddresses for the NetworkPort - specific_fields = get_spec_fields_list(inst_list,field_name="NetworkAddresses") + specific_fields = get_spec_fields_list(inst_list, + field_name="NetworkAddresses") list_index = 5 # NetworkPort - assoc_values(assoc_list=inst_list, field="Other", \ - list=prop_list, \ - index=list_index, \ - specific_fields_list=specific_fields) + assoc_values(assoc_list=inst_list, field="Other", + list=prop_list, + index=list_index, + specific_fields_list=specific_fields) if status != PASS:
diff -r 0123ff5809dc -r 70e13e2a2abf suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py exp_list = [ - {'desc' : "No such instance (SystemName)", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, \ - {'desc' : "No DeviceID specified", 'rc' : pywbem.CIM_ERR_FAILED}, \ - {'desc' : "No such instance", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, \ - {'desc' : "One or more parameter values passed to the method were invalid", \ - 'rc' : pywbem.CIM_ERR_INVALID_PARAMETER}, \ - {'desc' : "No such instance (CreationClassName)", 'rc' : pywbem.CIM_ERR_NOT_FOUND }, \ - {'desc' : "No such instance (SystemCreationClassName)", 'rc' : \ - pywbem.CIM_ERR_NOT_FOUND }, + {'desc' : "No such instance (SystemName)", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, + {'desc' : "No DeviceID specified", 'rc' : pywbem.CIM_ERR_FAILED}, + {'desc' : "No such instance", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, + {'desc' : "CIM_ERR_INVALID_PARAMETER", + 'rc' : pywbem.CIM_ERR_INVALID_PARAMETER}, + {'desc' : "No such instance (CreationClassName)", + 'rc' : pywbem.CIM_ERR_NOT_FOUND }, + {'desc' : "No such instance (SystemCreationClassName)", + 'rc' : pywbem.CIM_ERR_NOT_FOUND }, ]
These changes cause this to fail on F9 with a release rpm. Would be good to branch this test so that it passes on both the release rpm and on current sources.
- return try_assoc(conn, exp_ret, test_dom_invalid, test_keys, \ - test_vals, log_msg) + return try_assoc(conn, exp_ret, test_dom_invalid, test_keys, test_vals, + log_msg)

Kaitlin Rupert wrote:
diff -r 0123ff5809dc -r 70e13e2a2abf suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py exp_list = [ - {'desc' : "No such instance (SystemName)", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, \ - {'desc' : "No DeviceID specified", 'rc' : pywbem.CIM_ERR_FAILED}, \ - {'desc' : "No such instance", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, \ - {'desc' : "One or more parameter values passed to the method were invalid", \ - 'rc' : pywbem.CIM_ERR_INVALID_PARAMETER}, \ - {'desc' : "No such instance (CreationClassName)", 'rc' : pywbem.CIM_ERR_NOT_FOUND }, \ - {'desc' : "No such instance (SystemCreationClassName)", 'rc' : \ - pywbem.CIM_ERR_NOT_FOUND }, + {'desc' : "No such instance (SystemName)", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, + {'desc' : "No DeviceID specified", 'rc' : pywbem.CIM_ERR_FAILED}, + {'desc' : "No such instance", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, + {'desc' : "CIM_ERR_INVALID_PARAMETER", + 'rc' : pywbem.CIM_ERR_INVALID_PARAMETER}, + {'desc' : "No such instance (CreationClassName)", + 'rc' : pywbem.CIM_ERR_NOT_FOUND }, + {'desc' : "No such instance (SystemCreationClassName)", + 'rc' : pywbem.CIM_ERR_NOT_FOUND }, ]
These changes cause this to fail on F9 with a release rpm. Would be good to branch this test so that it passes on both the release rpm and on current sources.
The Error messages that is being returned when an InvalidCreationClassname is passed is different for pegasus and sfcb. On *F9 with sfcb and latest KVM provider* the 04_forward_errs.py tc passes with the error message *"One or more parameter values passed to the method were invalid", *while on *F9 or RHEL **with pegasus with the latest source* the 04_forward_errs.py tc passes with the error message* "*CIM_ERR_INVALID_PARAMETER". I believe these error messages are from the CIMOM and not from the providers. Any suggestion how do we fix this ?
- return try_assoc(conn, exp_ret, test_dom_invalid, test_keys, \ - test_vals, log_msg) + return try_assoc(conn, exp_ret, test_dom_invalid, test_keys, test_vals, + log_msg)

Deepti B Kalakeri wrote:
Kaitlin Rupert wrote:
diff -r 0123ff5809dc -r 70e13e2a2abf suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py
The Error messages that is being returned when an InvalidCreationClassname is passed is different for pegasus and sfcb. On *F9 with sfcb and latest KVM provider* the 04_forward_errs.py tc passes with the error message *"One or more parameter values passed to the method were invalid", *while on *F9 or RHEL **with pegasus with the latest source* the 04_forward_errs.py tc passes with the error message* "*CIM_ERR_INVALID_PARAMETER".
This is a good catch. You're correct - this is coming from the CIMOM. In order to know which provider to call, the CIMOM looks up which provider the class is registered to. In this case, it doesn't recognize the class and fails. Both return CIM_ERR_INVALID_PARAMETER.which is an error message we don't return currently. This is one of the more descriptive CMPI return codes (unlike CIM_ERR_FAILED, which could be just about anything). I'd suggest ignoring the return message in this case. I think it's fairly safe to rely on the return code. Thoughts? -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (3)
-
Deepti B Kalakeri
-
Deepti B. Kalakeri
-
Kaitlin Rupert