+def setup_env(server, virt):
+ if virt == 'Xen':
+ test_disk = 'xvda'
+ else:
+ test_disk = 'hda'
+ virt_xml = get_class(virt)
+ if virt == 'LXC':
+ cxml = virt_xml(test_dom)
+ else:
+ cxml = virt_xml(test_dom, disk = test_disk)
Move the 4 lines above out from underneath the else.
+def get_kvmrsap_inst(virt, ip, guest_name):
This is what threw me off in the last review. You're trying to verify
the result of the output of HostSystem -> KVMRedirectionSAP.
As you noted in your mail, this will return all the KVMRedirectionSAP
instances present on the host.
Because of this, you want to verify that the AssociatorNames() call
returns the same list that the EnumInstances() of KVMRedirectionSAP returns.
+ kvmrsap_inst = None
+
+ try:
+ kvmrsap_cn = get_typed_class(virt, 'KVMRedirectionSAP')
+ enum_list = EnumInstances(ip, kvmrsap_cn)
+
+ for kvmrsap in enum_list:
+ if kvmrsap.SystemName == guest_name:
+ if kvmrsap_inst is not None:
+ print "More than one KVMRedirectionSAP found \
+ the same guest"
Replace print with logger.error()
+ return kvmrsap_inst, FAIL
+ kvmrsap_inst = kvmrsap
So here, you want to do 2 things:
1) Verify that one of the instances in enum_list corresponds to the
guest we defined in the test. If there is no corresponding instance,
return an error.
2) Return the whole list, not just the instance corresponding to the guest.
+
+ except Exception, details:
+ logger.error(details)
+ return kvmrsap_inst, FAIL
+
+ return kvmrsap_inst, PASS
+
+def verify_kvmrsap(enum_list, kvmrsap_inst):
+ status = FAIL
+
+ for item in enum_list:
+ if item.classname != kvmrsap_inst.Classname
+ print "Wrong returned class name (%s)", item.classname
No need to verify the classname - all the instances will have the same
classname.
+ return status
+
+ if compare_all_prop(item, kvmrsap_inst) == PASS:
Since you don't know how many guests are running on the system, you want
to verify that HostSystem -> KVMRedirectionSAP returns the same number
of instances that the enum of KVMRedirectionSAP returns.
You can also verify the individual instances - to do that, you'll need
to loop through the list returned by HostSystem -> KVMRedirectionSAP,
then loop through the list returned by KVMRedirectionSAP to find a match.
Sorry for the confusion - originally, I thought you were just trying to
compare a single instance - but really, you want to verify the list
returned by EnumInstances() of KVMRedirectionSAP is identical to the
list returned by HostSystem -> KVMRedirectionSAP.
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin(a)linux.vnet.ibm.com