[Libvirt-cim] [PATCH] [TEST] Updating 01_forward.py of SDC to support XenFV, KVM
Kaitlin Rupert
kaitlin at linux.vnet.ibm.com
Tue May 6 22:46:23 UTC 2008
> -def get_or_bail(ip, id, pool_class):
> +def get_or_bail(virt, ip, id, pool_class):
> """
> Getinstance for the CLass and return instance on success, otherwise
> exit after cleanup_restore .
> """
> key_list = { 'InstanceID' : id }
> -
> + status = PASS
This function doesn't return the status, so no need to add this here.
> try:
> - instance = enumclass.getInstance(ip, pool_class, key_list)
> + instance = enumclass.getInstance(ip, pool_class, key_list, virt)
> except Exception, detail:
> - Globals.logger.error(Globals.CIM_ERROR_GETINSTANCE, '%s' % pool_class)
> - Globals.logger.error("Exception: %s", detail)
> - clean_up_restore()
> + logger.error(CIM_ERROR_GETINSTANCE, '%s' % pool_class)
> + logger.error("Exception: %s", detail)
> + cleanup_restore()
> status = FAIL
Can you remove this as well? Thanks!
> sys.exit(status)
> return instance
>
> +def verify_rasd_fields(loop, assoc_info, cllist, rtype, rangelist):
> + for inst in assoc_info:
> + if inst.classname != cllist[loop]:
> + print_field_error("Classname", inst.classname, cllist[loop])
> + return FAIL
> + if inst['ResourceType'] != rtype[cllist[loop]]:
> + print_field_error("ResourceType", inst['ResourceType'],
> + rtype[cllist[loop]])
Can this be indented like the following:
print_field_error("ResourceType", inst['ResourceType'],
rtype[cllist[loop]])
> + disk_cn = eval("enumclass." + get_typed_class(options.virt,
> + "DiskPool"))
> + disk = get_or_bail(virt, server, id=diskid, pool_class=disk_cn)
> + mem_cn = eval("enumclass." + get_typed_class(options.virt,
> + "MemoryPool"))
This is a little awkward here. Can you instead doing something like:
disk_cn = get_typed_class(options.virt, "DiskPool")
disk_ref = eval("enumclass." + disk_cn)
Also, the variable names are misleading - eval("enumclass." +
get_typed_class(options.virt, "DiskPool")) returns a DiskPool reference,
which we pass to GetInstance in the get_or_bail() call.
> netid = "%s/%s" % ("NetworkPool", test_network)
> - net = get_or_bail(server, id = netid, \
> - pool_class=enumclass.Xen_NetworkPool)
> - proc = get_or_bail(server, id = procid, \
> - pool_class=enumclass.Xen_ProcessorPool)
> + net_cn = eval("enumclass." + get_typed_class(options.virt,
> + "NetworkPool"))
> + net = get_or_bail(virt, server, id = netid, pool_class=net_cn)
> + proc_cn = eval("enumclass." + get_typed_class(options.virt,
> + "ProcessorPool"))
Same thing here too.
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com
More information about the Libvirt-cim
mailing list