Forum Discussion
KernelPanic
Nimbostratus
Nov 29, 2017F5-SDK How can I iterate a list of hosts with ManagementRoot(hostname)
When I iterate a list of hosts the ManagementRoot(hostname, username, password, token) class uses the literal and not the variable value for hostname. I only find single static IP address used in th...
KernelPanic
Nimbostratus
Nov 30, 2017with open("f5devices.txt") as file:
stuff = file.read().splitlines()
for thing in stuff:
print(thing)
b = ManagementRoot(thing, 'admin', 'admin', token=False)
print(b.tmos_version)
u = b.tm.auth.users.get_collection()
for usr in u:
print(usr.name)
delusr_lst = ["meh", "yew", "kittie"]
for delusr in delusr_lst:
if b.tm.auth.users.user.exists(name=delusr):
print(delusr + " exists on system...deleting now!")
rmusr = b.tm.auth.users.user.load(name=delusr)
rmusr.delete()
else:
print(" no user " + delusr + " on system...skipping!")
p = b.tm.auth.users.get_collection()
for usr in p:
print(usr.name)
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