InputRASD's and an uncoming ControllerRASD object can appear multiple
times in the guest XML. Currently the code uses dictionaries with the
ClassName of the object as the key to the dictionary. We cannot do that
as we move forward, so convert to using a list. The list will be a tuple
of the ClassName and the object previously stored in the dictionary key.
InputRASD's currently only have a mouse or tablet, but as of libvirt v1.2.2
there will be a keyboard device added.
ControllerRASD's will be added shortly and there are usually 2 or 3 per
domain.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
.../ComputerSystem/41_cs_to_settingdefinestate.py | 57 +++++++++++-----------
.../cimtest/HostSystem/02_hostsystem_to_rasd.py | 11 +++--
.../cimtest/RASD/01_verify_rasd_fields.py | 18 +++++--
.../ResourceAllocationFromPool/02_reverse.py | 12 ++---
.../cimtest/ServiceAffectsElement/01_forward.py | 57 ++++++++++++----------
.../cimtest/ServiceAffectsElement/02_reverse.py | 22 ++++-----
.../cimtest/SettingsDefine/02_reverse.py | 36 +++++++++-----
7 files changed, 121 insertions(+), 92 deletions(-)
diff --git a/suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py
b/suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py
index 4733f90..74565db 100644
--- a/suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py
@@ -99,19 +99,19 @@ def get_associators_info(server, cn, an, qcn, instid):
cn,
InstanceID = instid)
if len(assoc_info) < 1:
- logger.error("%s returned %i %s objects",
+ logger.error("get_associators_info %s returned %i %s objects",
an, len(assoc_info), qcn)
status = FAIL
except Exception, detail:
logger.error(CIM_ERROR_ASSOCIATORS, cn)
- logger.error("Exception: %s", detail)
+ logger.error("get_associators_info Exception: %s", detail)
status = FAIL
return status, assoc_info
def init_rasd_list(virt, ip):
- rasd_insts = {}
+ rasd_insts = []
rasds, status = enum_rasds(virt, ip)
if status != PASS:
logger.error("Enum RASDs failed")
@@ -125,14 +125,14 @@ def init_rasd_list(virt, ip):
return rasd_insts, FAIL
if guest == test_dom:
- rasd_insts[rasd.Classname] = rasd
+ rasd_insts.append((rasd.Classname,rasd.InstanceID))
return rasd_insts, PASS
def verify_values(assoc_info, vssd_cs_values, an, qcn):
if len(assoc_info) != 1:
- logger.error("%s returned %i %s objects, Expected 1", an,
+ logger.error("verify_values %s returned %i %s objects, Expected 1",
an,
len(assoc_info), qcn)
return FAIL
@@ -140,18 +140,19 @@ def verify_values(assoc_info, vssd_cs_values, an, qcn):
return compare_all_prop(vssd_cs_assoc, vssd_cs_values)
def build_sd_info(sd_assoc_info, qcn, an, rasd_values):
- sd_info = {}
+ sd_info = []
# Building the input for SettingsDefineState association.
for sd_val in sd_assoc_info:
if sd_val['SystemName'] == test_dom:
classname_keyvalue = sd_val['CreationClassName']
deviceid = sd_val['DeviceID']
- sd_info[classname_keyvalue] = deviceid
+ print "system, deviceid", test_dom, deviceid
+ sd_info.append((classname_keyvalue, deviceid))
# Expect the SystemDevice records == len(rasd_values) entries.
if len(sd_info) != len(rasd_values):
- logger.error("%s returned %i %s objects, Expected %i", an,
+ logger.error("build_sd_info %s returned %i %s objects, Expected %i",
an,
len(sd_info), qcn, len(rasd_values))
return FAIL, sd_info
@@ -171,7 +172,7 @@ def get_cs_sysdev_info(server, virt, qcn, rasd_val):
CreationClassName=cs_class,
Name=test_dom)
if len(sd_assoc) < 1:
- raise Exception("%s returned %d %s objects" \
+ raise Exception("get_cs_sysdev_info %s returned %d %s objects" \
% (an, len(sd_assoc), qcn))
status, sd_info = build_sd_info(sd_assoc, qcn, an, rasd_val)
@@ -180,18 +181,18 @@ def get_cs_sysdev_info(server, virt, qcn, rasd_val):
% test_dom)
except Exception, details:
- logger.error("Exception details: %s", details)
+ logger.error("get_cs_sysdev_info Exception details: %s", details)
return FAIL, dom_cs, sd_info
return PASS, dom_cs, sd_info
def get_sds_info(server, virt, cs_cn, rasd_values,
in_setting_define_state, qcn):
- sds_info = {}
+ sds_info = []
try:
an = get_typed_class(virt,"SettingsDefineState")
- for cn, devid in sorted(in_setting_define_state.items()):
+ for cn, devid in in_setting_define_state:
assoc_info = Associators(server, an, cn, DeviceID = devid,
CreationClassName = cn,
SystemName = test_dom,
@@ -200,29 +201,29 @@ def get_sds_info(server, virt, cs_cn, rasd_values,
# we expect only one RASD record to be returned for each device
# type when queried with SDS association.
if len(assoc_info) != 1:
- raise Exception("%s returned %d %s objects, Expected 1" \
- % (an, len(assoc_info), cn))
-
+ raise Exception("get_sds_info %s returned %d %s objects, "
+ "Expected 1" % (an, len(assoc_info), cn))
+
assoc_val = assoc_info[0]
CCName = assoc_val.classname
- exp_rasd = rasd_values[CCName]
- if assoc_val['InstanceID'] != exp_rasd.InstanceID:
- raise Exception("Got %s instead of %s" \
- % (assoc_val['InstanceID'],
- exp_rasd.InstanceID))
+ InstanceID = assoc_val['InstanceID']
+ if (CCName,InstanceID) not in rasd_values:
+ raise Exception("get_sds_info cannot find (%s,%s) "
+ "in rasd_values" % (CCName,InstanceID))
# Build the input required for VSSDC association query.
vs_name = assoc_val['InstanceID']
if vs_name.find(test_dom) >= 0:
instid = assoc_val['InstanceID']
- sds_info[CCName] = instid
+ sds_info.append((CCName,instid))
if len(sds_info) != len(rasd_values):
- raise Exception("%s returned %i %s objects, Expected %i" \
- % (an, len(sds_info), qcn, len(rasd_values)))
+ raise Exception("get_sds_info %s returned %i %s objects, "
+ " Expected %i" % \
+ (an, len(sds_info), qcn, len(rasd_values)))
except Exception, details:
- logger.error("Exception: %s", details)
+ logger.error("get_sds_info Exception: %s", details)
return FAIL, sds_info
return PASS, sds_info
@@ -243,7 +244,7 @@ def get_vssd_info(server, virt, in_vssdc_list, qcn):
raise Exception("Instance matching %s was not returned" %
test_dom)
an = get_typed_class(virt, 'VirtualSystemSettingDataComponent')
- for cn, instid in sorted((in_vssdc_list.items())):
+ for cn, instid in in_vssdc_list:
status, vssd_assoc_info = get_associators_info(server, cn, an,
vssd_class,
instid)
@@ -255,7 +256,7 @@ def get_vssd_info(server, virt, in_vssdc_list, qcn):
raise Exception("VSSD values verification error")
except Exception, details:
- logger.error("Exception details: %s", details)
+ logger.error("get_vssd_info Exception details: %s", details)
return FAIL, vssd_assoc_info
return PASS, vssd_assoc_info
@@ -279,7 +280,7 @@ def verify_vssdc_assoc(server, virt, cs_class, vssd_assoc_info,
dom_cs):
status = verify_values(cs_assoc_info, dom_cs, an, cs_class)
except Exception, details:
- logger.error("Exception details: %s", details)
+ logger.error("verify_vssd_assoc Exception details: %s", details)
return FAIL
return status
@@ -318,7 +319,7 @@ def main():
vssd_assoc_info, dom_cs)
except Exception, details:
- logger.error("Exception details is %s", details)
+ logger.error("main Exception details is %s", details)
status = FAIL
vsxml.cim_destroy(server)
diff --git a/suites/libvirt-cim/cimtest/HostSystem/02_hostsystem_to_rasd.py
b/suites/libvirt-cim/cimtest/HostSystem/02_hostsystem_to_rasd.py
index fe0f2cc..48f0d2f 100644
--- a/suites/libvirt-cim/cimtest/HostSystem/02_hostsystem_to_rasd.py
+++ b/suites/libvirt-cim/cimtest/HostSystem/02_hostsystem_to_rasd.py
@@ -138,14 +138,14 @@ def get_assoc_info(server, cn, an, qcn, name, vsxml):
return status, assoc_info
def verify_RASD_values(server, sd_assoc_info, vsxml, virt="Xen"):
- in_setting_define_state = {}
+ in_setting_define_state = []
status = PASS
try:
for i in range(len(sd_assoc_info)):
if sd_assoc_info[i]['SystemName'] == test_dom:
classname_keyvalue = sd_assoc_info[i]['CreationClassName']
deviceid = sd_assoc_info[i]['DeviceID']
- in_setting_define_state[classname_keyvalue] = deviceid
+ in_setting_define_state.append((classname_keyvalue,deviceid))
status, rasd_values, in_list = rasd_init_list(vsxml, virt,
test_disk, test_dom,
@@ -156,7 +156,7 @@ def verify_RASD_values(server, sd_assoc_info, vsxml,
virt="Xen"):
an = get_typed_class(virt, 'SettingsDefineState')
sccn = get_typed_class(virt, 'ComputerSystem')
- for cn, devid in sorted(in_setting_define_state.items()):
+ for cn, devid in in_setting_define_state:
assoc_info = Associators(server,
an,
cn,
@@ -170,8 +170,9 @@ def verify_RASD_values(server, sd_assoc_info, vsxml,
virt="Xen"):
status = FAIL
break
index = (len(assoc_info) - 1)
+ assoc_val = assoc_info[index]
rasd = rasd_values[cn]
- CCName = assoc_info[index].classname
+ CCName = assoc_val.classname
if 'ProcResourceAllocationSettingData' in CCName:
status = verify_procrasd_values(assoc_info[index], rasd)
elif 'NetResourceAllocationSettingData' in CCName:
@@ -189,7 +190,7 @@ def verify_RASD_values(server, sd_assoc_info, vsxml,
virt="Xen"):
else:
status = FAIL
if status != PASS:
- logger.error("Mistmatching association values" )
+ logger.error("Mismatching association values" )
break
except Exception, detail:
print_err(CIM_ERROR_ASSOCIATORS, detail, an)
diff --git a/suites/libvirt-cim/cimtest/RASD/01_verify_rasd_fields.py
b/suites/libvirt-cim/cimtest/RASD/01_verify_rasd_fields.py
index c847781..92cdd80 100644
--- a/suites/libvirt-cim/cimtest/RASD/01_verify_rasd_fields.py
+++ b/suites/libvirt-cim/cimtest/RASD/01_verify_rasd_fields.py
@@ -64,7 +64,7 @@ test_mem = 128
test_mac = "00:11:22:33:44:aa"
def init_rasd_list(virt, ip):
- rasd_insts = {}
+ rasd_insts = []
rasds, status = enum_rasds(virt, ip)
if status != PASS:
logger.error("Enum RASDs failed")
@@ -78,7 +78,7 @@ def init_rasd_list(virt, ip):
return rasd_insts, FAIL
if guest == test_dom:
- rasd_insts[rasd.Classname] = rasd
+ rasd_insts.append(rasd)
return rasd_insts, PASS
@@ -102,9 +102,19 @@ def verify_rasd(virt, ip, assoc_info):
logger.error("VSSDC should not have returned info for dom %s",
guest)
return FAIL
-
+
logger.info("Verifying: %s", rasd.classname)
- exp_rasd = rasds[rasd.classname]
+ # Find our rasd
+ exp_rasd = None
+ for r in rasds:
+ if r.Classname == rasd.classname and \
+ r.InstanceID == rasd['InstanceId']:
+ exp_rasd = r
+ break;
+ if exp_rasd is None:
+ logger.error("Could not find %s,%s in rasds",
+ rasd.classname, rasd['InstanceId'])
+ return FAIL
status = compare_all_prop(rasd, exp_rasd)
if status != PASS:
return status
diff --git a/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py
b/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py
index bef114d..5c51f0f 100644
--- a/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py
+++ b/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py
@@ -67,7 +67,7 @@ def setup_env(server, virt):
def init_rasd_list(virt, ip, guest_name):
disk_rasd_cn = get_typed_class(virt, "DiskResourceAllocationSettingData")
- rasd_insts = {}
+ rasd_insts = []
rasds, status = enum_rasds(virt, ip)
if status != PASS:
@@ -85,7 +85,7 @@ def init_rasd_list(virt, ip, guest_name):
return rasd_insts, FAIL
if guest == guest_name:
- rasd_insts[rasd.Classname] = rasd
+ rasd_insts.append((rasd.Classname, rasd))
return rasd_insts, PASS
@@ -171,12 +171,12 @@ def main():
if status != PASS:
raise Exception("Unable to build pool instance list")
- if len(rasds) != len(pools):
- raise Exception("%d RASD insts != %d pool insts" % (len(rasds),
- len(pools)))
+ # There can be more than one instance per rasd class, such as is
+ # the case for controllers, so we cannot compare the number of
+ # elements in each.
an = get_typed_class(virt, "ResourceAllocationFromPool")
- for rasd_cn, rasd in rasds.iteritems():
+ for rasd_cn, rasd in rasds:
pool = AssociatorNames(server,
an,
rasd_cn,
diff --git a/suites/libvirt-cim/cimtest/ServiceAffectsElement/01_forward.py
b/suites/libvirt-cim/cimtest/ServiceAffectsElement/01_forward.py
index fc1590d..9005b67 100644
--- a/suites/libvirt-cim/cimtest/ServiceAffectsElement/01_forward.py
+++ b/suites/libvirt-cim/cimtest/ServiceAffectsElement/01_forward.py
@@ -64,11 +64,11 @@ sae_assoc_with_input_graphics_rev = 795
test_dom = "SAE_dom"
def get_dom_records(an_cn, assoc_ei_info, assoc_ei_insts):
-
+
for assoc_ei_item in assoc_ei_info:
rec = None
CCN = assoc_ei_item['CreationClassName']
- if 'DisplayController' in CCN or 'PointingDevice' in CCN :
+ if 'DisplayController' in CCN or 'PointingDevice' in CCN :
guest, dev, status = parse_instance_id(assoc_ei_item['DeviceID'])
if status != PASS:
logger.error("Unable to parse DeviceID")
@@ -84,11 +84,8 @@ def get_dom_records(an_cn, assoc_ei_info, assoc_ei_insts):
"%s association", CCN, an_cn)
return assoc_ei_insts, FAIL
- if not CCN in assoc_ei_insts.keys() and rec != None:
- assoc_ei_insts[CCN]=rec
- elif rec != None and (CCN in assoc_ei_insts.keys()):
- logger.error("Got more than one record for '%s'", CCN)
- return assoc_ei_insts, FAIL
+ if rec is not None:
+ assoc_ei_insts.append(rec)
return assoc_ei_insts, PASS
@@ -100,7 +97,7 @@ def init_list_for_compare(server, virt):
c_list.append('PointingDevice' )
c_list.append('DisplayController')
- init_list = {}
+ init_list = []
for name in c_list:
c_name = get_typed_class(virt, name)
ei_details = EnumInstances(server, c_name, ret_cim_inst=True)
@@ -110,33 +107,43 @@ def init_list_for_compare(server, virt):
return init_list, PASS
-
def verify_assoc(server, virt, an, assoc_info):
- assoc_insts = {}
+ assoc_insts = []
try:
assoc_insts, status = get_dom_records(an, assoc_info, assoc_insts)
if status != PASS or len(assoc_insts) < 1 :
raise Exception("Failed to get insts for domain %s" % test_dom)
in_list, status = init_list_for_compare(server, virt)
- if status != PASS or len(in_list) != 3:
+ if status != PASS:
raise Exception("Failed to get init_list")
- in_list_keys = Set(in_list.keys())
- assoc_list_keys = Set(assoc_insts.keys())
- if len(in_list_keys & assoc_list_keys) < 1 :
- raise Exception("Mistmatching Class Names, expected %s, got %s" \
- % (in_list_keys, assoc_list_keys))
-
- for cname, prop in in_list.iteritems():
- logger.info("Verifying Values for '%s'", cname)
- exp_vals = in_list[cname].items()
- res_vals = assoc_insts[cname].items()
- for i in range(0, len(prop)):
- if exp_vals[i][1] != res_vals[i][1]:
+ if len(in_list) != len(assoc_insts):
+ raise Exception("in_list len=%d != assoc_insts len=%d",
+ len(in_inst), len(assoc_insts))
+
+ in_list_ccns = []
+ assoc_insts_ccns = []
+ for i in in_list:
+ in_list_ccns.append(i['CreationClassName'])
+ for a in assoc_insts:
+ assoc_insts_ccns.append(a['CreationClassName'])
+ if in_list_ccns != assoc_insts_ccns:
+ raise Exception("Mismatching Class Names, expected %s, got %s" \
+ % (in_list_ccns, assoc_insts_ccns))
+
+ for exp_vals, res_vals in zip(in_list, assoc_insts):
+ if len(exp_vals) != len(res_vals):
+ raise Exception("'%s' mismatching element count exp=%d
res=%d" \
+ % (exp_vals['CreationClassName'], \
+ len(exp_vals), len(res_vals)))
+
+ for key in exp_vals.keys():
+ if exp_vals[key] != res_vals[key]:
logger.error("'%s' val mismatch for '%s': "
\
- "got '%s', expected '%s'",
exp_vals[i][0],
- cname, res_vals[i][1], exp_vals[i][1])
+ "got '%s', expected '%s'",
+ exp_vals['CreationClassName'], key,
+ res_vals[key], exp_vals[key])
return FAIL
except Exception, details:
diff --git a/suites/libvirt-cim/cimtest/ServiceAffectsElement/02_reverse.py
b/suites/libvirt-cim/cimtest/ServiceAffectsElement/02_reverse.py
index 391ad42..d8340aa 100644
--- a/suites/libvirt-cim/cimtest/ServiceAffectsElement/02_reverse.py
+++ b/suites/libvirt-cim/cimtest/ServiceAffectsElement/02_reverse.py
@@ -62,7 +62,7 @@ dc_dev_rev = 725
test_dom = "SAE_dom"
def get_dom_records(cn, ei_info):
- ei_insts = {}
+ ei_insts = []
for ei_item in ei_info:
rec = None
CCN = ei_item['CreationClassName']
@@ -82,11 +82,8 @@ def get_dom_records(cn, ei_info):
"%s association", CCN, cn)
return ei_insts, FAIL
- if not CCN in ei_insts.keys() and rec != None:
- ei_insts[CCN]=rec
- elif rec != None and (CCN in ei_insts.keys()):
- logger.error("Got more than one record for '%s'", CCN)
- return ei_insts, FAIL
+ if rec is not None:
+ ei_insts.append((CCN, rec))
return ei_insts, PASS
@@ -99,17 +96,20 @@ def init_list_for_assoc(server, virt):
if curr_cim_rev >= dc_dev_rev:
c_list.append('DisplayController')
- key_dict = {}
+ in_list = []
for name in c_list:
- init_list = {}
c_name = get_typed_class(virt, name)
ei_details = EnumNames(server, c_name)
init_list, status = get_dom_records(c_name, ei_details)
if status != PASS:
return init_list, FAIL
- key_dict[c_name] = dict(init_list[c_name].keybindings)
- return key_dict, PASS
+ # List is returned as paired list of all bindings of the
+ # type ccn (or c_list).
+ for ccn, elem in init_list:
+ in_list.append((ccn, dict(elem.keybindings)))
+
+ return in_list, PASS
@do_main(sup_types)
@@ -139,7 +139,7 @@ def main():
raise Exception("'%s' returned %i records, expected 1" \
% (c_name, len(crs)))
- for cn, value in in_list.iteritems():
+ for cn, value in in_list:
logger.info("Verifying '%s' association with '%s'",
an, cn)
if 'ComputerSystem' in cn:
assoc_info = Associators(server, an, cn,
diff --git a/suites/libvirt-cim/cimtest/SettingsDefine/02_reverse.py
b/suites/libvirt-cim/cimtest/SettingsDefine/02_reverse.py
index 1917113..8cec0e3 100644
--- a/suites/libvirt-cim/cimtest/SettingsDefine/02_reverse.py
+++ b/suites/libvirt-cim/cimtest/SettingsDefine/02_reverse.py
@@ -93,7 +93,7 @@ def setup_env(server, virt):
def init_rasd_list(virt, ip, guest_name):
proc_rasd_cn = get_typed_class(virt, "ProcResourceAllocationSettingData")
- rasd_insts = {}
+ rasd_insts = []
rasds, status = enum_rasds(virt, ip)
if status != PASS:
@@ -108,12 +108,12 @@ def init_rasd_list(virt, ip, guest_name):
return rasd_insts, FAIL
if guest == guest_name:
- rasd_insts[rasd.Classname] = rasd
+ rasd_insts.append((rasd.Classname, rasd))
return rasd_insts, PASS
def init_device_list(virt, ip, guest_name):
- dev_insts = {}
+ dev_insts = []
devs, status = enum_dev(virt, ip)
if status != PASS:
@@ -128,7 +128,7 @@ def init_device_list(virt, ip, guest_name):
return dev_insts, FAIL
if guest == guest_name:
- dev_insts[dev.Classname] = dev
+ dev_insts.append((dev.Classname, dev))
return dev_insts, PASS
@@ -140,11 +140,15 @@ def verify_rasd(virt, enum_list, rasds):
status = FAIL
for rasd in enum_list:
- exp_rasd = rasds[rasd.classname]
-
- if rasd['InstanceID'] != exp_rasd.InstanceID:
- logger.error("Got %s instead of %s", rasd['InstanceID'],
- exp_rasd.InstanceID)
+ exp_rasd = None
+ for c, r in rasds:
+ if r.Classname == rasd.classname and \
+ r.InstanceID == rasd['InstanceId']:
+ exp_rasd = r
+ break
+ if exp_rasd is None:
+ logger.error("Could not find %s, %s in rasds",
+ rasd.classname, rasd['InstanceID'])
return FAIL
status = compare_all_prop(rasd, exp_rasd)
@@ -161,10 +165,16 @@ def verify_devices(enum_list, devs):
logger.error("Got %d %s devices, expected 1", len(enum_list), dev_cn)
return FAIL
- exp_dev = devs[dev_cn]
-
- if dev['DeviceID'] != exp_dev.DeviceID:
- logger.error("Got %s instead of %s", dev['DeviceID'],
exp_dev.DeviceID)
+ exp_dev = None
+ for c,d in devs:
+ if dev_cn == d.Classname and dev['DeviceID'] == d.DeviceID:
+ exp_dev = d
+ break
+ if exp_dev is None:
+ logger.error("Did not find %s, %s in passed devs list",
+ dev_cn, dev['DeviceID'])
+ for c,d in devs:
+ logger.error("devs class=%s id=%s", c, d.DeviceID)
return FAIL
status = compare_all_prop(dev, exp_dev)
--
1.8.5.3