Container 2¶
In this lab we will review, line-by-line an example script that has been created to view the attributes of a BIG-IP Pool directly from the command line.
Task 1 – Review read_pool.py¶
- Open
read_pool.py
in Notepad++ - We will review the code. For brevity we have removed lines that are common with previous examples:
if not mgmt.tm.ltm.pools.pool.exists(partition=args.partition, name=args.pool_name):
raise Exception("Pool '%s' does not exist" % args.pool_name)
This if statement checks to see if a pool with the same name exists in the specified partition on the device. The key difference between this and the example in the previous lab is the inclusion of the ‘not’ keyword. This inverses the logic of the statement so that the Exception is raised when the pool DOES NOT exist
pool = mgmt.tm.ltm.pools.pool.load(partition=args.partition, name=args.pool_name)
This line loads the configuration of the pool into a variable
print "Pool %s:" % pool_path
pp.pprint(pool.raw)
These lines print the human-readable pool path and then uses the PrettyPrint library to dump all the attributes associated with the pool