Forum Discussion

Thiyagu's avatar
Thiyagu
Icon for Cirrus rankCirrus
May 16, 2021

F5 SDK help to delete a provided node on the LTM

Hello All,

I'm in need of F5 SDK help to delete a provided node on the LTM. I have prepared the below scripts and for some reason the sequence is not wrong.

 

Could you please suggest?

 

from f5.bigip import ManagementRoot

 

# Connect to the BigIP and configure the basic objects

mgmt = ManagementRoot("x.x.x.x", "x.x.x.x", "x.x.x.x")

 

#Enter the member name to delete

member1 = input("Enter the host_name to delete ")

 

#Get a collection of all members and load it

all_members = mgmt.tm.ltm.pool.members_s.get_collection()

member_delete = mgmt.ltm.pool.members_s.load(name='member1', partition='Common')

 

# Find for a given node and Delete a node if it exists

if mgmt.ltm.pool.members_s.exists(name='member1', partition='Common'):

   member_delete.delete()

 

Regards,

Thiyagu

  • Hello Thiyagu.

    This works for me:

    from f5.bigip import ManagementRoot
     
    # ----------------------------------------------------------
     
    session = ManagementRoot("F5_mgmt_IP","username","password",token=True)
    pools = session.tm.ltm.pools.get_collection()
    for pool in pools:
        for member in pool.members_s.get_collection():
            if member.name.startswith('mynode'):
                member.delete()

    Regards,

    Dario.