+def get_redirserv_inst(virt, ip, host_inst):
+ redirserv_inst = None
+
+ try:
+ redirserv_cn = get_typed_class(virt, 'ConsoleRedirectionService')
+
+ enum_list = EnumInstances(ip, redirserv_cn)
+
+ for redirserv in enum_list:
+ if redirserv.SystemName == host_inst.Name:
+ if redirserv_inst is not None:
+ raise Exception("More than one RedirectionService found "
+
+ "for the same host/virt")
+ redirserv_inst = redirserv
No need for this loop. Only one instance of ConsoleRedirectionService
should be returned.
+
+ except Exception, details:
+ logger.error(details)
+ return redirserv_inst, FAIL
+
+ return redirserv_inst, PASS
+
+def verify_kvmrsap(enum_list, list_kvmrsap):
+ status = PASS
+
+ for item in enum_list:
+ found = FAIL
+ for kvmrsap in list_kvmrsap:
+ found = compare_all_prop(item, kvmrsap)
+ if found == PASS:
+ break
Compare the values of the Name and SystemName keys. If they match, then
call compare.
+
+ if found == FAIL:
+ logger.error("Instance found in kvmrsap list but not in " +
+ "association list")
+ return FAIL
+
+ return status
+
+@do_main(sup_types)
+def main():
+ options = main.options
+ server = options.ip
+ virt = options.virt
+
+ status = FAIL
+
+ # This check is required for libvirt-cim providers which do not have
+ # ServiceAccessBySAP changes in it and the ServiceAccessBySAP
+ # association is available with revision >= 784.
+ curr_cim_rev, changeset = get_provider_version(virt, server)
+ if curr_cim_rev < libvirtcim_servaccsap_changes:
+ logger.info("'%s' provider not supported, hence skipping the tc
....",
+ classname)
+ return SKIP
classname is not defined.
+
+ status, cxml = setup_env(options.ip, options.virt)
+ if status != PASS:
+ cxml.undefine(options.ip)
+ return status
+
+ try:
+ status, host_inst = get_host_info(options.ip,
+ options.virt)
+ if status != PASS:
+ raise Exception("Unable to get host info")
ServiceAccessBySAP does not associate the HostSystem - no need for this
call.
+
+ redirserv_inst, status = get_redirserv_inst(options.virt,
+ options.ip,
+ host_inst)
+ if status != PASS:
+ raise Exception("Unable to get RedirectionService instance")
+
+ list_kvmrsap, status = list_kvmrsap_inst(options.virt,
+ options.ip)
+
+ if status != PASS:
+ raise Exception("Unable to get kvmrsap instance")
+ if list_kvmrsap is None:
+ raise Exception("No kvmrsap instance returned")
+
+ an = get_typed_class(options.virt, 'ServiceAccessBySAP')
+
+ host_ccn = host_inst.CreationClassName
+ redirserv_ccn = redirserv_inst.CreationClassName
+ redirserv_name = redirserv_inst.Name
+
+ assoc_info = AssociatorNames(options.ip, an, redirserv_ccn,
+ CreationClassName = redirserv_ccn,
+ Name = redirserv_name,
+ SystemCreationClassName = host_ccn,
+ SystemName = host_inst.Name)
Do not use the host values as the keys. Use the keys of the redirserv_inst.
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin(a)linux.vnet.ibm.com