> +
> + if rasd['EmulatedType'] == VIRT_DISK_TYPE_FLOPPY and \
> + rasd['InstanceID'].find("Default") >= 0:
>
You could use "Default" in rasd['InstanceID']. That looks much simpler
to understand.
Agreed - this is a much cleaner approach.
> +
> + rasd['Address'] = addr
> + rasd_list[rasd.classname] = inst_to_mof(rasd)
> +
> + return rasd_list +
> +def verify_floppy_disk(ip, virt, addr, guest_name):
> + inst = None
> +
> + try:
> + drasd_cn = get_typed_class(virt,
> 'DiskResourceAllocationSettingData')
> + enum_list = EnumInstances(ip, drasd_cn)
> +
> + if enum_list < 1:
> + raise Exception("No %s instances returned" % drasd_cn)
> +
> + for rasd in enum_list:
> + guest, dev, status = parse_instance_id(rasd.InstanceID)
> + if status != PASS:
> + raise Exception("Unable to parse InstanceID: %s" % \
> + rasd.InstanceID)
> +
> + if guest == guest_name:
> + inst = rasd + break
> +
> + if inst is None:
> + raise Exception("%s instance for %s not found" %
> (drasd_cn, + guest_name))
> +
> + if inst.Address != addr:
> + raise Exception("%s instance for %s not found" %
> (drasd_cn, + guest_name))
>
You can combine both the if statements into one as the log message
remains same.
Or if you want you can make the log messages specific to the error type.
Good call. Thanks for catching these errors! Sending a new version soon.
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin(a)linux.vnet.ibm.com