[Libvirt-cim] [PATCH] [TEST]#3 Add new test to verify enum of DiskRASD to have EmulatedType=0 for Disk and EmulatedType=1 for CDROM

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Tue Dec 23 18:56:11 UTC 2008


>> +        try:
>> +            drasd_list = enumclass.EnumInstances(options.ip, drasd, 
>> ret_cim_inst=True)
>> +            if len(drasd_list) < 1:
>>   
> you can check for len(drasd_list) == 1 instead as we should get only one 
> record.

I disagree.  If there are other guests defined on the system, 
EnumInstances() of DiskRASD may return more than one instance.

>> +                logger.error("%s returned %i instances, excepted at 
>> least 1.",
>> +                             drasd, len(drasd_list))
>> +                return FAIL
>>   
> The return statement leaves the guest defined on the machine.
> Call cxml.undefine() before returning.
>> +        except Exception, detail:
>> +            logger.error(CIM_ERROR_ENUMERATE, drasd)
>> +            logger.error("Exception: %s", detail)
>> +            return FAIL
>> +
>> +        for rasd in drasd_list:
>>   
> Do we really require the for loop, since we are sure that we will get 
> only one DiskRASD, why not compare the rasd[0]['EmulatedType'] == 
> exp_emu_type ??

Yes, the loop here is required.  If multiple DiskRASDs are returned, we 
need to filter the list to find the DiskRASD that corresponds with our 
guest.

>> +            guest, dev, status = parse_instance_id(rasd['InstanceID'])
>> +            if status != PASS:
>> +               logger.error("Unable to parse InstanceID: %s" % 
>> rasd['InstanceID'])
>> +               return FAIL
>> +            if guest == default_dom:
>> +                if rasd['EmulatedType'] == exp_emu_type:
>> +                    status = PASS
>> +                    break                 +                else:
>> +                    logger.error("EmulatedType Mismatch: got %d, 
>> expected %d",\
>> +                                 rasd['EmulatedType'], exp_emu_type)
>> +                    return FAIL
>> +            elif rasd == drasd_list[len(drasd_list)-1]:
>> +                logger.error("The defined guest can not be found")
>> +                return FAIL
>>   
> I did not get how the above check rasd == drasd_list[len(drasd_list)-1] 
> is useful in the tc ?
> Once the verification of the guest for a particular emu_type is 
> successful we need to call cxml.undefine() before verifying for the next 
> emu_type.

This is bit of code is attempting to make sure that a DiskRASD for the 
guest was actually returned.  I think this can be done in an easier 
way..  See my review for info on that.

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




More information about the Libvirt-cim mailing list