3 # Copyright (c) 2004 The Trustees of Princeton University (Trustees).
5 # Stephen Soltesz <soltesz@cs.princeton.edu>
7 # $Id: monitor.py,v 1.7 2007/07/03 19:59:02 soltesz Exp $
15 api = plc.getAuthAPI()
17 from clean_policy import *
20 print "CALLING: mailmonitor.reboot(%s)" % hostname
22 l_nodes = api.GetNodes(hostname)
24 raise Exception("No such host: %s" % hostname)
26 l_blacklist = database.if_cached_else(1, "l_blacklist", lambda : [])
27 l_ticket_blacklist = database.if_cached_else(1,"l_ticket_blacklist",lambda : [])
29 l_nodes = filter(lambda x : not x['hostname'] in l_blacklist, l_nodes)
31 raise Exception("Host removed via blacklist: %s" % hostname)
33 #ad_dbTickets = database.if_cached_else_refresh(True, False, "ad_dbTickets", lambda : [])
34 #if ad_dbTickets == None:
35 # raise Exception("Could not find cached dbTickets")
37 #print "starting new thing"
38 mon = MonitorMergeDiagnoseSendEscellate(hostname, True)
42 #merge = Merge( [node['hostname'] for node in l_nodes])
43 #record_list = merge.run()
45 #rt = RT(record_list, ad_dbTickets, l_ticket_blacklist)
46 #record_list = rt.run()
48 #diag = Diagnose(record_list)
49 #diagnose_out = diag.run()
52 #action = Action(diagnose_out)
57 #def reboot2(hostname):
58 # l_nodes = api.GetNodes(hostname)
59 # if len(l_nodes) == 0:
60 # raise Exception("No such host: %s" % hostname)
62 # l_blacklist = database.if_cached_else(1, "l_blacklist", lambda : [])
63 # l_ticket_blacklist = database.if_cached_else(1,"l_ticket_blacklist",lambda : [])
65 # l_nodes = filter(lambda x : not x['hostname'] in l_blacklist, l_nodes)
66 # if len(l_nodes) == 0:
67 # raise Exception("Host removed via blacklist: %s" % hostname)
69 # ad_dbTickets = database.if_cached_else_refresh(True, False, "ad_dbTickets", lambda : None)
70 # if ad_dbTickets == None:
71 # raise Exception("Could not find cached dbTickets")
75 # args['hostname'] = "%s" % hostname
76 # args['hostname_list'] = "%s" % hostname
77 # args['loginbase'] = plc.siteId(hostname)
79 # m = PersistMessage(hostname, "Please Update Boot Image for %s" % hostname,
80 # mailtxt.newalphacd_one[1] % args, True, db='bootcd_persistmessages')
83 # merge = Merge( [node['hostname'] for node in l_nodes])
84 # record_list = merge.run()
86 # rt = RT(record_list, ad_dbTickets, l_ticket_blacklist)
87 # record_list = rt.run()
89 # diag = Diagnose(record_list)
90 # diagnose_out = diag.run()
93 # action = Action(diagnose_out)
100 for host in sys.argv[1:]:
103 if __name__ == '__main__':