- try:
- names = conn.AssociatorNames(instanceref, AssocClass =
get_typed_class(options.virt, "HostedService"))
- rc = 0
- except pywbem.CIMError, (rc, desc):
- if rc == exp_rc and desc.find(exp_desc) >= 0:
- logger.info("Got excepted rc code and error string")
- status = PASS
- else:
- logger.error("Unexpected rc code %s and description %s\n" %(rc,
desc))
- except Exception, details:
- logger.error("Unknown exception happened")
- logger.error(details)
+ hostedservice = get_typed_class(options.virt, "HostedService")
+ for i in range(0, len(instanceref)):
If you use a for loop, it's better to use:
for inst in instanceref:
+ try:
+ names = conn.AssociatorNames(instanceref[i], AssocClass = hostedservice)
+ rc = 0
+ except pywbem.CIMError, (rc, desc):
+ if rc == exp_rc and desc.find(exp_desc[i]) >= 0:
Using exp_desc[i] isn't very clear. It's not obvious which exception
corresponds to which reference. I'd use a list or some other way to
make it obvious which exception you're expecting in a given case.
+ logger.info("Got excepted rc code and error
string")
+ status = PASS
+ else:
+ logger.error("Unexpected rc code %s and description %s\n"
%(rc, desc))
+ except Exception, details:
+ logger.error("Unknown exception happened")
+ logger.error(details)
- if rc == 0:
- logger.error("HostedService associator should NOT return excepted result
with a wrong key name and value of HostSystem input")
- status = FAIL
+ if rc == 0:
+ logger.error("HostedService associator should NOT return excepted
result\
+ with a wrong key name and value of HostSystem input")
This is an existing typo, but can you change "HostedService associator
should NOT return excepted result" to "HostedService associator should
NOT return expected result"
And its better to fix this in the following manner:
logger.error("HostedService associator should NOT return excepted result"
"with a wrong key name and value of HostSystem input")
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin(a)linux.vnet.ibm.com