Forum Discussion
SK391_339749
Nimbostratus
May 25, 2018List commands to grab VIPs and Pool members
I would like to know how to do the foolowing please.
We have a 4 main nodes with out pools & are looking to retire 2 of them.
I wanted to know if there was a list command to so the number...
Jason_Nance
Nimbostratus
May 25, 2018If you're up for some Python you can use this:
!/usr/bin/env python3
from f5.bigip import ManagementRoot
mgmt = ManagementRoot('hostname', 'username', 'password')
CSV header
print('Partition, VS Name, Pool Name, Pool Members')
for virtual in mgmt.tm.ltm.virtuals.get_collection():
Does the virtual server have a pool assigned?
if not getattr(virtual, 'pool', None):
No - print virtual server name and move on
print('{},{},,'.format(virtual.partition, virtual.name))
continue
Pool partition
pool_part = virtual.pool.split('/')[1]
Pool name
pool_name = virtual.pool.split('/')[2]
pool = mgmt.tm.ltm.pools.pool.load(
partition=pool_part,
name=pool_name,
)
members = pool.members_s.get_collection()
Loop to output the results however you'd like
Example is CSV with pool members delimited by semicolon
Gather members in list - makes printing easier
pool_members = []
for member in members:
pool_members.append(member.name)
Print result
print('{},{},{},{}'.format(
virtual.partition,
virtual.name,
pool.name,
';'.join(pool_members),
))
That will give you more options for formatting. The example above spits out a CSV.
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