f5-common-python
f5-common-python copied to clipboard
Provide a similar function as expandSubcollections when calling get_collection()
Provide a similar function as expandSubcollections=true
from the REST api when calling get_collection()
. When you have hundreds of pools across a couple of vCMP guests, you get an enormous scaling issue.
The below code would make 101 API calls if there were 100 pools
from f5.bigip import ManagementRoot
mgmt = ManagementRoot('10.10.10.10', 'admin', 'admin')
pools = mgmt.tm.ltm.pools.get_collection()
for pool in pools:
print(pool.name)
for member in pool.members_s.get_collection():
print(member.name)
While code like this, would one do 2 calls if it queried for all pool members at once.
from f5.bigip import ManagementRoot
mgmt = ManagementRoot('10.10.10.10', 'admin', 'admin')
pools = mgmt.tm.ltm.pools.get_collection(expand_subcollections=True)
for pool in pools:
print(pool.name)
for member in pool.members:
print(member.name)
You can currently hack your way around it but it defeats all use for the sdk.
from f5.bigip import ManagementRoot
mgmt = ManagementRoot('10.10.10.10', 'admin', 'admin')
pools = mgmt.tm.ltm.pools.get_collection(requests_params={'params': {'expandSubcollections':'true'}})
for pool in pools:
print(pool.name)
for member in pool.membersReference['items']:
print(member['name'])
@jobec, thats not a hack, thats the way to send different params to a subcollection. Its the same method one would use to send odata filters.
The way I'm interpreting the issue here is
- Make the expand subcollection boolean less verbose
- Make the expanded subcollections available in object form
Does that sound correct?
Yes, that's correct.
@wojtek0806 I don't think the first bullet there is an unreasonable ask. I've experienced the same frustration in the past and if it's a common usage, which I believe it is, then it should have a way to get to it without hassle.
Also I think the expandSubcollections in BIG-IQ and iWorkflow are called something completely different (i think its just expand=true
). Having this param act as an abstraction would allow us to make the user experience consistent.
The second ask about the objection creation, could get a little hairy. I'm not sure what would be required to do that. Although I haven't taken a gander at that part of the code in some time.
@caphrim007 I will try to look into this next week, as the first ask is not a problem like you said, the second might be near impossible, given the way we instantiate sub-collections, but let me have a look, might turn out otherwise and be very simple :)