[PATCH 0 of 3] [TEST] SystemDevice XenFV & KVM support

Add XenFV & KVM support for SystemDevice test cases. Signed-off-by: Zhengang Li <lizg@cn.ibm.com>

# HG changeset patch # User Zhengang Li <lizg@cn.ibm.com> # Date 1206973949 -28800 # Node ID 05259e63c37a2d496411b6b473c0f107fbceb652 # Parent c67d4960d4073c641beeb1fe5180862001c247ae [TEST] SystemDevice.01_forward XenFV & KVM support Signed-off-by: Zhengang Li <lizg@cn.ibm.com> diff -r c67d4960d407 -r 05259e63c37a 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 Mon Mar 31 22:32:29 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,26 @@ 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) + cxml = vxml.get_class(options.virt)(test_dom, vcpus = test_cpu, + mac = test_mac, disk = test_disk) + cxml.destroy(options.ip) + 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,13 +71,15 @@ def main(): logger.error("No devices returned") return FAIL - devlist = ["Xen_NetworkPort", "Xen_Memory", "Xen_LogicalDisk", \ - "Xen_Processor"] + devlist = [get_typed_class(options.virt, "NetworkPort"), + get_typed_class(options.virt, "Memory"), + get_typed_class(options.virt, "LogicalDisk"), + get_typed_class(options.virt, "Processor")] key_list = {'DeviceID' : '', 'CreationClassName' : '', 'SystemName' : test_dom, - 'SystemCreationClassname' : "Xen_ComputerSystem" + 'SystemCreationClassname' : cs_classname } for items in devlist: @@ -81,14 +91,14 @@ def main(): continue devid = device.DeviceID - if items == "Xen_NetworkPort": + if items == devlist[0]: _devid = "%s/%s" % (test_dom, test_mac) - elif items == "Xen_LogicalDisk": + elif items == devlist[1]: + _devid = "%s/mem" % test_dom + elif items == devlist[2]: _devid = "%s/%s" % (test_dom, test_disk) - elif items == "Xen_Processor": + elif items == devlist[3]: _devid = "%s/%d" % (test_dom, test_cpu-1) - elif items == "Xen_Memory": - _devid = "%s/mem" % test_dom if devid != _devid: logger.error("DeviceID `%s` != `%s'" % (devid, _devid)) @@ -96,7 +106,8 @@ def main(): else: logger.info("Examined %s" % _devid) - test_domain_function(test_xml, options.ip, "destroy") + cxml.destroy(options.ip) + cxml.undefine(options.ip) return status

ZL> + cxml = vxml.get_class(options.virt)(test_dom, vcpus = test_cpu, ZL> + mac = test_mac, disk = test_disk) I'm not familiar with the "function(foo)(bar)" syntax. Can you explain? ZL> + cxml.destroy(options.ip) ZL> + ret = cxml.create(options.ip) Why destroy it immediately and then create? Does vxml.get_class()() create the domain, or are you trying to make sure it doesn't already exist? ZL> + devlist = [get_typed_class(options.virt, "NetworkPort"), ZL> + get_typed_class(options.virt, "Memory"), ZL> + get_typed_class(options.virt, "LogicalDisk"), ZL> + get_typed_class(options.virt, "Processor")] Is this used anywhere else but below? ZL> - if items == "Xen_NetworkPort": ZL> + if items == devlist[0]: ZL> _devid = "%s/%s" % (test_dom, test_mac) ZL> - elif items == "Xen_LogicalDisk": ZL> + elif items == devlist[1]: ZL> + _devid = "%s/mem" % test_dom ZL> + elif items == devlist[2]: ZL> _devid = "%s/%s" % (test_dom, test_disk) ZL> - elif items == "Xen_Processor": ZL> + elif items == devlist[3]: ZL> _devid = "%s/%d" % (test_dom, test_cpu-1) ZL> - elif items == "Xen_Memory": ZL> - _devid = "%s/mem" % test_dom Going from class names to array values makes this harder to eye-parse. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
ZL> + cxml = vxml.get_class(options.virt)(test_dom, vcpus = test_cpu, ZL> + mac = test_mac, disk = test_disk)
I'm not familiar with the "function(foo)(bar)" syntax. Can you explain?
If get_class returns a class object, then the second set of parens would represent the call to that classes constructor I believe. If I'm right, my opinion would be "clever, but let's make it more obvious what's going on here." -- -Jay

JG> If get_class returns a class object, then the second set of parens JG> would represent the call to that classes constructor I believe. JG> If I'm right, my opinion would be "clever, but let's make it more JG> obvious what's going on here." Oh, right. After I sent my response, I figured it was a function. Either way, a temporary variable will make it cleaner....Please :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
ZL> + cxml = vxml.get_class(options.virt)(test_dom, vcpus = test_cpu, ZL> + mac = test_mac, disk = test_disk)
I'm not familiar with the "function(foo)(bar)" syntax. Can you explain? Yes, just like what Jay explained in the other email.
ZL> + cxml.destroy(options.ip) ZL> + ret = cxml.create(options.ip)
Why destroy it immediately and then create? Does vxml.get_class()() create the domain, or are you trying to make sure it doesn't already exist?
vxml.get_class()(...) only generates the xml string. we need to define & start, or create to make the domain usable. Destroy was here to make sure no such domain alive. I was planned to delete the destroy step because the do_main did this for all test cases. This one was left out. I will remove the destroy step in the updated patch.
ZL> + devlist = [get_typed_class(options.virt, "NetworkPort"), ZL> + get_typed_class(options.virt, "Memory"), ZL> + get_typed_class(options.virt, "LogicalDisk"), ZL> + get_typed_class(options.virt, "Processor")]
Is this used anywhere else but below?
ZL> - if items == "Xen_NetworkPort": ZL> + if items == devlist[0]: ZL> _devid = "%s/%s" % (test_dom, test_mac) ZL> - elif items == "Xen_LogicalDisk": ZL> + elif items == devlist[1]: ZL> + _devid = "%s/mem" % test_dom ZL> + elif items == devlist[2]: ZL> _devid = "%s/%s" % (test_dom, test_disk) ZL> - elif items == "Xen_Processor": ZL> + elif items == devlist[3]: ZL> _devid = "%s/%d" % (test_dom, test_cpu-1) ZL> - elif items == "Xen_Memory": ZL> - _devid = "%s/mem" % test_dom
Going from class names to array values makes this harder to eye-parse.
For the two comments above: I'll make it a dictionary, just like what I did to the other two test cases.
------------------------------------------------------------------------
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- - Zhengang

# HG changeset patch # User Zhengang Li <lizg@cn.ibm.com> # Date 1206973985 -28800 # Node ID 6c8ff6906d1c4d1fd8c6766c5f7b70d7b7beb420 # Parent 05259e63c37a2d496411b6b473c0f107fbceb652 [TEST] SystemDevice.02_reverse XenFV & KVM support Also changed the devices.enumerate() method's 2nd param (devtype). Test cases are updated, where this method is referenced: LogicalDisk.02_nodevs ResourceAllocationFromPool.02_reverse Signed-off-by: Zhengang Li <lizg@cn.ibm.com> diff -r 05259e63c37a -r 6c8ff6906d1c suites/libvirt-cim/cimtest/LogicalDisk/02_nodevs.py --- a/suites/libvirt-cim/cimtest/LogicalDisk/02_nodevs.py Mon Mar 31 22:32:29 2008 +0800 +++ b/suites/libvirt-cim/cimtest/LogicalDisk/02_nodevs.py Mon Mar 31 22:33:05 2008 +0800 @@ -66,7 +66,7 @@ def main(): devid = "%s/%s" % (test_dom, test_dev) status = 0 - name = eval('devices.' + get_typed_class(options.virt, "LogicalDisk")) + name = get_typed_class(options.virt, "LogicalDisk") key_list = ["DeviceID", "CreationClassName", "SystemName", "SystemCreationClassName"] devs = devices.enumerate(options.ip, name, key_list) diff -r 05259e63c37a -r 6c8ff6906d1c suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py --- a/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py Mon Mar 31 22:32:29 2008 +0800 +++ b/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py Mon Mar 31 22:33:05 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,17 @@ def main(): key_list = ["DeviceID", "CreationClassName", "SystemName", "SystemCreationClassName"] try: - mem = devices.enumerate(options.ip, Xen_Memory, key_list) + mem = devices.enumerate(options.ip, + get_typed_class(options.virt, '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, + get_typed_class(options.virt, 'Processor'), + key_list) except Exception: logger.error(Globals.CIM_ERROR_ENUMERATE % devices.Xen_Processor) return FAIL diff -r 05259e63c37a -r 6c8ff6906d1c suites/libvirt-cim/cimtest/SystemDevice/02_reverse.py --- a/suites/libvirt-cim/cimtest/SystemDevice/02_reverse.py Mon Mar 31 22:32:29 2008 +0800 +++ b/suites/libvirt-cim/cimtest/SystemDevice/02_reverse.py Mon Mar 31 22:33:05 2008 +0800 @@ -25,18 +25,16 @@ # 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 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" @@ -47,21 +45,23 @@ 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") + cxml = vxml.get_class(options.virt)(test_dom, mac=test_mac) + cxml.create(options.ip) - devlist = [ "Xen_NetworkPort", "Xen_Memory", "Xen_LogicalDisk", \ - "Xen_Processor" ] + devlist = [ get_typed_class(options.virt, "NetworkPort"), + get_typed_class(options.virt, "Memory"), + get_typed_class(options.virt, "LogicalDisk"), + get_typed_class(options.virt, "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) 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 +69,28 @@ 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, + get_typed_class(options.virt, "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 +102,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 05259e63c37a -r 6c8ff6906d1c suites/libvirt-cim/lib/XenKvmLib/devices.py --- a/suites/libvirt-cim/lib/XenKvmLib/devices.py Mon Mar 31 22:32:29 2008 +0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/devices.py Mon Mar 31 22:33:05 2008 +0800 @@ -101,7 +101,7 @@ def enumerate(server, devtype, keys): list = [] try: - names = conn.EnumerateInstanceNames(devtype.__name__) + names = conn.EnumerateInstanceNames(devtype) except pywbem.CIMError, arg: print arg[1] return list @@ -114,7 +114,7 @@ def enumerate(server, devtype, keys): if len(key_list) == 0: return list - list.append(devtype(server, key_list)) + list.append(eval(devtype)(server, key_list)) return list

# HG changeset patch # User Zhengang Li <lizg@cn.ibm.com> # Date 1206974015 -28800 # Node ID 7d806de944b51750ae19b40bb3ec655930a476e3 # Parent 6c8ff6906d1c4d1fd8c6766c5f7b70d7b7beb420 [TEST] SystemDevice.03_fwderrs XenFV & KVM support Signed-off-by: Zhengang Li <lizg@cn.ibm.com> diff -r 6c8ff6906d1c -r 7d806de944b5 suites/libvirt-cim/cimtest/SystemDevice/03_fwderrs.py --- a/suites/libvirt-cim/cimtest/SystemDevice/03_fwderrs.py Mon Mar 31 22:33:05 2008 +0800 +++ b/suites/libvirt-cim/cimtest/SystemDevice/03_fwderrs.py Mon Mar 31 22:33:35 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,25 @@ 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) + cxml = vxml.get_class(options.virt)(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 = [ get_typed_class(options.virt, "NetworkPort"), + get_typed_class(options.virt, "Memory"), + get_typed_class(options.virt, "LogicalDisk"), + get_typed_class(options.virt, "Processor") ] # Building the dict for avoiding the correct key:val pairs # while verifying with the Invalid values for the association @@ -82,7 +87,7 @@ def main(): try: for item in devlist: - devs = devices.enumerate(options.ip, eval(item), key_list) + devs = devices.enumerate(options.ip, item, key_list) for dev in devs: if dev.SystemName != test_dom: @@ -131,9 +136,10 @@ def main(): 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 +167,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__":
participants (4)
-
Dan Smith
-
Jay Gagnon
-
lizg@cn.ibm.com
-
Zhengang Li