Forum Discussion
Sinan
Feb 25, 2020Ret. Employee
f5 sdk can't load pool objects after create pool.
Hi experts: I can't load a pool object after I created it. from f5.bigip import ManagementRoot
from f5.bigip.contexts import TransactionContextManager
if __name__ == "__main__":
for x in ...
consul_2019
Cirrus
Feb 25, 2020You'll need to put the indentations back in...
Sinan
Feb 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.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects