[PATCH] [TEST] add VirtualSystemSettingDataComponent.03 for XenFV & KVM support
by Guo Lian Yun
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1208496944 -28800
# Node ID bd227552046d59c9a7fbfc4cbed41751fe0e675e
# Parent c1d9b3ba06ca4c76fe9b1cf63a77a7f92bb01d22
[TEST] add VirtualSystemSettingDataComponent.03 for XenFV & KVM support
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r c1d9b3ba06ca -r bd227552046d suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/03_vssdc_fwd_errs.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/03_vssdc_fwd_errs.py Thu Apr 17 10:12:46 2008 +0800
+++ b/suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/03_vssdc_fwd_errs.py Fri Apr 18 13:35:44 2008 +0800
@@ -55,20 +55,19 @@
import pywbem
from VirtLib import utils
from XenKvmLib import assoc
-from XenKvmLib.test_xml import testxml
+from XenKvmLib import vxml
+from XenKvmLib.classes import get_typed_class
from XenKvmLib.common_util import try_assoc
-from XenKvmLib.test_doms import test_domain_function, destroy_and_undefine_all
+from XenKvmLib.test_doms import destroy_and_undefine_all
from CimTest.ReturnCodes import PASS, FAIL
from CimTest.Globals import do_main, log_param, logger
from CimTest.Globals import CIM_USER, CIM_PASS, CIM_NS
-sup_types = ['Xen']
+sup_types = ['Xen', 'XenFV', 'KVM']
-ac_classname = 'Xen_VirtualSystemSettingDataComponent'
test_dom = "domu1"
test_mac = "00:11:22:33:44:aa"
test_vcpus = 1
-test_disk = 'xvda'
expr_values = {
"INVALID_InstID_Keyname" : { 'rc' : pywbem.CIM_ERR_FAILED, \
@@ -77,7 +76,8 @@
'desc' : 'No such instance (INVALID_InstID_Keyval)'}
}
-def try_invalid_assoc(classname, name_val, i, field):
+def try_invalid_assoc(classname, name_val, i, field, virt="Xen"):
+ ac_classname = get_typed_class(virt, "VirtualSystemSettingDataComponent")
keys = {}
temp = name_val[i]
name_val[i] = field
@@ -103,23 +103,32 @@
status = PASS
destroy_and_undefine_all(options.ip)
- test_xml = testxml(test_dom, vcpus = test_vcpus, mac = test_mac, \
- disk = test_disk)
- ret = test_domain_function(test_xml, options.ip, cmd = "create")
+ 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)
+ ret = cxml.create(options.ip)
if not ret:
- logger.error("Failed to Create the dom: %s", test_dom)
+ logger.error('Unable to create domain %s' % test_dom)
return FAIL
global conn
conn = assoc.myWBEMConnection('http://%s' % options.ip, (CIM_USER, \
CIM_PASS), CIM_NS)
+ disk_rasd = get_typed_class(options.virt, 'DiskResourceAllocationSettingData')
+ mem_rasd = get_typed_class(options.virt, 'MemResourceAllocationSettingData')
+ net_rasd = get_typed_class(options.virt, 'NetResourceAllocationSettingData')
+ proc_rasd = get_typed_class(options.virt, 'ProcResourceAllocationSettingData')
class_id = {
- 'Xen_DiskResourceAllocationSettingData' : test_disk, \
- 'Xen_MemResourceAllocationSettingData' : 'mem', \
- 'Xen_NetResourceAllocationSettingData' : test_mac, \
- 'Xen_ProcResourceAllocationSettingData' : '0'
+ disk_rasd : test_disk, \
+ mem_rasd : 'mem', \
+ net_rasd : test_mac, \
+ proc_rasd : '0'
}
tc_scen = ['INVALID_InstID_Keyname', 'INVALID_InstID_Keyval']
@@ -128,11 +137,13 @@
devid = "%s/%s" % (test_dom, devid)
name_val = ['InstanceID', devid]
for i in range(len(tc_scen)):
- retval = try_invalid_assoc(classname, name_val, i, tc_scen[i])
+ retval = try_invalid_assoc(classname, name_val, i, tc_scen[i], options.virt)
if retval != PASS:
status = retval
- test_domain_function(test_dom, options.ip, cmd = "destroy")
+ cxml.destroy(options.ip)
+ cxml.undefine(options.ip)
+
return status
if __name__ == "__main__":
16 years, 6 months
[PATCH] [TEST] add VirtualSystemSettingDataComponent.04 for XenFV & KVM support
by Guo Lian Yun
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1208496684 25200
# Node ID 2e3a76cf844e1448112ff82bd998eeb4afc27a14
# Parent c1d9b3ba06ca4c76fe9b1cf63a77a7f92bb01d22
[TEST] add VirtualSystemSettingDataComponent.04 for XenFV & KVM support
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r c1d9b3ba06ca -r 2e3a76cf844e suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/04_vssdc_rev_errs.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/04_vssdc_rev_errs.py Thu Apr 17 10:12:46 2008 +0800
+++ b/suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/04_vssdc_rev_errs.py Thu Apr 17 22:31:24 2008 -0700
@@ -58,18 +58,16 @@ import pywbem
import pywbem
from VirtLib import utils
from XenKvmLib import assoc
-from XenKvmLib.test_xml import testxml
+from XenKvmLib import vxml
+from XenKvmLib.classes import get_typed_class
from XenKvmLib.common_util import try_assoc
-from XenKvmLib.test_doms import test_domain_function, destroy_and_undefine_all
+from XenKvmLib.test_doms import destroy_and_undefine_all
from CimTest.ReturnCodes import PASS, FAIL
from CimTest.Globals import do_main, log_param, logger
from CimTest.Globals import CIM_USER, CIM_PASS, CIM_NS
-sup_types = ['Xen']
+sup_types = ['Xen', 'XenFV', 'KVM']
-VSType = "Xen"
-classname = 'Xen_VirtualSystemSettingData'
-ac_classname = 'Xen_VirtualSystemSettingDataComponent'
test_dom = "domu1"
expr_values = {
@@ -79,7 +77,9 @@ expr_values = {
'desc' : 'No such instance (InstanceID)'}
}
-def try_invalid_assoc(name_val, i, field):
+def try_invalid_assoc(name_val, i, field, virt="Xen"):
+ classname = get_typed_class(virt, 'VirtualSystemSettingData')
+ ac_classname = get_typed_class(virt, 'VirtualSystemSettingDataComponent')
keys = {}
temp = name_val[i]
name_val[i] = field
@@ -105,11 +105,12 @@ def main():
status = PASS
destroy_and_undefine_all(options.ip)
- test_xml = testxml(test_dom)
- ret = test_domain_function(test_xml, options.ip, cmd = "create")
+ virt_xml = vxml.get_class(options.virt)
+ cxml = virt_xml(test_dom)
+ ret = cxml.create(options.ip)
if not ret:
- logger.error("Failed to Create the dom: %s", test_dom)
+ logger.error('Unable to create domain %s' % test_dom)
return FAIL
global conn
@@ -117,15 +118,22 @@ def main():
CIM_PASS), CIM_NS)
tc_scen = ['INVALID_InstID_Keyname', 'INVALID_InstID_Keyval']
- inst_id = "%s:%s" % (VSType, test_dom)
+
+ if options.virt == "Xen" or options.virt == "XenFV":
+ inst_id = "Xen:%s" % test_dom
+ else:
+ inst_id = "KVM:%s" % test_dom
+
name_val = ['InstanceID', inst_id]
for i in range(len(tc_scen)):
- retval = try_invalid_assoc(name_val, i, tc_scen[i])
+ retval = try_invalid_assoc(name_val, i, tc_scen[i], options.virt)
if retval != PASS:
status = retval
- test_domain_function(test_dom, options.ip, cmd = "destroy")
+ cxml.destroy(options.ip)
+ cxml.undefine(options.ip)
+
return status
if __name__ == "__main__":
16 years, 6 months
[PATCH] Fix silly compile warning (and actually initialize the library as intended)
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1208464649 25200
# Node ID 1904e4f08af21f99af698e42da236cf39407c5e2
# Parent 2806f8744946757036f9639d8c8fe9a95f689233
Fix silly compile warning (and actually initialize the library as intended)
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 2806f8744946 -r 1904e4f08af2 libxkutil/misc_util.c
--- a/libxkutil/misc_util.c Wed Apr 16 17:50:49 2008 -0700
+++ b/libxkutil/misc_util.c Thu Apr 17 13:37:29 2008 -0700
@@ -452,7 +452,7 @@ bool parse_instanceid(const CMPIObjectPa
bool libvirt_cim_init(void)
{
- return virInitialize == 0;
+ return virInitialize() == 0;
}
bool check_refs_pfx_match(const CMPIObjectPath *refa,
16 years, 6 months
[PATCH] [TEST].3# add ElementAllocatedFromPool.02 for KVM & XenFV support
by Guo Lian Yun
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1208413671 25200
# Node ID 7a86c54748f0eb6f353cc3a35c38f2a522bf64c0
# Parent 2977c29bb772fb764004aad004e4ff7c43264f38
[TEST].3# add ElementAllocatedFromPool.02 for KVM & XenFV support
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 2977c29bb772 -r 7a86c54748f0 suites/libvirt-cim/cimtest/ElementAllocatedFromPool/02_reverse.py
--- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/02_reverse.py Wed Apr 16 10:49:55 2008 +0800
+++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/02_reverse.py Wed Apr 16 23:27:51 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
@@ -53,21 +54,21 @@ from VirtLib import live
from VirtLib import live
from XenKvmLib import assoc
from XenKvmLib import enumclass
+from XenKvmLib import vxml
+from XenKvmLib.classes import get_typed_class
from CimTest import Globals
from CimTest.Globals import do_main
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
-sup_types = ['Xen']
+sup_types = ['Xen', 'XenFV', 'KVM']
status = PASS
test_dom = "hd_domain"
test_mac = "00:11:22:33:44:aa"
test_mem = 128
test_vcpus = 4
-test_disk = "xvdb"
test_dpath = "foo"
disk_file = '/tmp/diskpool.conf'
back_disk_file = disk_file + "." + "02_reverse"
@@ -105,14 +106,14 @@ def clean_up_restore(ip):
sys.exit(status)
-def get_or_bail(ip, id, pool_class):
+def get_or_bail(ip, id, pool_class, virt="Xen"):
"""
Getinstance for the CLass and return instance on success, otherwise
exit after cleanup_restore and destroying the guest.
"""
key_list = { 'InstanceID' : id }
try:
- instance = enumclass.getInstance(ip, pool_class, key_list)
+ instance = enumclass.getInstance(ip, pool_class, key_list, virt)
except Exception, detail:
Globals.logger.error(Globals.CIM_ERROR_GETINSTANCE, '%s', pool_class)
Globals.logger.error("Exception: %s", detail)
@@ -127,22 +128,22 @@ def print_error(field, ret_val, req_val)
Globals.logger.error("%s Mismatch", field)
Globals.logger.error("Returned %s instead of %s", ret_val, req_val)
-def init_list(ip, disk, mem, net, proc):
+def init_list(ip, disk, mem, net, proc, virt="Xen"):
"""
Creating the lists that will be used for comparisons.
"""
pllist = {
- "Xen_DiskPool" : disk.InstanceID, \
- "Xen_MemoryPool" : mem.InstanceID, \
- "Xen_NetworkPool" : net.InstanceID, \
- "Xen_ProcessorPool": proc.InstanceID
+ get_typed_class(virt, "DiskPool") : disk.InstanceID, \
+ get_typed_class(virt, "MemoryPool") : mem.InstanceID, \
+ get_typed_class(virt, "NetworkPool") : net.InstanceID, \
+ get_typed_class(virt, "ProcessorPool"): proc.InstanceID
}
cllist = [
- "Xen_LogicalDisk", \
- "Xen_Memory", \
- "Xen_NetworkPort", \
- "Xen_Processor"
+ get_typed_class(virt, "LogicalDisk"), \
+ get_typed_class(virt, "Memory"), \
+ get_typed_class(virt, "NetworkPort"), \
+ get_typed_class(virt, "Processor")
]
prop_list = ["%s/%s" % (test_dom, test_disk), test_disk, \
"%s/%s" % (test_dom, "mem"), test_mem, \
@@ -162,7 +163,7 @@ def get_inst_for_dom(assoc_val):
return list
-def get_spec_fields_list(inst_list, field_name):
+def get_spec_fields_list(inst_list, field_name, virt="Xen"):
global status
specific_fields = { }
if (len(inst_list)) != 1:
@@ -172,7 +173,7 @@ 1", len(inst_list))
return
# verifying the Name field for LogicalDisk
try:
- if inst_list[0]['CreationClassName'] != 'Xen_Memory':
+ if inst_list[0]['CreationClassName'] != get_typed_class(virt, 'Memory'):
field_value = inst_list[0][field_name]
if field_name == 'NetworkAddresses':
# For network we NetworkAddresses is a list of addresses, since we
@@ -190,11 +191,12 @@ 1", len(inst_list))
return specific_fields
-def assoc_values(assoc_list, field , list, index, specific_fields_list=""):
+def assoc_values(assoc_list, field , list, index, specific_fields_list="", virt="Xen"):
"""
Verifying the records retruned by the associations.
"""
global status
+ cn = get_typed_class(virt, 'Processor')
if field == "CreationClassName":
for i in range(len(assoc_list)):
if assoc_list[i][field] != list[index]:
@@ -203,7 +205,7 @@ def assoc_values(assoc_list, field , li
if status != PASS:
break
elif field == "DeviceID":
- if assoc_list[0]['CreationClassName'] == 'Xen_Processor':
+ if assoc_list[0]['CreationClassName'] == cn:
# Verifying the list of DeviceId returned by the association
# against the list created intially .
for i in range(len(list)):
@@ -218,7 +220,7 @@ def assoc_values(assoc_list, field , li
status = FAIL
else:
# other specific fields verification
- if assoc_list[0]['CreationClassName'] != 'Xen_Processor':
+ if assoc_list[0]['CreationClassName'] != cn:
spec_field_name = specific_fields_list['field_name']
spec_field_value = specific_fields_list['field_value']
if spec_field_value != list[index]:
@@ -235,24 +237,28 @@ def main():
server = options.ip
destroy_and_undefine_all(options.ip)
Globals.log_param()
- test_xml, bridge = testxml_bridge(test_dom, mem = test_mem, vcpus = test_vcpus, \
- mac = test_mac, disk = test_disk, server = options.ip)
+ global test_disk
+ 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 was not created properly")
- return FAIL
-
- virt_network = network_by_bridge(bridge, server)
+ 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, server, cmd = "create")
+ ret = cxml.create(options.ip)
if not ret:
- Globals.logger.error("Failed to Create the dom: %s", test_dom)
+ logger.error('Unable to create domain %s' % test_dom)
return FAIL
# Taking care of already existing diskconf file
@@ -264,16 +270,20 @@ def main():
else:
move_file(disk_file, back_disk_file)
conf_file()
+ diskpool_cn = get_typed_class(options.virt, "DiskPool")
+ mempool_cn = get_typed_class(options.virt, "MemoryPool")
+ netpool_cn = get_typed_class(options.virt, "NetworkPool")
+ procpool_cn = get_typed_class(options.virt, "ProcessorPool")
+ diskpool = eval('enumclass.' + diskpool_cn)
+ mempool = eval('enumclass.' + mempool_cn)
+ netpool = eval('enumclass.' + netpool_cn)
+ procpool = eval('enumclass.' + procpool_cn)
try :
- disk = get_or_bail(server, id=diskid, \
- pool_class=enumclass.Xen_DiskPool)
- mem = get_or_bail(server, id = memid, \
- pool_class=enumclass.Xen_MemoryPool)
+ disk = get_or_bail(server, id = diskid, pool_class = diskpool, virt=options.virt)
+ mem = get_or_bail(server, id = memid, pool_class = mempool, virt=options.virt)
netid = "%s/%s" % ("NetworkPool", virt_network)
- net = get_or_bail(server, id = netid, \
- pool_class=enumclass.Xen_NetworkPool)
- proc = get_or_bail(server, id = procid, \
- pool_class=enumclass.Xen_ProcessorPool)
+ net = get_or_bail(server, id = netid, pool_class = netpool, virt=options.virt)
+ proc = get_or_bail(server, id = procid, pool_class = procpool, virt=options.virt)
except Exception, detail:
Globals.logger.error("Exception: %s", detail)
@@ -283,15 +293,16 @@ def main():
cmd = "destroy")
return status
- pllist, cllist, prop_list, proc_prop = init_list(server, disk, mem, net, proc)
+ pllist, cllist, prop_list, proc_prop = init_list(server, disk, mem, net, proc, options.virt)
# Looping through the pllist to get association for various pools.
for cn, instid in sorted(pllist.items()):
try:
- assoc_info = assoc.Associators(server, \
- "Xen_ElementAllocatedFromPool", \
- cn, \
- InstanceID = instid)
+ assoc_info = assoc.Associators(server,
+ "ElementAllocatedFromPool",
+ cn,
+ options.virt,
+ InstanceID = instid)
# Verifying the Creation Class name for all the records returned for each
# pool class queried
inst_list = get_inst_for_dom(assoc_info)
@@ -301,43 +312,51 @@ the specified domain: %s", test_dom)
status = FAIL
break
- assoc_values(assoc_list=inst_list, field="CreationClassName", \
- list=cllist, \
- index=loop)
+ assoc_values(assoc_list=inst_list, field="CreationClassName", list=cllist, \
+ index=loop, virt=options.virt)
# verifying the DeviceID
- if inst_list[0]['CreationClassName'] == 'Xen_Processor':
+ proc_cn = get_typed_class(options.virt, 'Processor')
+ mem_cn = get_typed_class(options.virt, 'Memory')
+ disk_cn = get_typed_class(options.virt, 'LogicalDisk')
+ if inst_list[0]['CreationClassName'] == proc_cn:
# The DeviceID for the processor varies from 0 to (vcpu - 1 )
list_index = 0
assoc_values(assoc_list=inst_list, field="DeviceID", \
list=proc_prop, \
- index=list_index)
+ index=list_index, \
+ virt=options.virt)
else:
# For LogicalDisk, Memory and NetworkPort
- if inst_list[0]['CreationClassName'] == 'Xen_LogicalDisk':
+ if inst_list[0]['CreationClassName'] == disk_cn:
list_index = 0
- elif inst_list[0]['CreationClassName'] == 'Xen_Memory':
+ elif inst_list[0]['CreationClassName'] == mem_cn:
list_index = 2
else:
list_index = 4 # NetworkPort
assoc_values(assoc_list=inst_list, field="DeviceID", \
list=prop_list, \
- index=list_index)
- if inst_list[0]['CreationClassName'] == 'Xen_LogicalDisk':
+ index=list_index, \
+ virt=options.virt)
+ if inst_list[0]['CreationClassName'] == disk_cn:
# verifying the Name field for LogicalDisk
- specific_fields = get_spec_fields_list(inst_list,field_name="Name")
+ specific_fields = get_spec_fields_list(inst_list,field_name="Name", \
+ virt=options.virt)
list_index = 1
- elif inst_list[0]['CreationClassName'] == 'Xen_Memory':
+ elif inst_list[0]['CreationClassName'] == mem_cn:
# verifying the NumberOfBlocks allocated for Memory
- specific_fields = get_spec_fields_list(inst_list,field_name="NumberOfBlocks")
+ specific_fields = get_spec_fields_list(inst_list,field_name="NumberOfBlocks", \
+ virt=options.virt)
list_index = 3
else:
# verifying the NetworkAddresses for the NetworkPort
- specific_fields = get_spec_fields_list(inst_list,field_name="NetworkAddresses")
+ specific_fields = get_spec_fields_list(inst_list,field_name="NetworkAddresses", \
+ virt=options.virt)
list_index = 5 # NetworkPort
assoc_values(assoc_list=inst_list, field="Other", \
list=prop_list, \
index=list_index, \
- specific_fields_list=specific_fields)
+ specific_fields_list=specific_fields, \
+ virt=options.virt)
if status != PASS:
break
else:
@@ -345,13 +364,14 @@ the specified domain: %s", test_dom)
loop = loop + 1
except Exception, detail:
Globals.logger.error(Globals.CIM_ERROR_ASSOCIATORS, \
- 'Xen_ElementAllocatedFromPool')
+ 'ElementAllocatedFromPool')
Globals.logger.error("Exception: %s", detail)
clean_up_restore(server)
status = FAIL
- ret = test_domain_function(test_dom, server, \
- cmd = "destroy")
+ cxml.destroy(options.ip)
+ cxml.undefine(options.ip)
+
clean_up_restore(server)
return status
if __name__ == "__main__":
16 years, 6 months
[PATCH] [TEST] .4# add ElementAllocatedFromPool.02 for KVM & XenFV support
by Guo Lian Yun
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1208414787 25200
# Node ID b49b9c198038c05a456921513b70a48875544b26
# Parent 2977c29bb772fb764004aad004e4ff7c43264f38
[TEST] .4# add ElementAllocatedFromPool.02 for KVM & XenFV support
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 2977c29bb772 -r b49b9c198038 suites/libvirt-cim/cimtest/ElementAllocatedFromPool/02_reverse.py
--- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/02_reverse.py Wed Apr 16 10:49:55 2008 +0800
+++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/02_reverse.py Wed Apr 16 23:46:27 2008 -0700
@@ -53,21 +53,21 @@ from VirtLib import live
from VirtLib import live
from XenKvmLib import assoc
from XenKvmLib import enumclass
+from XenKvmLib import vxml
+from XenKvmLib.classes import get_typed_class
from CimTest import Globals
from CimTest.Globals import do_main
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
-sup_types = ['Xen']
+sup_types = ['Xen', 'XenFV', 'KVM']
status = PASS
test_dom = "hd_domain"
test_mac = "00:11:22:33:44:aa"
test_mem = 128
test_vcpus = 4
-test_disk = "xvdb"
test_dpath = "foo"
disk_file = '/tmp/diskpool.conf'
back_disk_file = disk_file + "." + "02_reverse"
@@ -105,14 +105,14 @@ def clean_up_restore(ip):
sys.exit(status)
-def get_or_bail(ip, id, pool_class):
+def get_or_bail(ip, id, pool_class, virt="Xen"):
"""
Getinstance for the CLass and return instance on success, otherwise
exit after cleanup_restore and destroying the guest.
"""
key_list = { 'InstanceID' : id }
try:
- instance = enumclass.getInstance(ip, pool_class, key_list)
+ instance = enumclass.getInstance(ip, pool_class, key_list, virt)
except Exception, detail:
Globals.logger.error(Globals.CIM_ERROR_GETINSTANCE, '%s', pool_class)
Globals.logger.error("Exception: %s", detail)
@@ -127,22 +127,22 @@ def print_error(field, ret_val, req_val)
Globals.logger.error("%s Mismatch", field)
Globals.logger.error("Returned %s instead of %s", ret_val, req_val)
-def init_list(ip, disk, mem, net, proc):
+def init_list(ip, disk, mem, net, proc, virt="Xen"):
"""
Creating the lists that will be used for comparisons.
"""
pllist = {
- "Xen_DiskPool" : disk.InstanceID, \
- "Xen_MemoryPool" : mem.InstanceID, \
- "Xen_NetworkPool" : net.InstanceID, \
- "Xen_ProcessorPool": proc.InstanceID
+ get_typed_class(virt, "DiskPool") : disk.InstanceID, \
+ get_typed_class(virt, "MemoryPool") : mem.InstanceID, \
+ get_typed_class(virt, "NetworkPool") : net.InstanceID, \
+ get_typed_class(virt, "ProcessorPool"): proc.InstanceID
}
cllist = [
- "Xen_LogicalDisk", \
- "Xen_Memory", \
- "Xen_NetworkPort", \
- "Xen_Processor"
+ get_typed_class(virt, "LogicalDisk"), \
+ get_typed_class(virt, "Memory"), \
+ get_typed_class(virt, "NetworkPort"), \
+ get_typed_class(virt, "Processor")
]
prop_list = ["%s/%s" % (test_dom, test_disk), test_disk, \
"%s/%s" % (test_dom, "mem"), test_mem, \
@@ -162,7 +162,7 @@ def get_inst_for_dom(assoc_val):
return list
-def get_spec_fields_list(inst_list, field_name):
+def get_spec_fields_list(inst_list, field_name, virt="Xen"):
global status
specific_fields = { }
if (len(inst_list)) != 1:
@@ -172,7 +172,7 @@ 1", len(inst_list))
return
# verifying the Name field for LogicalDisk
try:
- if inst_list[0]['CreationClassName'] != 'Xen_Memory':
+ if inst_list[0]['CreationClassName'] != get_typed_class(virt, 'Memory'):
field_value = inst_list[0][field_name]
if field_name == 'NetworkAddresses':
# For network we NetworkAddresses is a list of addresses, since we
@@ -190,11 +190,12 @@ 1", len(inst_list))
return specific_fields
-def assoc_values(assoc_list, field , list, index, specific_fields_list=""):
+def assoc_values(assoc_list, field , list, index, specific_fields_list="", virt="Xen"):
"""
Verifying the records retruned by the associations.
"""
global status
+ cn = get_typed_class(virt, 'Processor')
if field == "CreationClassName":
for i in range(len(assoc_list)):
if assoc_list[i][field] != list[index]:
@@ -203,7 +204,7 @@ def assoc_values(assoc_list, field , li
if status != PASS:
break
elif field == "DeviceID":
- if assoc_list[0]['CreationClassName'] == 'Xen_Processor':
+ if assoc_list[0]['CreationClassName'] == cn:
# Verifying the list of DeviceId returned by the association
# against the list created intially .
for i in range(len(list)):
@@ -218,7 +219,7 @@ def assoc_values(assoc_list, field , li
status = FAIL
else:
# other specific fields verification
- if assoc_list[0]['CreationClassName'] != 'Xen_Processor':
+ if assoc_list[0]['CreationClassName'] != cn:
spec_field_name = specific_fields_list['field_name']
spec_field_value = specific_fields_list['field_value']
if spec_field_value != list[index]:
@@ -235,24 +236,28 @@ def main():
server = options.ip
destroy_and_undefine_all(options.ip)
Globals.log_param()
- test_xml, bridge = testxml_bridge(test_dom, mem = test_mem, vcpus = test_vcpus, \
- mac = test_mac, disk = test_disk, server = options.ip)
+ global test_disk
+ 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 was not created properly")
- return FAIL
-
- virt_network = network_by_bridge(bridge, server)
+ 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, server, cmd = "create")
+ ret = cxml.create(options.ip)
if not ret:
- Globals.logger.error("Failed to Create the dom: %s", test_dom)
+ logger.error('Unable to create domain %s' % test_dom)
return FAIL
# Taking care of already existing diskconf file
@@ -264,16 +269,20 @@ def main():
else:
move_file(disk_file, back_disk_file)
conf_file()
+ diskpool_cn = get_typed_class(options.virt, "DiskPool")
+ mempool_cn = get_typed_class(options.virt, "MemoryPool")
+ netpool_cn = get_typed_class(options.virt, "NetworkPool")
+ procpool_cn = get_typed_class(options.virt, "ProcessorPool")
+ diskpool = eval('enumclass.' + diskpool_cn)
+ mempool = eval('enumclass.' + mempool_cn)
+ netpool = eval('enumclass.' + netpool_cn)
+ procpool = eval('enumclass.' + procpool_cn)
try :
- disk = get_or_bail(server, id=diskid, \
- pool_class=enumclass.Xen_DiskPool)
- mem = get_or_bail(server, id = memid, \
- pool_class=enumclass.Xen_MemoryPool)
+ disk = get_or_bail(server, id = diskid, pool_class = diskpool, virt=options.virt)
+ mem = get_or_bail(server, id = memid, pool_class = mempool, virt=options.virt)
netid = "%s/%s" % ("NetworkPool", virt_network)
- net = get_or_bail(server, id = netid, \
- pool_class=enumclass.Xen_NetworkPool)
- proc = get_or_bail(server, id = procid, \
- pool_class=enumclass.Xen_ProcessorPool)
+ net = get_or_bail(server, id = netid, pool_class = netpool, virt=options.virt)
+ proc = get_or_bail(server, id = procid, pool_class = procpool, virt=options.virt)
except Exception, detail:
Globals.logger.error("Exception: %s", detail)
@@ -283,15 +292,16 @@ def main():
cmd = "destroy")
return status
- pllist, cllist, prop_list, proc_prop = init_list(server, disk, mem, net, proc)
+ pllist, cllist, prop_list, proc_prop = init_list(server, disk, mem, net, proc, options.virt)
# Looping through the pllist to get association for various pools.
for cn, instid in sorted(pllist.items()):
try:
- assoc_info = assoc.Associators(server, \
- "Xen_ElementAllocatedFromPool", \
- cn, \
- InstanceID = instid)
+ assoc_info = assoc.Associators(server,
+ "ElementAllocatedFromPool",
+ cn,
+ options.virt,
+ InstanceID = instid)
# Verifying the Creation Class name for all the records returned for each
# pool class queried
inst_list = get_inst_for_dom(assoc_info)
@@ -301,43 +311,51 @@ the specified domain: %s", test_dom)
status = FAIL
break
- assoc_values(assoc_list=inst_list, field="CreationClassName", \
- list=cllist, \
- index=loop)
+ assoc_values(assoc_list=inst_list, field="CreationClassName", list=cllist, \
+ index=loop, virt=options.virt)
# verifying the DeviceID
- if inst_list[0]['CreationClassName'] == 'Xen_Processor':
+ proc_cn = get_typed_class(options.virt, 'Processor')
+ mem_cn = get_typed_class(options.virt, 'Memory')
+ disk_cn = get_typed_class(options.virt, 'LogicalDisk')
+ if inst_list[0]['CreationClassName'] == proc_cn:
# The DeviceID for the processor varies from 0 to (vcpu - 1 )
list_index = 0
assoc_values(assoc_list=inst_list, field="DeviceID", \
list=proc_prop, \
- index=list_index)
+ index=list_index, \
+ virt=options.virt)
else:
# For LogicalDisk, Memory and NetworkPort
- if inst_list[0]['CreationClassName'] == 'Xen_LogicalDisk':
+ if inst_list[0]['CreationClassName'] == disk_cn:
list_index = 0
- elif inst_list[0]['CreationClassName'] == 'Xen_Memory':
+ elif inst_list[0]['CreationClassName'] == mem_cn:
list_index = 2
else:
list_index = 4 # NetworkPort
assoc_values(assoc_list=inst_list, field="DeviceID", \
list=prop_list, \
- index=list_index)
- if inst_list[0]['CreationClassName'] == 'Xen_LogicalDisk':
+ index=list_index, \
+ virt=options.virt)
+ if inst_list[0]['CreationClassName'] == disk_cn:
# verifying the Name field for LogicalDisk
- specific_fields = get_spec_fields_list(inst_list,field_name="Name")
+ specific_fields = get_spec_fields_list(inst_list,field_name="Name", \
+ virt=options.virt)
list_index = 1
- elif inst_list[0]['CreationClassName'] == 'Xen_Memory':
+ elif inst_list[0]['CreationClassName'] == mem_cn:
# verifying the NumberOfBlocks allocated for Memory
- specific_fields = get_spec_fields_list(inst_list,field_name="NumberOfBlocks")
+ specific_fields = get_spec_fields_list(inst_list,field_name="NumberOfBlocks", \
+ virt=options.virt)
list_index = 3
else:
# verifying the NetworkAddresses for the NetworkPort
- specific_fields = get_spec_fields_list(inst_list,field_name="NetworkAddresses")
+ specific_fields = get_spec_fields_list(inst_list,field_name="NetworkAddresses", \
+ virt=options.virt)
list_index = 5 # NetworkPort
assoc_values(assoc_list=inst_list, field="Other", \
list=prop_list, \
index=list_index, \
- specific_fields_list=specific_fields)
+ specific_fields_list=specific_fields, \
+ virt=options.virt)
if status != PASS:
break
else:
@@ -345,13 +363,14 @@ the specified domain: %s", test_dom)
loop = loop + 1
except Exception, detail:
Globals.logger.error(Globals.CIM_ERROR_ASSOCIATORS, \
- 'Xen_ElementAllocatedFromPool')
+ 'ElementAllocatedFromPool')
Globals.logger.error("Exception: %s", detail)
clean_up_restore(server)
status = FAIL
- ret = test_domain_function(test_dom, server, \
- cmd = "destroy")
+ cxml.destroy(options.ip)
+ cxml.undefine(options.ip)
+
clean_up_restore(server)
return status
if __name__ == "__main__":
16 years, 6 months
[PATCH] [TEST].3# add ElementAllocatedFromPool.01 for KVM & XenFV support
by Guo Lian Yun
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1208411620 25200
# Node ID e12d888a9502d9089f982c87305994ec17c28cc4
# Parent 2977c29bb772fb764004aad004e4ff7c43264f38
[TEST].3# add ElementAllocatedFromPool.01 for KVM & XenFV support
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 2977c29bb772 -r e12d888a9502 suites/libvirt-cim/cimtest/ElementAllocatedFromPool/01_forward.py
--- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/01_forward.py Wed Apr 16 10:49:55 2008 +0800
+++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/01_forward.py Wed Apr 16 22:53:40 2008 -0700
@@ -21,56 +21,89 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-# This tc is used to verify the classname, InstanceID are
-# appropriately set for a given of the domains when verified using the
+# This tc is used to verify the classname, InstanceID are
+# appropriately set for a given of the domains when verified using the
# Xen_ElementAllocatedFromPool asscoiation.
#
# Example command for LogicalDisk w.r.t to Xen_ElementAllocatedFromPool \
# asscoiation :
#
-# wbemcli ain -ac Xen_ElementAllocatedFromPool
+# wbemcli ain -ac Xen_ElementAllocatedFromPool
# 'http://localhost:5988/root/virt:
# Xen_LogicalDisk.CreationClassName="Xen_LogicalDisk",\
# DeviceID="hd_domain/xvda",SystemCreationClassName="",SystemName="hd_domain"'
-#
+#
# Output:
# localhost:5988/root/virt:Xen_DiskPool.InstanceID="DiskPool/foo"
-#
+#
# Similarly we check for Memory,Network,Processor.
#
# Date : 26-11-2007
import sys
import pywbem
+import os
+from distutils.file_util import move_file
from XenKvmLib.test_xml import testxml, testxml_bridge
from VirtLib import utils
from XenKvmLib import assoc
-from XenKvmLib.test_doms import test_domain_function, destroy_and_undefine_all
+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'
-
+test_vcpus = 1
+test_dpath = "foo"
+disk_file = '/tmp/diskpool.conf'
+back_disk_file = disk_file + "." + "01_forward"
+
+def conf_file():
+ """
+ Creating diskpool.conf file.
+ """
+ try:
+ f = open(disk_file, 'w')
+ f.write('%s %s' % (test_dpath, '/'))
+ f.close()
+ except Exception,detail:
+ Globals.logger.error("Exception: %s", detail)
+ status = SKIP
+ sys.exit(status)
+
+def clean_up_restore():
+ """
+ Restoring back the original diskpool.conf
+ file.
+ """
+ try:
+ if os.path.exists(back_disk_file):
+ os.remove(disk_file)
+ move_file(back_disk_file, disk_file)
+ except Exception, detail:
+ Globals.logger.error("Exception: %s", detail)
+ status = SKIP
+ sys.exit(status)
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)
+ cs = get_typed_class(virt, "ComputerSystem")
key_list = { 'DeviceID' : id,
'CreationClassName' : cn,
'SystemName' : test_dom,
- 'SystemCreationClassName' : "Xen_ComputerSystem"
+ 'SystemCreationClassName' : cs
}
return key_list
@@ -85,93 +118,104 @@ def main():
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)
+ os.system("rm -f %s" % back_disk_file )
+ if not (os.path.exists(disk_file)):
+ conf_file()
+ else:
+ move_file(disk_file, back_disk_file)
+ conf_file()
+
+ 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")
+ return SKIP
+
+ ret = cxml.define(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)
- 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)
+ Globals.logger.error('Unable to create domain %s' % test_dom)
+ return FAIL
+
+ disk_cn = get_typed_class(options.virt, "LogicalDisk")
+ mem_cn = get_typed_class(options.virt, "Memory")
+ net_cn = get_typed_class(options.virt, "NetworkPort")
+ proc_cn = get_typed_class(options.virt, "Processor")
+
+ try:
+ key_list = get_keys(disk_cn, test_disk, options.virt)
+ disk = eval('devices.' + disk_cn)(options.ip, key_list)
+ except Exception,detail:
+ print_error(cn, detail)
+ return FAIL
+
+ try:
+ key_list = get_keys(mem_cn, "mem", options.virt)
+ mem = eval('devices.' + mem_cn)(options.ip, key_list)
+ except Exception,detail:
+ print_error(cn, detail)
+ return FAIL
+
+ try:
+ key_list = get_keys(net_cn, test_mac, options.virt)
+ net = eval('devices.' + net_cn)(options.ip, key_list)
+ except Exception,detail:
+ print_error(cn, detail)
+ return FAIL
+
+ try:
+ key_list = get_keys(proc_cn, "0", options.virt)
+ proc = eval('devices.' + proc_cn)(options.ip, key_list)
except Exception,detail:
print_error(cn, detail)
return FAIL
netpool_id = "NetworkPool/%s" % virt_network
-
+ diskpool_id = "DiskPool/%s" % test_dpath
lelist = {
- "Xen_LogicalDisk" : disk.DeviceID, \
- "Xen_Memory" : mem.DeviceID, \
- "Xen_NetworkPort" : net.DeviceID, \
- "Xen_Processor" : proc.DeviceID
+ disk_cn : disk.DeviceID, \
+ mem_cn : mem.DeviceID, \
+ net_cn : net.DeviceID, \
+ proc_cn : proc.DeviceID
}
- poollist = [
- "Xen_DiskPool", \
- "Xen_MemoryPool", \
- "Xen_NetworkPool", \
- "Xen_ProcessorPool"
+ poollist = [
+ 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", \
+ poolval = [
+ diskpool_id, \
"MemoryPool/0", \
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
@@ -181,8 +225,8 @@ def main():
assoc_info[0].classname, \
poollist[idx])
status = FAIL
-
- if assoc_info[0]['InstanceID'] != poolval[idx]:
+
+ if assoc_info[0]['InstanceID'] != poolval[idx]:
Globals.logger.error("InstanceID Mismatch")
Globals.logger.error("Returned %s instead of %s", \
assoc_info[0]['InstanceID'], \
@@ -196,13 +240,15 @@ 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)
+ clean_up_restore()
+
return status
-
+
if __name__ == "__main__":
sys.exit(main())
16 years, 6 months
[PATCH] [TEST] .3# update network_by_bridge for KVM & XenFV support
by Guo Lian Yun
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1208399302 -28800
# Node ID 2b19d0a1450ea8df5598a79ff56996145cbfb58f
# Parent 2977c29bb772fb764004aad004e4ff7c43264f38
[TEST] .3# update network_by_bridge for KVM & XenFV support
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 2977c29bb772 -r 2b19d0a1450e lib/VirtLib/live.py
--- a/lib/VirtLib/live.py Wed Apr 16 10:49:55 2008 +0800
+++ b/lib/VirtLib/live.py Thu Apr 17 10:28:22 2008 +0800
@@ -301,15 +301,15 @@
if len(bridge) > 1:
return bridge[1]
-def network_by_bridge(bridge, server):
+def network_by_bridge(bridge, server, virt="Xen"):
"""Function returns virtual network for a given bridge"""
- networks = net_list(server)
+ networks = net_list(server, virt)
if len(networks) == 0:
return None
for network in networks:
- if bridge == get_bridge_from_network_xml(network, server):
+ if bridge == get_bridge_from_network_xml(network, server, virt):
return network
return None
16 years, 6 months
[PATCH] [TEST] .2# add ElementConforms.04 for XenFV & KVM support
by Guo Lian Yun
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1208398366 -28800
# Node ID b19ad6f794584fffcaa13829bdd61da6e2b8d234
# Parent 2977c29bb772fb764004aad004e4ff7c43264f38
[TEST] .2# add ElementConforms.04 for XenFV & KVM support
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 2977c29bb772 -r b19ad6f79458 suites/libvirt-cim/cimtest/ElementConforms/04_ectp_rev_errs.py
--- a/suites/libvirt-cim/cimtest/ElementConforms/04_ectp_rev_errs.py Wed Apr 16 10:49:55 2008 +0800
+++ b/suites/libvirt-cim/cimtest/ElementConforms/04_ectp_rev_errs.py Thu Apr 17 10:12:46 2008 +0800
@@ -82,14 +82,17 @@
import pywbem
from VirtLib import utils, live
from XenKvmLib import assoc
+from XenKvmLib import vxml
+from XenKvmLib.classes import get_typed_class
from XenKvmLib.common_util import try_assoc
+from XenKvmLib.test_doms import destroy_and_undefine_all
from CimTest.ReturnCodes import PASS, FAIL
from CimTest.Globals import log_param, logger, CIM_USER, CIM_PASS, CIM_NS, do_main
-sup_types = ['Xen']
+sup_types = ['Xen', 'XenFV', 'KVM']
-ac_classname = 'Xen_ElementConformsToProfile'
bug = '92642'
+test_dom = "domU"
cs_values = {
"INVALID_CCName_Keyname" : { 'rc' : 6 , 'desc' : 'No such instance' }, \
@@ -105,7 +108,8 @@
"INVALID_Name_Keyvalue" : { 'rc' : 6 , 'desc' : 'No such instance' }
}
-def try_invalid_assoc(classname, name_val, i, field):
+def try_invalid_assoc(classname, name_val, i, field, virt="Xen"):
+ ac_classname = get_typed_class(virt, "ElementConformsToProfile")
j = 0
keys = {}
temp = name_val[i]
@@ -113,7 +117,7 @@
for j in range(len(name_val)/2):
k = j * 2
keys[name_val[k]] = name_val[k+1]
- if classname == "Xen_HostSystem":
+ if classname == get_typed_class(virt, "HostSystem"):
expr_values = hs_values
else:
expr_values = cs_values
@@ -134,16 +138,24 @@
global conn
conn = assoc.myWBEMConnection('http://%s' % options.ip, (CIM_USER, CIM_PASS), CIM_NS)
+ virt_xml = vxml.get_class(options.virt)
+ cxml = virt_xml(test_dom)
+ ret = cxml.define(options.ip)
+ if not ret:
+ logger.error('Unable to define domain %s' % test_dom)
+ return FAIL
+ hs = get_typed_class(options.virt, "HostSystem")
+ cs = get_typed_class(options.virt, "ComputerSystem")
host_name = live.hostname(options.ip)
host_name_val = [
- 'CreationClassName', 'Xen_HostSystem', \
+ 'CreationClassName', hs, \
'Name', host_name
]
comp_name_val = [
- 'CreationClassName', 'Xen_ComputerSystem', \
- 'Name', 'Domain-0'
+ 'CreationClassName', cs, \
+ 'Name', test_dom
]
tc_scen = [
@@ -154,12 +166,12 @@
]
for i in range(len(tc_scen)):
- retval = try_invalid_assoc('Xen_HostSystem', host_name_val, i, tc_scen[i])
+ retval = try_invalid_assoc(hs, host_name_val, i, tc_scen[i], options.virt)
if retval != PASS:
status = retval
for i in range(len(tc_scen)):
- retval = try_invalid_assoc('Xen_ComputerSystem', comp_name_val, i, tc_scen[i])
+ retval = try_invalid_assoc(cs, comp_name_val, i, tc_scen[i], options.virt)
if retval != PASS:
status = retval
16 years, 6 months
[PATCH] [TEST] .2# Add KVM support for HostedDependency.03
by zli@linux.vnet.ibm.com
# HG changeset patch
# User Zhengang Li <lizg(a)cn.ibm.com>
# Date 1208397762 -28800
# Node ID 7080c55211cbaffdc60ca2110ff949638f457c28
# Parent 29a35b835943eee34952e099797d03d5e89a923e
[TEST] .2# Add KVM support for HostedDependency.03
Updates:
- Move failure rc code assignment to the exception block.
Signed-off-by: Zhengang Li <lizg(a)cn.ibm.com>
diff -r 29a35b835943 -r 7080c55211cb suites/libvirt-cim/cimtest/HostedDependency/03_enabledstate.py
--- a/suites/libvirt-cim/cimtest/HostedDependency/03_enabledstate.py Wed Apr 16 10:44:03 2008 +0800
+++ b/suites/libvirt-cim/cimtest/HostedDependency/03_enabledstate.py Thu Apr 17 10:02:42 2008 +0800
@@ -32,19 +32,19 @@
import sys
from time import sleep
-from XenKvmLib.test_xml import testxml
from VirtLib import utils
+from XenKvmLib import vxml
from XenKvmLib import computersystem
from XenKvmLib import assoc
from XenKvmLib.common_util import get_host_info
-from XenKvmLib.test_doms import test_domain_function, destroy_and_undefine_all
+from XenKvmLib.classes import get_class_basename
from CimTest.Globals import log_param, logger, CIM_ERROR_ASSOCIATORS, \
CIM_ERROR_GETINSTANCE
from CimTest.Globals import do_main
from XenKvmLib.devices import CIM_Instance
from CimTest.ReturnCodes import PASS, FAIL
-sup_types = ['Xen']
+sup_types = ['Xen', 'KVM']
test_dom = "hd_domain1"
test_mac = "00:11:22:33:44:55"
@@ -62,7 +62,7 @@ def print_error(field, ret_val, req_val)
logger.error("%s Mismatch", field)
logger.error("Returned %s instead of %s", ret_val, req_val)
-def poll_for_enabledstate_value(server):
+def poll_for_enabledstate_value(server, virt):
status = PASS
dom_field_list = {}
check_reqstate_value = None
@@ -70,7 +70,8 @@ def poll_for_enabledstate_value(server):
try:
for i in range(1, (timeout + 1)):
sleep(1)
- dom_cs = computersystem.Xen_ComputerSystem(server, name=test_dom)
+ cs = computersystem.get_cs_class(virt)
+ dom_cs = cs(server, name=test_dom)
if dom_cs.EnabledState == "" or dom_cs.CreationClassName == "" or \
dom_cs.Name == "" or dom_cs.RequestedState == "":
logger.error("Empty EnabledState field.")
@@ -83,7 +84,7 @@ def poll_for_enabledstate_value(server):
break
except Exception, detail:
- logger.error(CIM_ERROR_GETINSTANCE, 'Xen_ComputerSystem')
+ logger.error(CIM_ERROR_GETINSTANCE, 'ComputerSystem')
logger.error("Exception: %s" % detail)
status = FAIL
@@ -94,31 +95,39 @@ def poll_for_enabledstate_value(server):
return status, dom_field_list
+class HsError(Exception):
+ pass
+
@do_main(sup_types)
def main():
options = main.options
log_param()
status = PASS
- destroy_and_undefine_all(options.ip)
- test_xml = testxml(test_dom, mac = test_mac)
- ret = test_domain_function(test_xml, options.ip, cmd = "create")
+ virtxml = vxml.get_class(options.virt)
+ cxml = virtxml(test_dom, mac = test_mac)
+
+ ret = cxml.create(options.ip)
if not ret:
logger.error("Failed to Create the dom: %s" % test_dom)
status = FAIL
return status
- ret = test_domain_function(test_dom, options.ip, cmd = "suspend")
+ ret = cxml.run_virsh_cmd(options.ip, "suspend")
if not ret:
logger.error("Failed to suspend the dom: %s" % test_dom)
+ cxml.destroy(options.ip)
+ cxml.undefine(options.ip)
status = FAIL
return status
- status, host_name, host_ccn = get_host_info(options.ip)
+ status, host_name, host_ccn = get_host_info(options.ip, options.virt)
if status != PASS:
- ret = test_domain_function(test_dom, options.ip, cmd = "destroy")
+ logger.error("Failed to get host info")
+ cxml.destroy(options.ip)
+ cxml.undefine(options.ip)
return status
try:
@@ -128,25 +137,24 @@ def main():
#it does not get set immediatley to value of 9 when suspended.
dom_field_list = {}
- status, dom_field_list = poll_for_enabledstate_value(options.ip)
+ status, dom_field_list = poll_for_enabledstate_value(options.ip,
+ options.virt)
if status != PASS or len(dom_field_list) == 0:
- test_domain_function(test_dom, options.ip, cmd = "destroy")
- return status
+ raise HsError("Failed to poll for enabled state value")
- hs = assoc.Associators(options.ip, "Xen_HostedDependency", host_ccn, \
+ hs = assoc.Associators(options.ip, "HostedDependency",
+ get_class_basename(host_ccn), options.virt,
CreationClassName=host_ccn, Name=host_name)
if len(hs) == 0:
- logger.error("HostedDependency didn't return any instances.")
- return FAIL
+ raise HsError("HostedDependency didn't return any instances.")
hs_field_list = []
- for i in range(len(hs)):
- if hs[i]['Name'] == test_dom:
- hs_field_list = create_list(CIM_Instance(hs[i]))
+ for hsi in hs:
+ if hsi['Name'] == test_dom:
+ hs_field_list = create_list(CIM_Instance(hsi))
if len(hs_field_list) == 0:
- logger.error("Association did not return expected guest instance.")
- return FAIL
+ raise HsError("Association did not return expected guest instance.")
if dom_field_list['CreationClassName'] != hs_field_list['CreationClassName']:
print_error('CreationClassName', hs_field_list['CreationClassName'], \
@@ -165,12 +173,16 @@ def main():
print_error('EnabledState', hs_field_list['EnabledState'], \
dom_field_list['EnabledState'])
status = FAIL
+ except HsError, detail:
+ status = FAIL
+ logger.error(detail)
except Exception, detail:
- logger.error(CIM_ERROR_ASSOCIATORS,'Xen_HostedDependency')
+ logger.error(CIM_ERROR_ASSOCIATORS,'HostedDependency')
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__":
diff -r 29a35b835943 -r 7080c55211cb suites/libvirt-cim/lib/XenKvmLib/common_util.py
--- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Wed Apr 16 10:44:03 2008 +0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Thu Apr 17 10:02:42 2008 +0800
@@ -136,7 +136,7 @@ def get_host_info(server, virt="Xen"):
host_ccn = host_sys.CreationClassName
host_name = host_sys.Name
except Exception, detail:
- logger.error(CIM_ERROR_ENUMERATE, 'Xen_HostSystem')
+ logger.error(CIM_ERROR_ENUMERATE, 'HostSystem')
logger.error("Exception: %s", detail)
status = FAIL
return status, host_name, host_ccn
16 years, 6 months