Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. import requests
  2. from requests.auth import HTTPBasicAuth
  3.  
  4. BASE_URL = "https://localhost/mgmt/tm"
  5. username = "admin"
  6. password = "admin"
  7.  
  8. def makeRequest(username, password, url):
  9. response_data = requests.get(url, auth = HTTPBasicAuth(username, password), verify = False)
  10.  
  11. return response_data.json()
  12.  
  13.  
  14. pool_data = makeRequest(username, password, BASE_URL + "/ltm/pool")
  15.  
  16. for pools in pool_data['items']:
  17. print pools['name']
  18. tildPath = pools['fullPath'].replace('/','~')
  19.  
  20. #GET the Pool stats
  21. pool_stats = makeRequest(username, password, BASE_URL + "/ltm/pool/" + tildPath + "/stats")
  22. print pool_stats['entries']['status.availabilityState']['description']
  23.  
  24. #GET the Pool Members
  25. pool_members = makeRequest(username, password, BASE_URL + "/ltm/pool/" + tildPath + "/members")
  26.  
  27. for members in pool_members['items']:
  28. print members['name'] +" " + members['address'] + " " + members['state']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement