# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1216972699 25200
# Node ID be268ff56f1a52fb77fe8d98da8a4a7ff3602397
# Parent 32d78f23f6e73f5443022179410128767896465d
[TEST] Convert HostSystem - 04_hs_to_EAPF.py for XenFV/KVM support
Also fix failure for Xen, remove CCName parameter from verify_device_values() function
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 32d78f23f6e7 -r be268ff56f1a
suites/libvirt-cim/cimtest/HostSystem/04_hs_to_EAPF.py
--- a/suites/libvirt-cim/cimtest/HostSystem/04_hs_to_EAPF.py Wed Jul 23 00:32:36 2008
-0700
+++ b/suites/libvirt-cim/cimtest/HostSystem/04_hs_to_EAPF.py Fri Jul 25 00:58:19 2008
-0700
@@ -52,17 +52,17 @@ from CimTest.Globals import logger, CIM_
from CimTest.Globals import logger, CIM_ERROR_ASSOCIATORNAMES, \
CIM_ERROR_ASSOCIATORS
from CimTest.Globals import do_main
+from XenKvmLib.vxml import XenXML, KVMXML, get_class
from XenKvmLib.assoc import AssociatorNames, Associators
from XenKvmLib.common_util import get_host_info
+from XenKvmLib.classes import get_typed_class
from CimTest.ReturnCodes import PASS, FAIL, SKIP
-from XenKvmLib.test_xml import testxml_bridge
-from XenKvmLib.test_doms import test_domain_function, destroy_and_undefine_all
-from VirtLib.live import network_by_bridge
+from XenKvmLib.test_doms import destroy_and_undefine_all
from XenKvmLib.logicaldevices import verify_device_values
from XenKvmLib.common_util import cleanup_restore, test_dpath, \
create_diskpool_file
-sup_types = ['Xen']
+sup_types = ['Xen', 'KVM', 'XenFV']
test_dom = "CrossClass_GuestDom"
test_mac = "00:11:22:33:44:aa"
@@ -72,30 +72,6 @@ diskid = "%s/%s" % ("DiskPool", test_dpa
diskid = "%s/%s" % ("DiskPool", test_dpath)
memid = "%s/%s" % ("MemoryPool", 0)
procid = "%s/%s" % ("ProcessorPool", 0)
-
-def setup_env(server):
- destroy_and_undefine_all(server)
- test_xml, bridge = testxml_bridge(test_dom, mem = test_mem,
- vcpus = test_vcpus, mac = test_mac,
- disk = test_disk, server = server)
- if bridge == None:
- logger.error("Unable to find virtual bridge")
- return SKIP
-
- if test_xml == None:
- logger.error("Guest xml was not created properly")
- return FAIL
-
- virt_network = network_by_bridge(bridge, server)
- if virt_network == None:
- logger.error("No virtual network found for bridge %s", bridge)
- return SKIP
-
- ret = test_domain_function(test_xml, server, cmd = "create")
- if not ret:
- logger.error("Failed to create the dom: %s", test_dom)
- return FAIL
- return PASS
def print_err(err, detail, cn):
logger.error(err % cn)
@@ -112,34 +88,39 @@ def pool_init_list(pool_assoc):
in_pllist[classname_keyvalue] = instid
return in_pllist
-def eapf_list():
+def eapf_list(server, virt="Xen"):
+ disk_inst = get_typed_class(virt, "LogicalDisk")
+ proc_inst = get_typed_class(virt, "Processor")
+ net_inst = get_typed_class(virt, "NetworkPort")
+ mem_inst = get_typed_class(virt, "Memory")
+
disk = {
'SystemName' : test_dom,
- 'CreationClassName' : "Xen_LogicalDisk",
- 'DeviceID' : "%s/%s" % (test_dom,test_disk),
+ 'CreationClassName' : disk_inst,
+ 'DeviceID' : "%s/%s" % (test_dom, test_disk),
'Name' : test_disk
}
proc = {
'SystemName' : test_dom,
- 'CreationClassName' : "Xen_Processor",
+ 'CreationClassName' : proc_inst,
'DeviceID' : "%s/%s" % (test_dom,0)
}
net = {
'SystemName' : test_dom,
- 'CreationClassName' : "Xen_NetworkPort",
+ 'CreationClassName' : net_inst,
'DeviceID' : "%s/%s" % (test_dom, test_mac),
'NetworkAddresses' : test_mac
}
mem = {
'SystemName' : test_dom,
- 'CreationClassName' : "Xen_Memory",
+ 'CreationClassName' : mem_inst,
'DeviceID' : "%s/%s" % (test_dom,
"mem"),
'NumberOfBlocks' : test_mem * 1024
}
- eaf_values = { "Xen_Processor" : proc,
- "Xen_LogicalDisk" : disk,
- "Xen_NetworkPort" : net,
- "Xen_Memory" : mem
+ eaf_values = { proc_inst : proc,
+ disk_inst : disk,
+ net_inst : net,
+ mem_inst : mem
}
return eaf_values
@@ -152,13 +133,14 @@ def get_inst_for_dom(assoc_val):
return dom_list
-def get_assocname_info(server, cn, an, qcn, hostname):
+def get_assocname_info(server, cn, an, qcn, hostname, virt="Xen"):
status = PASS
assoc_info = []
try:
assoc_info = AssociatorNames(server,
an,
cn,
+ virt,
CreationClassName=cn,
Name = hostname)
if len(assoc_info) < 1:
@@ -172,7 +154,6 @@ def get_assocname_info(server, cn, an, q
if status != PASS:
cleanup_restore(server, virt='Xen')
- test_domain_function(test_dom, server, "destroy")
return status, assoc_info
@@ -183,24 +164,24 @@ def check_len(an, assoc_list_info, qcn,
return FAIL
return PASS
-def verify_eafp_values(server, in_pllist):
+def verify_eafp_values(server, in_pllist, virt="Xen"):
# Looping through the in_pllist to get association for various pools.
status = PASS
- an = "Xen_ElementAllocatedFromPool"
+ an = get_typed_class(virt, "ElementAllocatedFromPool")
exp_len = 1
qcn = "Logical Devices"
- eafp_values = eapf_list()
+ eafp_values = eapf_list(server, virt)
for cn, instid in sorted(in_pllist.items()):
try:
- assoc_info = Associators(server, an, cn, InstanceID = instid)
+ assoc_info = Associators(server, an, cn, virt, InstanceID = instid)
inst_list = get_inst_for_dom(assoc_info)
status = check_len(an, inst_list, qcn, exp_len)
if status != PASS:
break
assoc_eafp_info = inst_list[0]
CCName = assoc_eafp_info['CreationClassName']
- status = verify_device_values(assoc_eafp_info, CCName,
- eafp_values, virt='Xen')
+ status = verify_device_values(assoc_eafp_info,
+ eafp_values, virt)
if status != PASS:
return status
@@ -216,22 +197,36 @@ def main():
def main():
options= main.options
server = options.ip
- virt=options.virt
+ if options.virt == "XenFV":
+ virt = "Xen"
+ else:
+ virt=options.virt
# Get the host info
- status, host_name, classname = get_host_info(server)
+ status, host_name, classname = get_host_info(server, virt)
if status != PASS:
return status
+ destroy_and_undefine_all(server)
+ virt_type = get_class(virt)
+ if virt == 'LXC':
+ vsxml = virt_type(test_dom)
+ else:
+ vsxml = virt_type(test_dom, vcpus = test_vcpus, mac = test_mac,
+ disk = test_disk)
+
+ ret = vsxml.define(server)
+ if not ret:
+ logger.error("Failed to Create the dom: '%s'", test_dom)
+ return FAIL
# Verify DiskPool on machine
status = create_diskpool_file()
if status != PASS:
return status
-
# Get the hostedResourcePool info first
cn = classname
- an = "Xen_HostedResourcePool"
+ an = get_typed_class(virt, "HostedResourcePool")
qcn = "Device Pool"
- status, pool = get_assocname_info(server, cn, an, qcn, host_name)
+ status, pool = get_assocname_info(server, cn, an, qcn, host_name, virt)
if status != PASS:
return status
@@ -241,15 +236,9 @@ def main():
if status != PASS:
return FAIL
- status = setup_env(server)
- if status != PASS:
- cleanup_restore(server, virt=virt)
- test_domain_function(test_dom, server, cmd = "destroy")
- return status
-
in_pllist = pool_init_list(pool)
- status = verify_eafp_values(server, in_pllist)
- ret = test_domain_function(test_dom, server, cmd = "destroy")
+ status = verify_eafp_values(server, in_pllist, virt)
+ vsxml.undefine(server)
cleanup_restore(server, virt=virt)
return status
if __name__ == "__main__":