Forum Discussion
consul_2019
Feb 25, 2020Cirrus
You'll need to put the indentations back in...
- SinanFeb 25, 2020Ret. Employee
from f5.bigip import ManagementRoot from f5.bigip.contexts import TransactionContextManager import threading import time def create_pool(name): print time.ctime() + "create pool name: %s" % name tx = mgmt.tm.transactions.transaction with TransactionContextManager(tx) as api: api.tm.ltm.pools.pool.create(name=name) def delete_pool(name): print time.ctime() + "delete pool name: %s" % name tx = mgmt.tm.transactions.transaction with TransactionContextManager(tx) as api: p = api.tm.ltm.pools.pool.load(name=name) p.delete() def save_config(): print time.ctime() + "save sys config" tx = mgmt.tm.transactions.transaction with TransactionContextManager(tx) as api: api.tm.util.bash.exec_cmd( command='run', utilCmdArgs="-c 'tmsh save sys config'" ) if __name__ == "__main__": for x in range(1, 50): mgmt = ManagementRoot('10.5.10.23', 'admin', 'XXXXX', token=True) name = 'pool' + str(x) # x = threading.Thread(target=create_pool, args=(name,)) # x.start() # # time.sleep(1) # x = threading.Thread(target=delete_pool, args=(name,)) # x.start() # time.sleep(1) # x = threading.Thread(target=save_config) # x.start() # time.sleep(1) create_pool(name) delete_pool(name) save_config()
Tested this code, it works.