[Libvirt-cim] [PATCH 3 of 3] [TEST] Fix potiential false positive in ESD 01

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Tue Jul 15 15:53:53 UTC 2008


>> +def get_inst(ip, virt, cn, key):
>> +    inst = None +
>>      try:
>> -        ret_inst = assoc.AssociatorNames(host,esd_cn, class_name, virt,
>> -                                         InstanceID = id)
>> +        key_list = {"InstanceID" : key }
>> +
>> +        inst = getInstance(ip, cn, key_list, virt)
>> +
>> +    except Exception, details:
>> +        logger.error("Exception %s" % details)
>> +        return None +
>> +    if inst is None:
>> +        logger.error("Expected at least one %s instance" % cn)
>> +        return None +
>> +    return inst +
>>   
> The above function can be moved to a library . We can probably pass the 
> key_list to get_inst() fn.

I think I'll leave this as is.  Having a getInstance() function, and 
then another, similar, get_inst() function is confusing.

The only thing this function adds is trapping of the exception and some 
additional error checking.  It's not much extra work to have the test 
case trap the exception and test for error conditions.

It's possible that the calling function will want to trap the exception 
differently or return a different error message.

-- 
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list