NEW: f5-sdk examples
This commit is contained in:
parent
99909b1d7c
commit
16061611f6
18
py/f5-sdk/datagroup-edit.py
Normal file
18
py/f5-sdk/datagroup-edit.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from f5.bigip import ManagementRoot
|
||||||
|
# Connect to the BigIP
|
||||||
|
session = ManagementRoot("10.11.232.247", "username", "password")
|
||||||
|
|
||||||
|
datagroup = session.tm.ltm.data_group.internals.internal.load(name='domain1-WHITELIST', partition='Common')
|
||||||
|
# Print current record
|
||||||
|
print(datagroup.records)
|
||||||
|
|
||||||
|
# Update record
|
||||||
|
# datagroup.records = [{'name': '203.60.15.113/32', 'data': ''}, {'name': '222.186.30.174/32', 'data': ''},{'name': '120.136.32.106/32', 'data': ''}]
|
||||||
|
datagroup.records = [{'name': '203.60.15.113/32', 'data': ''}, {'name': '222.186.30.174/32', 'data': ''}]
|
||||||
|
datagroup.update()
|
||||||
|
|
||||||
|
# Print latest record
|
||||||
|
print(datagroup.records)
|
||||||
|
|
37
py/f5-sdk/datagroup-list.py
Normal file
37
py/f5-sdk/datagroup-list.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from f5.bigip import ManagementRoot
|
||||||
|
# Connect to the BigIP
|
||||||
|
mgmt = ManagementRoot("10.11.232.247", "username", "password")
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
def showDatagroups() :
|
||||||
|
print("\n\n**** Showing Datagroups")
|
||||||
|
dgs = mgmt.tm.ltm.data_group.internals.get_collection()
|
||||||
|
for idx, dg in enumerate(dgs):
|
||||||
|
if "WHITELIST" in dg.name:
|
||||||
|
# print("\n{}: {}".format(idx, dg.raw))
|
||||||
|
print("\n{}: {}".format(idx, dg.name))
|
||||||
|
if hasattr(dg, 'records'):
|
||||||
|
print("\n{}: {}".format(idx, dg.records))
|
||||||
|
#for record in dg.records:
|
||||||
|
# print("\nrec: {}".format(record))
|
||||||
|
else:
|
||||||
|
print("\nObject {} has no records".format(dg.name))
|
||||||
|
|
||||||
|
def showDatagroupFiles():
|
||||||
|
print("\n\n**** Showing DatagroupFiles")
|
||||||
|
dgFiles = mgmt.tm.sys.file.data_groups.get_collection()
|
||||||
|
for idx, f in enumerate(dgFiles):
|
||||||
|
print('\n{}: {}'.format(idx, f.raw))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
showDatagroups()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user