(no commit message)
[monitor.git] / get_metasite_nodes.py
1 #!/usr/bin/python
2 import plc
3 import database
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_sitelist = []
11         count = 0
12         # for each prefix above
13         for pre_loginbase in meta_sites:
14                 print "getting sites from base %s*" % pre_loginbase
15                 search_sites  = plc.getSites({'login_base' : pre_loginbase + "*"})
16                 # for each of the sites that begin with this prefix
17                 for site in search_sites:
18                         # get the nodes for that site
19                         l_sitelist.append(site['login_base'])
20                         print "%s : " % site['login_base']
21                         nodes = plc.getSiteNodes2(site['login_base'])
22                         for node in nodes:
23                                 hn = node['hostname']
24                                 if hn not in l_blacklist:
25                                         print "\t%s" % hn
26                                         count += 1
27                                         # add the nodes to the blacklist
28                                         l_blacklist.append(hn)
29                                 #else:
30                                 #       print "not adding %s" % hn
31         print string.join(l_sitelist,  ",")
32         print "Found %d nodes" % count
33         print "Found %d sites " % len(l_sitelist)
34
35
36 if __name__=="__main__":
37         main()