How To's - Interact with F5 BigIP using Python
Hi there, this will be a short and basic script on how to interact with F5 using python (v3).
from f5.bigip import ManagementRoot
mgmt = ManagementRoot("192.168.12.3", "admin", "superpassword")
ltm = mgmt.tm.ltm
# Get a list of all virtual servers
print(f'{" Virtual servers ":=^50}')
virtuals = ltm.virtuals.get_collection()
for virtual in virtuals:
print(f"{virtual.name}")
for vs in virtuals:
print(" ->" , f"{vs.pool}")
# Get a list of all pools
print(f'{" Pool ":=^50}')
pools = ltm.pools.get_collection()
for pool in pools:
print(pool.name)
for member in pool.members_s.get_collection():
print(" ->" , member.name)
# Get a list of all nodes
print(f'{" Nodes ":=^50}')
nodes = ltm.nodes.get_collection()
for node in nodes:
print(f"{node.name}" " has a an IP of " f"{node.address}")
Result
And that’s it.
I hope you enjoyed this post, leave your comments below and I'll see you on the next one.
Great job. May be you could add a function to see what certifications Https VIP has