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 $
11 from monitor_policy import *
16 api = plc.getAuthAPI()
18 from clean_policy import *
21 print "calling reboot!!! %s " % hostname
23 l_nodes = api.GetNodes(hostname)
25 raise Exception("No such host: %s" % hostname)
27 l_blacklist = database.if_cached_else(1, "l_blacklist", lambda : [])
28 l_ticket_blacklist = database.if_cached_else(1,"l_ticket_blacklist",lambda : [])
30 l_nodes = filter(lambda x : not x['hostname'] in l_blacklist, l_nodes)
32 raise Exception("Host removed via blacklist: %s" % hostname)
34 ad_dbTickets = database.if_cached_else_refresh(True, False, "ad_dbTickets", lambda : [])
35 if ad_dbTickets == None:
36 raise Exception("Could not find cached dbTickets")
38 print "starting new thing"
39 mon = MonitorMergeDiagnoseSendEscellate(hostname, True)
43 #merge = Merge( [node['hostname'] for node in l_nodes])
44 #record_list = merge.run()
46 #rt = RT(record_list, ad_dbTickets, l_ticket_blacklist)
47 #record_list = rt.run()
49 #diag = Diagnose(record_list)
50 #diagnose_out = diag.run()
53 #action = Action(diagnose_out)
58 def reboot2(hostname):
59 l_nodes = api.GetNodes(hostname)
61 raise Exception("No such host: %s" % hostname)
63 l_blacklist = database.if_cached_else(1, "l_blacklist", lambda : [])
64 l_ticket_blacklist = database.if_cached_else(1,"l_ticket_blacklist",lambda : [])
66 l_nodes = filter(lambda x : not x['hostname'] in l_blacklist, l_nodes)
68 raise Exception("Host removed via blacklist: %s" % hostname)
70 ad_dbTickets = database.if_cached_else_refresh(True, False, "ad_dbTickets", lambda : None)
71 if ad_dbTickets == None:
72 raise Exception("Could not find cached dbTickets")
76 args['hostname'] = "%s" % hostname
77 args['hostname_list'] = "%s" % hostname
78 args['loginbase'] = plc.siteId(hostname)
80 m = PersistMessage(hostname, "Please Update Boot Image for %s" % hostname,
81 mailtxt.newalphacd_one[1] % args, True, db='bootcd_persistmessages')
84 merge = Merge( [node['hostname'] for node in l_nodes])
85 record_list = merge.run()
87 rt = RT(record_list, ad_dbTickets, l_ticket_blacklist)
88 record_list = rt.run()
90 diag = Diagnose(record_list)
91 diagnose_out = diag.run()
94 action = Action(diagnose_out)
101 for host in sys.argv[1:]:
104 if __name__ == '__main__':