clearer names for actions, and infer actions better
[monitor.git] / tests / bwlimit.py
1 #!/usr/bin/python
2
3 import os
4 import sys
5 import string
6 import time
7 import plc
8
9 bwlimit = {}
10
11 def main():
12         global bwlimit
13
14         l_nodes = plc.getNodes()
15         d_nodes = {}
16         for host in l_nodes:
17                 h = host['hostname']
18                 d_nodes[h] = host
19
20         for h in d_nodes:
21                 host = d_nodes[h]
22                 for nw_id in host['interface_ids']:
23                         l_nw = plc.getNodeNetworks({'interface_id': host['interface_ids']})
24                         bwlimit[h] = []
25                         for nw in l_nw:
26                                 if nw['bwlimit'] != None and nw['bwlimit'] < 500000:
27                                         bwlimit[h].append(nw['bwlimit'])
28                         if len(bwlimit[h]) == 0:
29                                 del bwlimit[h]
30         
31         for host in bwlimit:
32                 print "%s %s" % (host, bwlimit[host])
33                         
34         
35 if __name__ == '__main__':
36         main()