
-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. I agree that the loop is little hard to read, but considering the fact
Kaitlin Rupert wrote: that this is a Cross class test case where we would like to be able to make use of the output from the previous provider as input for the next step as much as possible, do you think that manually generating a list of our own will serve the purpose ? If yes, then the Crosss Class tc will no longer require query from the *HostedResourcePool, *correct?? Also, the above *if condition*s checks along with the following check after the *pool_init_list()* is called in the *main loop *make sure that we have *4* *required resourcepool *as inputs for *EAFP *query. in_pllist = pool_init_list(virt, pool, net_name, dpool_name) # One pool for each Device type, hence len should be 4 exp_len = 4 status = check_len(an, in_pllist, qcn, exp_len) if status != PASS: vsxml.undefine(server) cleanup_restore(server, virt=virt) destroy_netpool(server, virt, net_name) return FAIL Apart from this, the above *pool_init_list() *function can be made more readable as follows: def pool_init_list(virt, pool_assoc, net_name, dp_InstID): """ Creating the lists that will be used for comparisons. """ in_pllist = {} dp_CName = get_typed_class(virt, 'DiskPool') pp_CName = get_typed_class(virt, 'ProcessorPool') mp_CName = get_typed_class(virt, 'MemoryPool') np_CName = get_typed_class(virt, 'NetworkPool') np_InstID = '%s/%s' % ('NetworkPool', net_name) for p_inst in pool_assoc: CName = p_inst.classname InstID = p_inst['InstanceID'] if CName == np_CName and InstID == np_InstID: in_pllist[CName] = InstID elif CName == dp_CName and InstID == dp_InstID: in_pllist[CName] = InstID elif CName == pp_CName or CName == mp_CName: in_pllist[CName] = InstID return in_pllist Inputs are welcome as always :). Thanks and Regards, Deepti.