09-Nov-2020 12:56
Hi folks and python developers, I am looking for a solution to a question. Currently I am using python sdk to get the list of the virtuals with filter option as partition and destination/vip? I have tried following things and unable to achieve that:
virtuals = mgmt.tm.ltm.virtuals.get_collection(requests_params={
'params': 'expandSubcollections=true&$filter=partition+eq+partition&$destination+eq+vip')}
What I am trying to do is for a given device , partition, vip I want to get the list of the virtuals. s there a way to wild card for destination?
articles i referred are:
3)
18-Nov-2020 04:40
I'm confused why your filter ends with $destination+eq+vip
Take a look at https://www.odata.org/documentation/odata-version-2-0/uri-conventions/#FilterSystemQueryOption for the odata syntax
Your string handling is also not correct
My thinking is that from a Python perspective you want:
partition = "myPartition"
destination="1.2.3.4:443"
virtuals = mgmt.tm.ltm.virtuals.get_collection(requests_params={ 'params': 'expandSubcollections=true&$filter=partition+eq+' + partition + 'and+destination+eq+' + vip)}
A good way to test this is to create the filter string and then insert it into the command, so you can print it out first
eg
partition = "myPartition"
destination="1.2.3.4:443"
filterString = 'expandSubcollections=true&$filter=partition+eq+' + partition + 'and+destination+eq+' + vip
print("filterString:" + filterString)
virtuals = mgmt.tm.ltm.virtuals.get_collection(requests_params={ 'params': filterString)}
You can also use my iCR python module for a simple script