-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathf5debugCache2.py
74 lines (66 loc) · 2.25 KB
/
f5debugCache2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from f5.bigip import ManagementRoot
import sys
import time
sys.setrecursionlimit(10000) # Allow python to recurse more than the default 999. There are over 4000 Pools we need to iterate through :(
# Connect to the BigIP and configure the basic objects
mgmt = ManagementRoot('', '', '')
ltm = mgmt.tm.ltm
ip = [""]
pool_members = []
pool_name = []
pools = []
print("Starting node")
f5_nodes = mgmt.tm.ltm.nodes.get_collection()
print("finish node")
print("starting pool")
f5_pools = mgmt.tm.ltm.pools.get_collection()
print("finish pool")
def deletenode():
for node in f5_nodes:
if node.address in ip:
print(ip)
print("Inside Deletenode func " + node.address)
f=open("node_delete" + now.strftime("%Y-%m-%d %H:%M"), "a")
f.write(node.address)
f.close()
node.delete()
print("Deleting")# why is it not reading this
def deletepool():
for pool in f5_pools:
if pool.name in pool_name: # iterate through the pool list. If the pool
print("inside deletepool")
print(pool.name)
print(pool_name)
print("Inside deletepool func")
print(pool)
f=open("pool_delete" + now.strftime("%Y-%m-%d %H:%M"), "a")
f.write(pool.name)
f.close()
pool.delete()
def deleteemptypool(self):
for pool in self.f5_pools:
if pool.members_s.items:
continue
else:
print(pool.name)
f=open("empty_pools" + now.strftime("%Y-%m-%d %H:%M"), "a")
f.write(pool.name)
f.close()
pool.delete()
print("starting members search")
for pool in f5_pools: # Lets get the pools and the nodes/members that are apart of the pools
for pool_member in pool.members_s.get_collection():
if pool_member.address in ip:
print("pool member name = " + pool_member.name)
print("pool name = " + pool.name)
pool_members.append(pool_member.name)
pool_name.append(pool.name)
pools.append(pool)
def main():
start = time.time()
deletepool()
deletenode()
end = time.time()
print( end - start)
if __name__ == '__main__':
main()