Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get all servers in a GTM pool (Python f5-sdk)

A_J_
Altostratus
Altostratus

I am sure this is quite simple but I can't find reference to this in documentation.

pool = mgmt.tm.gtm.pools.a_s.a.load(name='poolname')

Once i've loaded it, how can I see what servers are in this pool and get their name(s)? I would also like to do the same with wideips, gather all pools in each one to see if a particular pool is being used by it. (Version 12)

2 REPLIES 2

xuwen
MVP
MVP

this code for type A and partition is Common:

from f5.bigip import ManagementRoot

 

mgmt = ManagementRoot('192.168.5.109', 'admin', 'xt32112300')

 

for i in mgmt.tm.gtm.wideips.a_s.get_collection():

try:

type_A_wideip = mgmt.tm.gtm.wideips.a_s.a.load(name=i.name)

except Exception as e:

print('type A widip name {} error msg is '.format(i.name) + str(e))

else:

if hasattr(type_A_wideip, 'pools'):

for pool_name in type_A_wideip.pools:

gslb_A_pool = mgmt.tm.gtm.pools.a_s.a.load(name=pool_name['name'])

gslb_pool_members_vs_name_list = [str(mem.name) for mem in gslb_A_pool.members_s.get_collection()]

print('type A wideip name: {} use gslb pool name is: {}; gslb_pool_members_vs_name_list: {}'.format(i.name, pool_name['name'], gslb_pool_members_vs_name_list))

 

 

code running result:

type A wideip name: www.bank.com use gslb pool name is: gslb_pool; gslb_pool_members_vs_name_list: ['dc1-vs', 'dc2-vs']

type A wideip name: www.gslb.xuwen.com use gslb pool name is: gslb_pool; gslb_pool_members_vs_name_list: ['dc1-vs', 'dc2-vs']

 

Process finished with exit code 0

This is great! Very helpful. I can use this as a reference. I want to take a VS, find what pools it is in, then what wideip has that pool.