# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1208329712 25200
# Node ID ac6d65d178a0deec57611e6b0175deac7a7a28cc
# Parent dfe0e517e9903fa49f31ade82117d4341c829e0b
[TEST] add ElementAllocatedFromPool.01 for KVM & XenFV support
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r dfe0e517e990 -r ac6d65d178a0
suites/libvirt-cim/cimtest/ElementAllocatedFromPool/01_forward.py
--- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/01_forward.py Wed Apr 16
00:02:53 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/01_forward.py Wed Apr 16
00:08:32 2008 -0700
@@ -4,6 +4,7 @@
#
# Authors:
# Deepti B. Kalakeri <dkalaker(a)in.ibm.com>
+# Guolian Yun <yunguol(a)cn.ibm.com>
# Kaitlin Rupert <karupert(a)us.ibm.com>
#
# This library is free software; you can redistribute it and/or
@@ -47,30 +48,31 @@ from XenKvmLib import assoc
from XenKvmLib import assoc
from XenKvmLib.test_doms import test_domain_function, destroy_and_undefine_all
from XenKvmLib import devices
+from XenKvmLib import vxml
+from XenKvmLib.classes import get_typed_class
from CimTest import Globals
from CimTest.Globals import do_main
from VirtLib.live import network_by_bridge
from CimTest.ReturnCodes import PASS, FAIL, SKIP
-sup_types = ['Xen']
+sup_types = ['Xen', 'XenFV', 'KVM']
test_dom = "hd_domain"
test_mac = "00:11:22:33:44:aa"
test_vcpus = 1
-test_disk = 'xvda'
def print_error(cn, detail):
Globals.logger.error(Globals.CIM_ERROR_GETINSTANCE, cn)
Globals.logger.error("Exception: %s", detail)
-def get_keys(cn, device_id):
+def get_keys(cn, device_id, virt='Xen'):
id = "%s/%s" % (test_dom, device_id)
key_list = { 'DeviceID' : id,
'CreationClassName' : cn,
'SystemName' : test_dom,
- 'SystemCreationClassName' : "Xen_ComputerSystem"
+ 'SystemCreationClassName' : get_typed_class(virt,
"ComputerSystem")
}
return key_list
@@ -84,56 +86,58 @@ def main():
# Getting the VS list and deleting the test_dom if it already exists.
destroy_and_undefine_all(options.ip)
Globals.log_param()
-
- test_xml, bridge = testxml_bridge(test_dom, vcpus = test_vcpus, \
- mac = test_mac, disk = test_disk, \
- server = options.ip)
+
+ if options.virt == 'Xen':
+ test_disk = 'xvda'
+ else:
+ test_disk = 'hda'
+
+ virt_xml = vxml.get_class(options.virt)
+ cxml = virt_xml(test_dom, vcpus = test_vcpus, mac = test_mac, disk = test_disk)
+ bridge = cxml.set_vbridge(options.ip)
+
if bridge == None:
Globals.logger.error("Unable to find virtual bridge")
- return SKIP
-
- if test_xml == None:
- Globals.logger.error("Guest xml not created properly")
- return FAIL
-
- virt_network = network_by_bridge(bridge, options.ip)
+ return SKIP
+
+ virt_network = network_by_bridge(bridge, options.ip, options.virt)
if virt_network == None:
Globals.logger.error("No virtual network found for bridge %s", bridge)
return SKIP
- ret = test_domain_function(test_xml, options.ip, cmd = "create")
+ ret = cxml.create(options.ip)
if not ret:
- Globals.logger.error("Failed to Create the dom: %s", test_dom)
- return FAIL
-
- try:
- cn = "Xen_LogicalDisk"
- key_list = get_keys(cn, test_disk)
- disk = devices.Xen_LogicalDisk(options.ip, key_list)
- except Exception,detail:
- print_error(cn, detail)
- return FAIL
-
- try:
- cn = "Xen_Memory"
- key_list = get_keys(cn, "mem")
- mem = devices.Xen_Memory(options.ip, key_list)
+ logger.error('Unable to create domain %s' % test_dom)
+ return FAIL
+
+ try:
+ cn = get_typed_class(options.virt, "LogicalDisk")
+ key_list = get_keys(cn, test_disk, options.virt)
+ disk = eval('devices.' + get_typed_class(options.virt,
"LogicalDisk"))(options.ip, key_list)
+ except Exception,detail:
+ print_error(cn, detail)
+ return FAIL
+
+ try:
+ cn = get_typed_class(options.virt, "Memory")
+ key_list = get_keys(cn, "mem", options.virt)
+ mem = eval('devices.' + get_typed_class(options.virt,
"Memory"))(options.ip, key_list)
except Exception,detail:
print_error(cn, detail)
return FAIL
try:
- cn = "Xen_NetworkPort"
- key_list = get_keys(cn, test_mac)
- net = devices.Xen_NetworkPort(options.ip, key_list)
- except Exception,detail:
- print_error(cn, detail)
- return FAIL
-
- try:
- cn = "Xen_Processor"
- key_list = get_keys(cn, "0")
- proc = devices.Xen_Processor(options.ip, key_list)
+ cn = get_typed_class(options.virt, "NetworkPort")
+ key_list = get_keys(cn, test_mac, options.virt)
+ net = eval('devices.' + get_typed_class(options.virt,
"NetworkPort"))(options.ip, key_list)
+ except Exception,detail:
+ print_error(cn, detail)
+ return FAIL
+
+ try:
+ cn = get_typed_class(options.virt, "Processor")
+ key_list = get_keys(cn, "0", options.virt)
+ proc = eval('devices.' + get_typed_class(options.virt,
"Processor"))(options.ip, key_list)
except Exception,detail:
print_error(cn, detail)
return FAIL
@@ -141,16 +145,16 @@ def main():
netpool_id = "NetworkPool/%s" % virt_network
lelist = {
- "Xen_LogicalDisk" : disk.DeviceID, \
- "Xen_Memory" : mem.DeviceID, \
- "Xen_NetworkPort" : net.DeviceID, \
- "Xen_Processor" : proc.DeviceID
+ get_typed_class(options.virt, "LogicalDisk") : disk.DeviceID, \
+ get_typed_class(options.virt, "Memory") : mem.DeviceID, \
+ get_typed_class(options.virt, "NetworkPort") : net.DeviceID, \
+ get_typed_class(options.virt, "Processor") : proc.DeviceID
}
poollist = [
- "Xen_DiskPool", \
- "Xen_MemoryPool", \
- "Xen_NetworkPool", \
- "Xen_ProcessorPool"
+ get_typed_class(options.virt, "DiskPool"), \
+ get_typed_class(options.virt, "MemoryPool"), \
+ get_typed_class(options.virt, "NetworkPool"), \
+ get_typed_class(options.virt, "ProcessorPool")
]
poolval = [
"DiskPool/foo", \
@@ -158,20 +162,21 @@ def main():
netpool_id, \
"ProcessorPool/0"
]
-
- sccn = "Xen_ComputerSystem"
+
+ sccn = get_typed_class(options.virt, "ComputerSystem")
for cn, devid in sorted(lelist.items()):
try:
assoc_info = assoc.Associators(options.ip, \
- "Xen_ElementAllocatedFromPool",
+ "ElementAllocatedFromPool",
cn,
+ options.virt,
DeviceID = devid,
CreationClassName = cn,
SystemName = test_dom,
SystemCreationClassName = sccn)
if len(assoc_info) != 1:
- Globals.logger.error("Xen_ElementAllocatedFromPool returned %i\
- ResourcePool objects for domain '%s'", len(assoc_info), test_dom)
+ Globals.logger.error("ElementAllocatedFromPool returned %i\
+ ResourcePool objects for domain '%s'", len(assoc_info), test_dom)
status = FAIL
break
@@ -196,12 +201,13 @@ def main():
except Exception, detail:
Globals.logger.error(Globals.CIM_ERROR_ASSOCIATORS, \
- 'Xen_ElementAllocatedFromPool')
+ 'ElementAllocatedFromPool')
Globals.logger.error("Exception: %s", detail)
status = FAIL
- ret = test_domain_function(test_dom, options.ip, \
- cmd = "destroy")
+ cxml.destroy(options.ip)
+ cxml.undefine(options.ip)
+
return status
if __name__ == "__main__":