Forum Discussion
Steve_Brown_882
Jul 01, 2009Historic F5 Account
pycontrol help
Hi Guys,
I am pretty new to python and pycontrol and need a little help with a script I am working on. I think I am missibng something obvious and this may even be more a case of me not fully u...
L4L7_53191
Nimbostratus
Jul 02, 2009Good post, thanks for sharing. Here's another method: it looks like you're calling the iControl portal for each virtual server name separately. iControl and Python's zip() function can save you (and the BigIP!) some time and CPU cycles:
In [16]: vlist = b.LocalLB_VirtualServer.get_list()['return']
In [18]: vdest = b.LocalLB_VirtualServer.get_destination(virtual_servers = vlist)['return']
In [19]: combined = zip(vlist, vdest)
In [20]: for x in combined:
....: print "%s=>%s:%d" % (x[0], x[1]['address'], x[1]['port'])
Produces output like: virtual_forward_test=>192.168.1.0:0
The key bit here is that you can pass in the entire list of VS names to get_destination, and iControl will do the Right Thing and return the ip/port combos back in order. Then you "zip" them together, which will create a tuple by default - you then just iterate through it as if it were a list...
I hope this helps!
-Matt
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
