# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1217403718 25200
# Node ID b0af611e1fde61297aa300a0d5f51ebc0a5de1c3
# Parent 2efc46fd30f33e06c20ca8c771abed65725a3fdb
[TEST]#2 Update HostSystem.04 for XenFV/KVM/LXC support
Updates from 1 to 2:
define a network pool for test
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 2efc46fd30f3 -r b0af611e1fde
suites/libvirt-cim/cimtest/HostSystem/04_hs_to_EAPF.py
--- a/suites/libvirt-cim/cimtest/HostSystem/04_hs_to_EAPF.py Wed Jul 23 17:42:47 2008
-0700
+++ b/suites/libvirt-cim/cimtest/HostSystem/04_hs_to_EAPF.py Wed Jul 30 00:41:58 2008
-0700
@@ -52,17 +52,17 @@
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
+create_diskpool_file, create_netpool_conf, destroy_netpool
-sup_types = ['Xen']
+sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
test_dom = "CrossClass_GuestDom"
test_mac = "00:11:22:33:44:aa"
@@ -72,30 +72,6 @@
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,35 +88,43 @@
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
- }
+ if virt == "LXC":
+ eaf_values = { mem_inst : mem}
+ else:
+ eaf_values = { proc_inst : proc,
+ disk_inst : disk,
+ net_inst : net,
+ mem_inst : mem
+ }
return eaf_values
def get_inst_for_dom(assoc_val):
@@ -152,13 +136,14 @@
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 +157,6 @@
if status != PASS:
cleanup_restore(server, virt='Xen')
- test_domain_function(test_dom, server, "destroy")
return status, assoc_info
@@ -183,24 +167,24 @@
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,41 +200,60 @@
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 define the dom: '%s'", test_dom)
+ return FAIL
+ cleanup_restore(server, virt=virt)
# Verify DiskPool on machine
status = create_diskpool_file()
if status != PASS:
return status
+ # Create NetPool on machine
+ status, net_name = create_netpool_conf(server, virt)
+ if status != PASS:
+ logger.error('Unable to create network pool')
+ return FAIL
# 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
-
- # One pool for each Device type, hence len should be 4
+ # One pool for each Device type, hence len should be 4
exp_len = 4
status = status = check_len(an, pool, qcn, exp_len)
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")
+ if virt == 'LXC':
+ for cn, instid in in_pllist.items():
+ if cn == 'LXC_MemoryPool':
+ in_pllist = {cn: instid}
+ break
+ status = verify_eafp_values(server, in_pllist, virt)
+ vsxml.undefine(server)
cleanup_restore(server, virt=virt)
+ destroy_netpool(server, virt, net_name)
return status
if __name__ == "__main__":
sys.exit(main())