# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1223901834 25200
# Node ID 5ec9783447b1f35c57f4d1ed73ecafa1d4cccc44
# Parent c7eaf17bd591f313b93ff2b2087cee11b25789e0
[TEST] Fixing 01_forward.py tc of HostedResourcePool.
The tc would fails in case if there is more than one pool for a particular devtype.
Tested with Xen, XenFV, KVM with current sources, with/without sblim-base-provider.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r c7eaf17bd591 -r 5ec9783447b1
suites/libvirt-cim/cimtest/HostedResourcePool/01_forward.py
--- a/suites/libvirt-cim/cimtest/HostedResourcePool/01_forward.py Fri Oct 10 03:08:12 2008
-0700
+++ b/suites/libvirt-cim/cimtest/HostedResourcePool/01_forward.py Mon Oct 13 05:43:54 2008
-0700
@@ -24,6 +24,7 @@
#
import sys
+from sets import Set
from XenKvmLib import assoc
from XenKvmLib import enumclass
from XenKvmLib.common_util import get_host_info
@@ -39,14 +40,14 @@
@do_main(sup_types)
def main():
options = main.options
-
+ virt = options.virt
keys = ['Name', 'CreationClassName']
- status, host_sys, host_cn = get_host_info(options.ip, options.virt)
+ status, host_sys, host_cn = get_host_info(options.ip, virt)
if status != PASS:
logger.error("Error in calling get_host_info function")
return FAIL
try:
- assoc_cn = get_typed_class(options.virt, "HostedResourcePool")
+ assoc_cn = get_typed_class(virt, "HostedResourcePool")
pool = assoc.AssociatorNames(options.ip,
assoc_cn,
host_cn,
@@ -66,26 +67,51 @@
else:
logger.error("No pool returned")
return FAIL
+
+ mpool = get_typed_class(virt, 'MemoryPool')
+ exp_pllist = { mpool : ['MemoryPool/0'] }
+ if virt != 'LXC':
+ npool = get_typed_class(virt, 'NetworkPool')
+ dpool = get_typed_class(virt, 'DiskPool')
+ ppool = get_typed_class(virt, 'ProcessorPool')
+ exp_pllist[dpool] = ['DiskPool/%s' % default_pool_name]
+ exp_pllist[npool] = ['%s/%s' %('NetworkPool',
default_network_name)]
+ exp_pllist[ppool] = ['ProcessorPool/0']
try:
+ res_pllist = {}
for items in pool:
- cname = items.classname
- if cname.find("MemoryPool") >=0 and items['InstanceID']
!= \
- "MemoryPool/0":
- raise Exception("%s does not match MemoryPool/0",
- items['InstanceID'])
- elif cname.find("ProcessorPool") >=0 and
items['InstanceID'] != \
- "ProcessorPool/0":
- raise Exception("%s does not match ProcessorPool/0",
- items['InstanceID'])
- elif cname.find("NetworkPool") >=0 and
items['InstanceID'] != \
- "NetworkPool/%s" %default_network_name:
- raise Exception("%s does not match NetworkPool/%s",
- items['InstanceID'], default_network_name)
- elif cname.find("DiskPool") >=0 and items['InstanceID']
!= \
- "DiskPool/%s" % default_pool_name:
- raise Exception("%s does not match DiskPool/%s",
- items['InstanceID'], default_pool_name)
+ # The dict has some elements
+ if len(res_pllist) != 0:
+ # If the dict already has the key we append the new value
+ if items.classname in res_pllist.keys():
+ list = []
+ list = res_pllist[items.classname]
+ list.append(items['InstanceID'])
+ res_pllist[items.classname] = list
+ else:
+ # If the dict is not empty, but does not yet contain
+ # items.classname, we create new item
+ res_pllist[items.classname] = [items['InstanceID']]
+ else:
+ # When the dict is empty
+ res_pllist[items.classname] = [items['InstanceID']]
+
+ #Verifying we get all the expected pool class info
+ if len(Set(exp_pllist.keys()) - Set(res_pllist.keys())) != 0:
+ logger.error("Pool Class mismatch")
+ raise Exception("Expected Pool class list: %s \n \t Got: %s"
+ % (sorted(exp_pllist.keys()),
+ sorted(res_pllist.keys())))
+
+ #Verifying that we get the atleast the expected instanceid
+ #for every pool class
+ for key in exp_pllist.keys():
+ if len(Set(exp_pllist[key]) - Set(res_pllist[key])) != 0:
+ logger.error("InstanceID mismatch")
+ raise Exception("Expected InstanceID: %s \n \t Got: %s"
+ % (sorted(exp_pllist[key]),
+ sorted(res_pllist[key])))
except Exception, details:
logger.error(details)
return FAIL