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