[PATCH 0 of 3] .2# SystemDevice XenFV & KVM support

# HG changeset patch # User Zhengang Li <lizg@cn.ibm.com> # Date 1207015341 -28800 # Node ID 15835b6f2704b50e2b7d872319ef0023e6348559 # Parent c67d4960d4073c641beeb1fe5180862001c247ae [TEST] .2# SystemDevice.01_forward XenFV & KVM support Use dict instead of array. More clear vxml construction. Unnecessary destroy step removed. Signed-off-by: Zhengang Li <lizg@cn.ibm.com> diff -r c67d4960d407 -r 15835b6f2704 suites/libvirt-cim/cimtest/SystemDevice/01_forward.py --- a/suites/libvirt-cim/cimtest/SystemDevice/01_forward.py Fri Mar 28 21:46:53 2008 +0800 +++ b/suites/libvirt-cim/cimtest/SystemDevice/01_forward.py Tue Apr 01 10:02:21 2008 +0800 @@ -25,19 +25,18 @@ # import sys -from XenKvmLib.test_xml import testxml from VirtLib import utils from XenKvmLib import assoc -from XenKvmLib.test_doms import test_domain_function +from XenKvmLib import vxml from XenKvmLib import devices +from XenKvmLib.classes import get_typed_class from CimTest.Globals import log_param, logger, do_main from CimTest.ReturnCodes import PASS, FAIL -sup_types = ['Xen'] +sup_types = ['Xen', 'KVM', 'XenFV'] test_dom = "test_domain" test_mac = "00:11:22:33:44:55" -test_disk = "xvdb" test_cpu = 1 @do_main(sup_types) @@ -45,17 +44,25 @@ def main(): options= main.options log_param() + if options.virt == 'Xen': + test_disk = 'xvdb' + else: + test_disk = 'hdb' + status = PASS - test_xml = testxml(test_dom, vcpus = test_cpu, mac = test_mac, \ - disk = test_disk) + virt_xml = vxml.get_class(options.virt) + cxml = virt_xml(test_dom, vcpus = test_cpu, mac = test_mac, disk = test_disk) + ret = cxml.create(options.ip) + if not ret: + logger.error('Unable to create domain %s' % test_dom) + return FAIL - test_domain_function(test_xml, options.ip, "destroy") - test_domain_function(test_xml, options.ip, "create") + sd_classname = get_typed_class(options.virt, 'SystemDevice') + cs_classname = get_typed_class(options.virt, 'ComputerSystem') - devs = assoc.AssociatorNames(options.ip, "Xen_SystemDevice", - "Xen_ComputerSystem", - Name=test_dom, - CreationClassName="Xen_ComputerSystem") + devs = assoc.AssociatorNames(options.ip, sd_classname, cs_classname, + virt=options.virt, + Name=test_dom, CreationClassName=cs_classname) if devs == None: logger.error("System association failed") return FAIL @@ -63,40 +70,37 @@ def main(): logger.error("No devices returned") return FAIL - devlist = ["Xen_NetworkPort", "Xen_Memory", "Xen_LogicalDisk", \ - "Xen_Processor"] + cn_devid = { + get_typed_class(options.virt, "NetworkPort") : '%s/%s' % (test_dom, test_mac), + get_typed_class(options.virt, "Memory") : '%s/mem' % test_dom, + get_typed_class(options.virt, "LogicalDisk") : '%s/%s' % (test_dom, test_disk), + get_typed_class(options.virt, "Processor") : '%s/%s' % (test_dom, test_cpu-1) + } key_list = {'DeviceID' : '', 'CreationClassName' : '', 'SystemName' : test_dom, - 'SystemCreationClassname' : "Xen_ComputerSystem" + 'SystemCreationClassname' : cs_classname } - for items in devlist: + for dev_cn in cn_devid.keys(): for dev in devs: key_list['CreationClassName'] = dev['CreationClassname'] key_list['DeviceID'] = dev['DeviceID'] device = devices.device_of(options.ip, key_list) - if device.CreationClassName != items: + if device.CreationClassName != dev_cn: continue devid = device.DeviceID - if items == "Xen_NetworkPort": - _devid = "%s/%s" % (test_dom, test_mac) - elif items == "Xen_LogicalDisk": - _devid = "%s/%s" % (test_dom, test_disk) - elif items == "Xen_Processor": - _devid = "%s/%d" % (test_dom, test_cpu-1) - elif items == "Xen_Memory": - _devid = "%s/mem" % test_dom - + _devid = cn_devid[dev_cn] if devid != _devid: logger.error("DeviceID `%s` != `%s'" % (devid, _devid)) status = FAIL else: logger.info("Examined %s" % _devid) - test_domain_function(test_xml, options.ip, "destroy") + cxml.destroy(options.ip) + cxml.undefine(options.ip) return status

# HG changeset patch # User Zhengang Li <lizg@cn.ibm.com> # Date 1207017518 -28800 # Node ID 9d4b1e2eb6aa19e9c9d45f33bca7f3cf29c871ee # Parent 15835b6f2704b50e2b7d872319ef0023e6348559 [TEST] .2# SystemDevice.02_reverse XenFV & KVM support - devices.enumerate() methods' 2nd param is now a string typed basename of the class. - LogicalDisk.02_nodevs, ResourceAllocationFromPool.02_reverse are also updated to keep up to date. (only the method reference, no other changes to the two test cases.) - More clear vxml construction. Signed-off-by: Zhengang Li <lizg@cn.ibm.com> diff -r 15835b6f2704 -r 9d4b1e2eb6aa suites/libvirt-cim/cimtest/LogicalDisk/02_nodevs.py --- a/suites/libvirt-cim/cimtest/LogicalDisk/02_nodevs.py Tue Apr 01 10:02:21 2008 +0800 +++ b/suites/libvirt-cim/cimtest/LogicalDisk/02_nodevs.py Tue Apr 01 10:38:38 2008 +0800 @@ -66,10 +66,9 @@ def main(): devid = "%s/%s" % (test_dom, test_dev) status = 0 - name = eval('devices.' + get_typed_class(options.virt, "LogicalDisk")) key_list = ["DeviceID", "CreationClassName", "SystemName", "SystemCreationClassName"] - devs = devices.enumerate(options.ip, name, key_list) + devs = devices.enumerate(options.ip, 'LogicalDisk', key_list) if devs.__class__ == str: logger.error("Got error instead of empty list: %s" % devs) status = 1 diff -r 15835b6f2704 -r 9d4b1e2eb6aa suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py --- a/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py Tue Apr 01 10:02:21 2008 +0800 +++ b/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py Tue Apr 01 10:38:38 2008 +0800 @@ -26,7 +26,7 @@ from VirtLib import utils from VirtLib import utils from XenKvmLib import assoc from XenKvmLib import devices -from XenKvmLib.devices import Xen_Memory, Xen_Processor +from XenKvmLib.classes import get_typed_class from CimTest import Globals from CimTest.Globals import log_param, logger, do_main from CimTest.ReturnCodes import PASS, FAIL, XFAIL @@ -42,13 +42,13 @@ def main(): key_list = ["DeviceID", "CreationClassName", "SystemName", "SystemCreationClassName"] try: - mem = devices.enumerate(options.ip, Xen_Memory, key_list) + mem = devices.enumerate(options.ip, 'Memory', key_list) except Exception: logger.error(Globals.CIM_ERROR_ENUMERATE % devices.Xen_Memory) return FAIL try: - proc = devices.enumerate(options.ip, Xen_Processor, key_list) + proc = devices.enumerate(options.ip, 'Processor', key_list) except Exception: logger.error(Globals.CIM_ERROR_ENUMERATE % devices.Xen_Processor) return FAIL diff -r 15835b6f2704 -r 9d4b1e2eb6aa suites/libvirt-cim/cimtest/SystemDevice/02_reverse.py --- a/suites/libvirt-cim/cimtest/SystemDevice/02_reverse.py Tue Apr 01 10:02:21 2008 +0800 +++ b/suites/libvirt-cim/cimtest/SystemDevice/02_reverse.py Tue Apr 01 10:38:38 2008 +0800 @@ -25,18 +25,15 @@ # import sys -from XenKvmLib.test_xml import testxml from VirtLib import utils +from XenKvmLib import vxml from XenKvmLib import computersystem from XenKvmLib import assoc -from XenKvmLib.test_doms import test_domain_function from XenKvmLib import devices -from XenKvmLib.devices import Xen_NetworkPort, Xen_Memory, Xen_LogicalDisk, \ - Xen_Processor from CimTest.Globals import log_param, logger, do_main from CimTest.ReturnCodes import PASS, FAIL -sup_types = ['Xen'] +sup_types = ['Xen', 'KVM', 'XenFV'] test_dom = "test_domain" test_mac = "00:11:22:33:44:55" @@ -47,21 +44,21 @@ def main(): log_param() status = FAIL - test_xml = testxml(test_dom, mac = test_mac) - test_domain_function(test_xml, options.ip, "destroy") - test_domain_function(test_xml, options.ip, "create") + virt_xml = vxml.get_class(options.virt) + cxml = virt_xml(test_dom, mac=test_mac) + cxml.create(options.ip) - devlist = [ "Xen_NetworkPort", "Xen_Memory", "Xen_LogicalDisk", \ - "Xen_Processor" ] + devlist = [ "NetworkPort", "Memory", "LogicalDisk", "Processor" ] key_list = ["DeviceID", "CreationClassName", "SystemName", "SystemCreationClassName"] for items in devlist: try: - devs = devices.enumerate(options.ip, eval(items), key_list) + devs = devices.enumerate(options.ip, items, key_list, options.virt) except Exception, detail: logger.error("Exception: %s" % detail) - test_domain_function(test_xml, options.ip, "destroy") + cxml.destroy(options.ip) + cxml.undefine(options.ip) return FAIL for dev in devs: @@ -69,24 +66,27 @@ def main(): continue try: - systems = assoc.AssociatorNames(options.ip, "Xen_SystemDevice", - items, - DeviceID=dev.DeviceID, - CreationClassName=dev.CreationClassName, - SystemName=dev.SystemName, - SystemCreationClassName=dev.SystemCreationClassName) + systems = assoc.AssociatorNames(options.ip, + "SystemDevice", items, virt=options.virt, + DeviceID=dev.DeviceID, + CreationClassName=dev.CreationClassName, + SystemName=dev.SystemName, + SystemCreationClassName=dev.SystemCreationClassName) except Exception, detail: logger.error("Exception: %s" % detail) - test_domain_function(test_xml, options.ip, "destroy") + cxml.destroy(options.ip) + cxml.undefine(options.ip) return FAIL if systems == None: logger.error("Device association failed") - test_domain_function(test_xml, options.ip, "destroy") + cxml.destroy(options.ip) + cxml.undefine(options.ip) return FAIL elif len(systems) != 1: logger.error("%s systems returned, expected 1" % len(systems)) - test_domain_function(test_xml, options.ip, "destroy") + cxml.destroy(options.ip) + cxml.undefine(options.ip) return FAIL system = computersystem.system_of(options.ip, systems[0]) @@ -98,7 +98,8 @@ def main(): logger.error("Association returned wrong system: %s" % system.Name) - test_domain_function(test_xml, options.ip, "destroy") + cxml.destroy(options.ip) + cxml.undefine(options.ip) return status diff -r 15835b6f2704 -r 9d4b1e2eb6aa suites/libvirt-cim/lib/XenKvmLib/devices.py --- a/suites/libvirt-cim/lib/XenKvmLib/devices.py Tue Apr 01 10:02:21 2008 +0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/devices.py Tue Apr 01 10:38:38 2008 +0800 @@ -93,13 +93,17 @@ class KVM_Processor(CIM_Processor): class KVM_Processor(CIM_Processor): pass -def enumerate(server, devtype, keys): +def enumerate(server, basetype, keys, virt='Xen'): conn = pywbem.WBEMConnection('http://%s' % server, (Globals.CIM_USER, Globals.CIM_PASS), Globals.CIM_NS) list = [] + #FIXME - Remove once all tests are converted for KVM + basetype = basetype.split('_', 1)[-1] + + devtype = eval(get_typed_class(virt, basetype)) try: names = conn.EnumerateInstanceNames(devtype.__name__) except pywbem.CIMError, arg:

# HG changeset patch # User Zhengang Li <lizg@cn.ibm.com> # Date 1207020339 -28800 # Node ID 2a7c38299fe676863577ff2b2f5bb9a01df35a00 # Parent 9d4b1e2eb6aa19e9c9d45f33bca7f3cf29c871ee [TEST] .2# SystemDevice.03_fwderrs XenFV & KVM support - More clear vxml construction - Strip unnecessary prefix passed to devices.enumerate() Signed-off-by: Zhengang Li <lizg@cn.ibm.com> diff -r 9d4b1e2eb6aa -r 2a7c38299fe6 suites/libvirt-cim/cimtest/SystemDevice/03_fwderrs.py --- a/suites/libvirt-cim/cimtest/SystemDevice/03_fwderrs.py Tue Apr 01 10:38:38 2008 +0800 +++ b/suites/libvirt-cim/cimtest/SystemDevice/03_fwderrs.py Tue Apr 01 11:25:39 2008 +0800 @@ -32,20 +32,18 @@ import pywbem import pywbem from pywbem.cim_obj import CIMInstanceName from VirtLib import utils -from XenKvmLib.test_xml import testxml +from XenKvmLib import vxml from XenKvmLib import assoc from XenKvmLib import devices -from XenKvmLib.test_doms import test_domain_function, destroy_and_undefine_all -from XenKvmLib.devices import Xen_NetworkPort, Xen_Memory, Xen_LogicalDisk, Xen_Processor +from XenKvmLib.classes import get_typed_class from CimTest.Globals import log_param, logger, do_main from CimTest import Globals from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC -sup_types = ['Xen'] +sup_types = ['Xen', 'KVM', 'XenFV'] test_dom = "virt1" test_mac = "00:11:22:33:44:55" -test_disk = "xvda" test_cpu = 1 exp_rc1 = 1 #CIM_ERR_FAILED @@ -59,18 +57,23 @@ def main(): def main(): options = main.options + if options.virt == 'Xen': + test_disk = 'xvda' + else: + test_disk = 'hda' + log_param() status = PASS - test_xml = testxml(test_dom, vcpus = test_cpu, mac = test_mac, disk = test_disk) + virt_xml = vxml.get_class(options.virt) + cxml = virt_xml(test_dom, vcpus = test_cpu, mac = test_mac, + disk = test_disk) - test_domain_function(test_dom, options.ip, "destroy") - ret = test_domain_function(test_xml, options.ip, "create") + ret = cxml.create(options.ip) if not ret : logger.info("error while 'create' of VS") return FAIL - devlist = [ "Xen_NetworkPort", "Xen_Memory", - "Xen_LogicalDisk", "Xen_Processor" ] + devlist = [ "NetworkPort", "Memory", "LogicalDisk", "Processor" ] # Building the dict for avoiding the correct key:val pairs # while verifying with the Invalid values for the association @@ -82,8 +85,9 @@ def main(): try: for item in devlist: - devs = devices.enumerate(options.ip, eval(item), key_list) - + devs = devices.enumerate(options.ip, item, key_list, options.virt) + if len(devs) == 0: + raise Exception('empty result returned') for dev in devs: if dev.SystemName != test_dom: continue @@ -92,7 +96,7 @@ def main(): names[item] = ("DeviceID" , dev.DeviceID ) except Exception, details: - logger.info("exception ", details , item) + logger.info("Exception %s for class %s" % (details , item)) return FAIL if len(name) <=0 or len(names) <= 0: @@ -127,13 +131,14 @@ def main(): (a, b) = names[item] if i == a and keyval == b and name[i, keyval] == item: continue + cn = get_typed_class(options.virt, item) + instanceref = CIMInstanceName(cn, keybindings = {i : keyval , + "CreationClassName" : cn}) - instanceref = CIMInstanceName(item, keybindings = \ - {i : keyval , "CreationClassName" : item}) - - try: + try: + sd_classname = get_typed_class(options.virt, 'SystemDevice') conn.AssociatorNames(instanceref, - AssocClass = "Xen_SystemDevice") + AssocClass = sd_classname) rc = 0 except pywbem.CIMError, (rc, desc): @@ -161,7 +166,8 @@ def main(): logger.info("exception" , details) status = FAIL - test_domain_function(test_dom, options.ip, "destroy") + cxml.destroy(options.ip) + cxml.undefine(options.ip) return status if __name__ == "__main__":

lizg@cn.ibm.com wrote:
Signed-off-by: Zhengang Li <lizg@cn.ibm.com>
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
Sorry, forget to add [TEST] in the .2# of SystemDevice and SettingsDefine update. -- - Zhengang
participants (2)
-
lizg@cn.ibm.com
-
Zhengang Li