cancel
Showing results for 
Search instead for 
Did you mean: 

get virtual list based on vip/destination filter [request params]?

Akash9920
Nimbostratus
Nimbostratus

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:

 

1) https://devcentral.f5.com/s/articles/getting-started-with-the-python-sdk-part-4-working-with-request...

2) https://devcentral.f5.com/s/articles/demystifying-icontrol-rest-part-3-how-to-pass-query-parameters-...

3)

1 REPLY 1

PeteWhite
F5 Employee
F5 Employee

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