KernelPanic
Nov 29, 2017Nimbostratus
F5-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 the hostname parameter SDK examples here. It is easily done with curl.
Would someone show me how this is done in the F5 SDK?
f5adminloop.py
import requests
from f5.bigip import ManagementRoot
requests.packages.urllib3.disable_warnings() ignore cert warnings
c = ManagementRoot('10.2.92.140',"admin","admin",token=True)
print(c.tmos_version)
f5List = ['10.2.192.140', '10.222.224.72', '10.222.123.32', '10.222.123.33']
for f5 in f5List:
f5 = "'" + f5 + "'"
b = 'ManagementRoot(%s,"admin","admin",token=True)' % (f5)
print(b)
print(b.tmos_version)
[root@flks-centos7-01 scripts] python f5adminloop.py
/usr/lib/python2.7/site-packages/urllib3/connectionpool.py:769: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
InsecureRequestWarning)
12.1.2
ManagementRoot('10.2.192.140',"admin","admin",token=True)
Traceback (most recent call last):
File "f5adminloop.py", line 17, in
print(b.tmos_version)
AttributeError: 'str' object has no attribute 'tmos_version'