Tagging module Monitor - Monitor-1.0-4
[monitor.git] / get_metasite_nodes.py
1 #!/usr/bin/python
2 import plc
3 import soltesz
4 import string
5 import sys
6
7 def main():
8         meta_sites = ['canarie', 'rnp', 'jgn2', 'i2', 'tp', 'princeton', 'princetondsl', 'plcolo', 'wide']
9         l_blacklist = [ "grouse.hpl.hp.com", "planet1.att.nodes.planet-lab.org"]
10         #l_blacklist = soltesz.dbLoad("l_blacklist")
11         l_sitelist = []
12         count = 0
13         # for each prefix above
14         for pre_loginbase in meta_sites:
15                 print "getting sites from base %s*" % pre_loginbase
16                 search_sites  = plc.getSites({'login_base' : pre_loginbase + "*"})
17                 # for each of the sites that begin with this prefix
18                 for site in search_sites:
19                         # get the nodes for that site
20                         l_sitelist.append(site['login_base'])
21                         print "%s : " % site['login_base']
22                         nodes = plc.getSiteNodes2(site['login_base'])
23                         for node in nodes:
24                                 hn = node['hostname']
25                                 if hn not in l_blacklist:
26                                         print "\t%s" % hn
27                                         count += 1
28                                         # add the nodes to the blacklist
29                                         l_blacklist.append(hn)
30                                 #else:
31                                 #       print "not adding %s" % hn
32         print string.join(l_sitelist,  ",")
33         print "Found %d nodes" % count
34         print "Found %d sites " % len(l_sitelist)
35
36         soltesz.dbDump("l_blacklist")
37
38 if __name__=="__main__":
39         main()