Difference between revisions of "F5 sdk"
Jump to navigation
Jump to search
| (6 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| + | # SDK | ||
| + | - https://community.f5.com/t5/technical-articles/getting-started-with-the-f5-common-python-sdk/ta-p/288629 | ||
| + | - https://github.com/f5devcentral/f5-sdk-python | ||
| + | - Discontinued - https://github.com/F5Networks/f5-common-python | ||
| + | |||
| + | |||
| + | # Go | ||
| + | - https://github.com/e-XpertSolutions/f5-rest-client | ||
| + | - https://community.f5.com/t5/codeshare/go-library-to-manage-big-ip-icontrol-rest-api/ta-p/290967 | ||
| + | |||
| + | # More | ||
| + | |||
https://community.f5.com/t5/technical-forum/python-f5-sdk-401-unexpected-error-f5-authorization-required/td-p/167675 | https://community.f5.com/t5/technical-forum/python-f5-sdk-401-unexpected-error-f5-authorization-required/td-p/167675 | ||
https://community.f5.com/t5/technical-forum/get-list-of-monitors-through-sdk/td-p/120088 | https://community.f5.com/t5/technical-forum/get-list-of-monitors-through-sdk/td-p/120088 | ||
| + | |||
| + | https://community.f5.com/t5/technical-articles/tinkering-with-the-bigrest-python-sdk-part-2/ta-p/285190 | ||
Monitors | Monitors | ||
https://community.f5.com/t5/technical-forum/using-the-python-sdk-for-monitors/td-p/231801 | https://community.f5.com/t5/technical-forum/using-the-python-sdk-for-monitors/td-p/231801 | ||
| + | |||
| + | |||
| + | Stats | ||
| + | |||
| + | https://community.f5.com/t5/technical-forum/how-do-i-get-pool-stats-using-f5-sdk/td-p/86748 | ||
| + | |||
| + | |||
| + | # Code Examples | ||
| + | |||
| + | ``` | ||
| + | from f5.bigip import ManagementRoot | ||
| + | from f5.utils.responses.handlers import Stats | ||
| + | |||
| + | #Authentication | ||
| + | mgmt = ManagementRoot("***", "***", "***") | ||
| + | |||
| + | #Print tmos version | ||
| + | file = open('Availability.txt', 'w') | ||
| + | TMOS = "TMOS version - " + mgmt.tmos_version | ||
| + | print(TMOS) | ||
| + | file.write(TMOS + '\n') | ||
| + | |||
| + | #Get a collection of all Virtual Servers, pools | ||
| + | all_vips = mgmt.tm.ltm.virtuals.get_collection() | ||
| + | all_pools = mgmt.tm.ltm.pools.get_collection() | ||
| + | |||
| + | #Loop over all virtual servers and fetch name and availability | ||
| + | for vip in all_vips: | ||
| + | vip_stats = Stats(vip.stats.load()) | ||
| + | State = vip_stats.stat.status_availabilityState['description'] | ||
| + | file.write(vip.name + " - " + State + '\n') | ||
| + | |||
| + | #Loop over all pools | ||
| + | for pool in all_pools: | ||
| + | pool_stats = Stats(pool.stats.load()) | ||
| + | State = pool_stats.stat.status_availabilityState['description'] | ||
| + | file.write(pool.name + " - " + State + '\n') | ||
| + | #Loop over all pool members | ||
| + | for member in pool.members_s.get_collection(): | ||
| + | member_stats = Stats(member.stats.load()) | ||
| + | State = member_stats.stat.status_availabilityState['description'] | ||
| + | file.write(member.name + " - " + State + '\n') | ||
| + | ``` | ||
Latest revision as of 17:39, 19 August 2023
SDK
- https://community.f5.com/t5/technical-articles/getting-started-with-the-f5-common-python-sdk/ta-p/288629
- https://github.com/f5devcentral/f5-sdk-python
- Discontinued - https://github.com/F5Networks/f5-common-python
Go
- https://github.com/e-XpertSolutions/f5-rest-client
- https://community.f5.com/t5/codeshare/go-library-to-manage-big-ip-icontrol-rest-api/ta-p/290967
More
https://community.f5.com/t5/technical-forum/get-list-of-monitors-through-sdk/td-p/120088
Monitors
https://community.f5.com/t5/technical-forum/using-the-python-sdk-for-monitors/td-p/231801
Stats
https://community.f5.com/t5/technical-forum/how-do-i-get-pool-stats-using-f5-sdk/td-p/86748
Code Examples
from f5.bigip import ManagementRoot
from f5.utils.responses.handlers import Stats
#Authentication
mgmt = ManagementRoot("***", "***", "***")
#Print tmos version
file = open('Availability.txt', 'w')
TMOS = "TMOS version - " + mgmt.tmos_version
print(TMOS)
file.write(TMOS + '\n')
#Get a collection of all Virtual Servers, pools
all_vips = mgmt.tm.ltm.virtuals.get_collection()
all_pools = mgmt.tm.ltm.pools.get_collection()
#Loop over all virtual servers and fetch name and availability
for vip in all_vips:
vip_stats = Stats(vip.stats.load())
State = vip_stats.stat.status_availabilityState['description']
file.write(vip.name + " - " + State + '\n')
#Loop over all pools
for pool in all_pools:
pool_stats = Stats(pool.stats.load())
State = pool_stats.stat.status_availabilityState['description']
file.write(pool.name + " - " + State + '\n')
#Loop over all pool members
for member in pool.members_s.get_collection():
member_stats = Stats(member.stats.load())
State = member_stats.stat.status_availabilityState['description']
file.write(member.name + " - " + State + '\n')