6 from datetime import datetime
7 from optparse import OptionParser
8 from geni.util.rspec import Rspec
10 sfi_dir = os.path.expanduser("~/.sfi/")
15 usage = "%(command)s [options]" % locals()
16 description = """getNodes will query comon and generate a list of nodes
17 (plain or rspec) that meet the specified crieteria. If no criteria is
18 specified, the default action is to return node comon considers 'alive'
21 cmp_options = ['rwfs', 'uptime', 'loads', 'meminfo', 'kernver', 'cpuspeed', 'txrate', 'rxrate', 'numslices', 'liveslices']
24 parser = OptionParser(usage=usage,description=description)
26 parser.add_option("--%s" % opt, dest="%s" % opt, action="store_true",
27 help = "available options [%s]" % ",".join(cmp_options))
32 def download_file(url, localFile):
33 webFile = urllib.urlopen(url)
34 localFile = open(localFile, 'w')
35 localFile.write(webFile.read())
42 month = str(date.month)
49 comon_data_filename = sfi_dir + os.sep + "comon_data.dat"
50 comon_url = "http://comon.cs.princeton.edu/status/dump_comon_%s%s%s" % (year, month, day)
52 print "storing comon data from %s in %s" % (comon_url, comon_data_filename)
53 download_file(comon_url, comon_data_filename)
55 return comon_data_filename
58 parser = create_parser()
59 comon_file = get_comon_data()
62 if __name__ == '__main__':