
-def pool_init_list(pool_assoc): +def pool_init_list(virt, pool_assoc, net_name, dpool_name): """ Creating the lists that will be used for comparisons. """ in_pllist = {} + npool = get_typed_class(virt, 'NetworkPool') + dpool = get_typed_class(virt, 'DiskPool') + ppool = get_typed_class(virt, 'ProcessorPool') + mpool = get_typed_class(virt, 'MemoryPool') + n_instid = '%s/%s' % ('NetworkPool', net_name) + for i in range(len(pool_assoc)): classname_keyvalue = pool_assoc[i].classname instid = pool_assoc[i]['InstanceID'] - in_pllist[classname_keyvalue] = instid + if classname_keyvalue == npool and instid == n_instid: + in_pllist[classname_keyvalue] = instid + elif classname_keyvalue == dpool and instid == dpool_name: + in_pllist[classname_keyvalue] = instid + elif classname_keyvalue == ppool or classname_keyvalue == mpool: + in_pllist[classname_keyvalue] = instid return in_pllist
This loop is a little hard to read. I think this loop can be removed. Instead, just build a list with the values you're expecting. in_pllist = { npool, '%s/%s' % ('NetworkPool', net_name), ... } I know this was already existing code, but if pool_assoc doesn't contain the instances you're expecting, then in_pllist won't contain the proper values to query against ElementAllocatedFromPool. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com