Please ignore this patch, thanks!
libvirt-cim-bounces(a)redhat.com wrote on 2008-04-17 14:27:57:
# 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__":
_______________________________________________
Libvirt-cim mailing list
Libvirt-cim(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim