Forum Discussion

James_Betts_290's avatar
Dec 13, 2016
Solved

Python f5.bigip VIP issue

I wrote some sample code and was able to retrieve a VIP like this: VIP = mgmt.tm.ltm.virtuals.virtual.load(partition='Common', name='Foo')

 

When I ran the code against my production server, most of the VIPs were created with iApps so their fullPath value would be something like: /Common/myapp.iapp/Foo

 

The problem is that the code shown above won't retrieve the VIP I need. I can't figure out how using the API to supply a query string like "Common~myapp.iapp~Foo". Is there a workaround for this? I've been a C programmer so long I have the yellow Bell Labs reference but I'm pretty new to Python, any hints?

 

  • Turns out a solution existed but wasn't in the docs.

     

    There is a parameter "subPath" that can be used in queries and updates:

     

    Code: VIP = mgmt.tm.ltm.virtuals.virtual.load(partition='Common', subPath='iApp', name='myVIP')

3 Replies

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    That Python lib looks like having some catching-up to do. Meanwhile, you can try something like this:

    vservers = mgmt.tm.ltm.virtuals.get_collection()
    for vs in vservers:
        if vs.fullPath = '/Common/Foo/bar'
            ...
    
  • Turns out a solution existed but wasn't in the docs.

     

    There is a parameter "subPath" that can be used in queries and updates:

     

    Code: VIP = mgmt.tm.ltm.virtuals.virtual.load(partition='Common', subPath='iApp', name='myVIP')
    • JG's avatar
      JG
      Icon for Cumulonimbus rankCumulonimbus

      I downloaded the latest cvs version "f5-common-python-2.1.0" and yes, it seems to work with this lib. And the following command is what worked for me:

      vs_obj = mgmt.tm.ltm.virtuals.virtual.load(partition='Common', subPath='iapp_prefix.iApp', name='my_virtual_server_name')

      where "iapp_prefix" is the prefix one entered at the time of the iapp application creation, and "my_virtual_server_name' is the name of the virtual server.