
+def get_redirserv_inst(virt, ip, host_inst): + redirserv_inst = None + status = PASS + + 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 redirection service found " + + "for the same host/virt") + redirserv_inst = redirserv
There should only be one instance of ConsoleRedirectionService on a system. No need for this loop.
+ + except Exception, details: + logger.error(details) + status = FAIL + + return redirserv_inst, status + +def verify_redirserv(enum_list, redirserv_inst): + status = PASS + + try: + if len(enum_list) > 1: + raise Exception("Association returned more than one redirection " + + "service instance") + if len(enum_list) < 1: + raise Exception("Association didn't return any redirection " + + "service instance") + + item = enum_list[0] + + if compare_all_prop(item, redirserv_inst) == FAIL: + raise Exception("Redirection service returned by association is " + + "not equal redirection service instance returned " + + "by enumeration") + except Exception, details: + logger.error(details) + status = 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)
ServiceAccessBySAP does not associate HostSystem - this call is not needed.
+ if status != PASS: + raise Exception("Unable to get host info") + + redirserv_inst, status = get_redirserv_inst(options.virt, + options.ip, + host_inst) + if status != PASS: + raise Exception("Unable to get redirection service instance") + if redirserv_inst == None: + raise Exception("No redirection service instance returned")
Move this check into the get_redirserv_inst() call.
+ + kvmrsap_inst, status = get_kvmrsap_inst(options.virt, + options.ip, + test_dom) + if status != PASS: + raise Exception("Unable to get kvmrsap instance") + if kvmrsap_inst is None: + raise Exception("No kvmrsap instance returned")
Move this check to the get_kvmrsap_inst() call.
+ + an = get_typed_class(options.virt, 'ServiceAccessBySAP') + + sys_ccn = kvmrsap_inst.SystemCreationClassName + kvmrsap_ccn = kvmrsap_inst.CreationClassName + kvmrsap_name = kvmrsap_inst.Name + + assoc_info = AssociatorNames(options.ip, an, kvmrsap_ccn, + CreationClassName = kvmrsap_ccn, + Name = kvmrsap_name, + SystemCreationClassName = sys_ccn, + SystemName = test_dom)
Instead of using test_dom, use the SystemName key value of kvmrsap_inst. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com