Added init scripts for monitor-server and -client.
[monitor.git] / tests / bwlimit.py
diff --git a/tests/bwlimit.py b/tests/bwlimit.py
new file mode 100755 (executable)
index 0000000..6b93156
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/python
+
+import os
+import sys
+import string
+import time
+import plc
+
+bwlimit = {}
+
+def main():
+       global bwlimit
+
+       l_nodes = plc.getNodes()
+       d_nodes = {}
+       for host in l_nodes:
+               h = host['hostname']
+               d_nodes[h] = host
+
+       for h in d_nodes:
+               host = d_nodes[h]
+               for nw_id in host['nodenetwork_ids']:
+                       l_nw = plc.getNodeNetworks({'nodenetwork_id': host['nodenetwork_ids']})
+                       bwlimit[h] = []
+                       for nw in l_nw:
+                               if nw['bwlimit'] != None and nw['bwlimit'] < 500000:
+                                       bwlimit[h].append(nw['bwlimit'])
+                       if len(bwlimit[h]) == 0:
+                               del bwlimit[h]
+       
+       for host in bwlimit:
+               print "%s %s" % (host, bwlimit[host])
+                       
+       
+if __name__ == '__main__':
+       main()