python f5-sdk - Reverse Lookup (Pool -> Virtual Server)

Problem this snippet solves:

This python f5-sdk script prints the list of pools using a specific pool.

How to use this snippet: <hostname> <username> <poolname>

Script will prompt for password.
This will only search the Common partition. This also does not check for policies or iRules that may change the value of pool.

Code :

#!/usr/bin/env python

__author__ = 'buzzsurfr'
__version__ = '0.2'

#  Standard Library
import sys
import re

#  Related Third-Party
import getpass

#  Local Application/Library Specific
from f5.bigip import ManagementRoot

if len(sys.argv) < 4:
print "\n\n\tUsage: %s host user pool" % sys.argv[0]

#  Get login password from CLI
userpass = getpass.getpass()

#  Connect to BIG-IP
mgmt = ManagementRoot(sys.argv[1], sys.argv[2], userpass)

#  Pool to search for
pool = sys.argv[3]
if len(pool) < 8 or pool[:8] != '/Common/':
pool = '/Common/'+pool
print "Virtual Servers using Pool "+pool

#  Get list of virtual servers
virtual_servers =

#  Iterate through pool member list (has a list of members per pool referenced) looking for node
for vs in virtual_servers:
if pool == vs.pool:
print "\t"

Tested this on version:

Updated Jun 06, 2023
Version 2.0

Was this article helpful?

No CommentsBe the first to comment