Need help with f5 SDK for a program to identify the node for the provided IP address and subsequently removing the config
Hello All,
I'm working on a F5 SDK python script to to identify the node for the provided IP address and subsequently removing the node from the member and removing the node from the load balancer configuration.
I have tried the below script and it works as expected till to identify the pool member however it is not working to delete the pool member and host.
Could you please help to fix the issue?
from f5.bigip import ManagementRoot
import pprint
import argparse
# Define unique variables
user = 'admin'
password = 'x.x.x..x'
f5_ip = '10.10.10.10'
partition = 'LAB-QA'
# Connect to the F5
mgmt = ManagementRoot(f5_ip, user, password)
ltm = mgmt.tm.ltm
###################
## Gain information
###################
# What nodes are on this F5?
nodes = ltm.nodes.get_collection()
# What pools are on this F5?
pools = ltm.pools.get_collection()
###################
## Checks
###################
# Does a node exist on the F5?
my_node = 'HOST_LAB_QA'
test = ltm.nodes.node.exists(partition=partition, name=my_node)
print("Is {} on the F5? {}".format(my_node, test))
# Is my node in a pool?
for pool in ltm.pools.get_collection():
# Take note of how this call works
for member in pool.members_s.get_collection():
if my_node in member.name:
print("{} is in the pool {}".format(my_node, pool.name))
pool_memeber = mgmt.tm.ltm.pools.member.name
# Delete if a pool-member exists for the node to remove
pool_memeber.delete()