F5 SDK usage with ASM
Where can I get sample code for using ASM with F5 SDK I ran the following code.
from import BigIP import requests from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
mgmt = BigIP("192.168.199.241", "admin", "admin")
Get a list of all pools on the BigIP and print their names and their
members' names
pools = mgmt.tm.ltm.pools.get_collection() for pool in pools: print pool.name for member in pool.members_s.get_collection(): print member.name
Create a new pool on the BIG-IP
mypool = mgmt.tm.ltm.pools.pool.create(name='mypool', partition='Common')
Load an existing pool and update its description
pool_a = mgmt.tm.ltm.pools.pool.load(name='mypool', partition='Common') pool_a.description = "New description" pool_a.update()
Delete a pool if it exists
if mgmt.tm.ltm.pools.pool.exists(name='mypool', partition='Common'): pool_b = mgmt.tm.ltm.pools.pool.load(name='mypool', partition='Common') pool_b.delete()
I got the following result.
Traceback (most recent call last): File "test.py", line 10, in pools = mgmt.tm.ltm.pools.get_collection() File "/usr/lib/python2.7/site-packages/f5/bigip/mixins.py", line 102, in getattr raise AttributeError(error_message) AttributeError: 'f5.bigip.BigIP'>' object has no attribute 'tm'