# HG changeset patch
# User Zhengang Li <lizg(a)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(a)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