cancel
Showing results for 
Search instead for 
Did you mean: 

Enable/Disable GTM pool member by java Icontrol

janarthanan
Nimbostratus
Nimbostratus

Hi,

I got java code to enable/disable LTM pool members and it is working as expected. Simplarly we want for GTM pool members as well. I tried to get pool members for particlur pool but it displayes all the pool and not able to find code for enable and disable GTM pool members. Also there is no documnet for it. please help on this . in our office we need this for automation for clinets. We are using F5 wiedly for many clients.

Below is the code for getting GTM pool members but it displays all the pool members.

public void getPoolMembers(String pool) throws Exception

  {

  System.out.println("getPoolMembers---");

    String [] pool_list = { pool };

   

    GlobalLBPoolPoolMemberDefinition[][] memberDefAofA = 

      m_interfaces.getGlobalLBPool().get_member(pool_list);

   

    GlobalLBPoolPoolMemberDefinition[] memberDefA = memberDefAofA[0];

   

    System.out.println("Pool Member for pool '" + pool + "'");

   

    for(int i=0; i<memberDefA.length; i++)

    {

      String addr = memberDefA[i].getMember().getAddress();

      long port = memberDefA[i].getMember().getPort();

      System.out.println("  " + addr + ":" + port);

    }

  }

Kindly help on this.Thanks

 

2 REPLIES 2

xuwen
Cirrostratus
Cirrostratus

i suggest you use python sdk: f5-sdk

here  is the code to find which gtm pool member is be disabled:

from f5.bigip import ManagementRoot


mgmt = ManagementRoot('192.168.5.110', 'admin', 'xt32112300')
for i in mgmt.tm.gtm.pools.a_s.get_collection():
for j in mgmt.tm.gtm.pools.a_s.a.load(name=i.name, partition='Common').members_s.get_collection():
if hasattr(j, 'disabled'):
print('type A gtm pool name {} member name {} has already been disabled and its fullpath is {}'.format(
i.name, j.name, j.fullPath))
result:

type A gtm pool name gslb_pool_ctc_v4 member name vs_ctc has already been disabled and its fullpath is /Common/DC-2-GTM-ipv4:/Common/vs_ctc

Process finished with exit code 0

here is the code to enable or disable gtm pool member:

gtm_pool_obj = mgmt.tm.gtm.pools.a_s.a.load(name='gslb_pool_ctc_v4')

mem_ctc = gtm_pool_obj.members_s.member.load(name='/Common/DC-2-GTM-ipv4:/Common/vs_ctc')
"""enable gtm pool member vs_ctc"""
mem_ctc.disabled = False
mem_ctc.enabled = True
mem_ctc.update()

mem_cuc = gtm_pool_obj.members_s.member.load(name='/Common/DC-2-GTM-ipv4:/Common/vs_cuc')
"""disable gtm pool member vs_cuc"""
mem_cuc.enabled = False
mem_cuc.disabled = True
mem_cuc.update()

 

 

Hi xuwen,

        Thanks for looking into it . I am familier with java but will try with python. Can i get code for both LTM and GTM manipulation using python.