X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=mailmonitor.py;h=fab3e65ab572a4bd591399cc02d44b231ddaa361;hb=08bc8fdd4fc58fd7db356b0e5ba981d975231b78;hp=c9c1750f77175bbea8d73f5f1d0693b02324cead;hpb=ee740a3ff286a9720cd1656cd60a3c85f0f14b29;p=monitor.git diff --git a/mailmonitor.py b/mailmonitor.py index c9c1750..fab3e65 100644 --- a/mailmonitor.py +++ b/mailmonitor.py @@ -6,15 +6,15 @@ # # $Id: monitor.py,v 1.7 2007/07/03 19:59:02 soltesz Exp $ -import database - -import rt import sys -import plc -api = plc.getAuthAPI() +from monitor import database +from monitor.wrapper import rt +from monitor.wrapper import plc +from monitor.policy import * +from monitor.database.info.model import * -from clean_policy import * +api = plc.getAuthAPI() def reboot(hostname): print "CALLING: mailmonitor.reboot(%s)" % hostname @@ -23,79 +23,18 @@ def reboot(hostname): if len(l_nodes) == 0: raise Exception("No such host: %s" % hostname) - l_blacklist = database.if_cached_else(1, "l_blacklist", lambda : []) - l_ticket_blacklist = database.if_cached_else(1,"l_ticket_blacklist",lambda : []) + q_blacklist = BlacklistRecord.query.all() + l_blacklist = [ n.hostname for n in q_blacklist ] l_nodes = filter(lambda x : not x['hostname'] in l_blacklist, l_nodes) if len(l_nodes) == 0: raise Exception("Host removed via blacklist: %s" % hostname) - #ad_dbTickets = database.if_cached_else_refresh(True, False, "ad_dbTickets", lambda : []) - #if ad_dbTickets == None: - # raise Exception("Could not find cached dbTickets") - - #print "starting new thing" mon = MonitorMergeDiagnoseSendEscellate(hostname, True) mon.run() - #print "merge" - #merge = Merge( [node['hostname'] for node in l_nodes]) - #record_list = merge.run() - ##print "rt" - #rt = RT(record_list, ad_dbTickets, l_ticket_blacklist) - #record_list = rt.run() - ##print "diagnose" - #diag = Diagnose(record_list) - #diagnose_out = diag.run() - #print diagnose_out - #print "action" - #action = Action(diagnose_out) - #action.run() - return True -#def reboot2(hostname): -# l_nodes = api.GetNodes(hostname) -# if len(l_nodes) == 0: -# raise Exception("No such host: %s" % hostname) -# -# l_blacklist = database.if_cached_else(1, "l_blacklist", lambda : []) -# l_ticket_blacklist = database.if_cached_else(1,"l_ticket_blacklist",lambda : []) -# -# l_nodes = filter(lambda x : not x['hostname'] in l_blacklist, l_nodes) -# if len(l_nodes) == 0: -# raise Exception("Host removed via blacklist: %s" % hostname) -# -# ad_dbTickets = database.if_cached_else_refresh(True, False, "ad_dbTickets", lambda : None) -# if ad_dbTickets == None: -# raise Exception("Could not find cached dbTickets") -# -# -# args = {} -# args['hostname'] = "%s" % hostname -# args['hostname_list'] = "%s" % hostname -# args['loginbase'] = plc.siteId(hostname) -# -# m = PersistMessage(hostname, "Please Update Boot Image for %s" % hostname, -# mailtxt.newalphacd_one[1] % args, True, db='bootcd_persistmessages') -# -# #print "merge" -# merge = Merge( [node['hostname'] for node in l_nodes]) -# record_list = merge.run() -# #print "rt" -# rt = RT(record_list, ad_dbTickets, l_ticket_blacklist) -# record_list = rt.run() -# #print "diagnose" -# diag = Diagnose(record_list) -# diagnose_out = diag.run() -# #print diagnose_out -# #print "action" -# action = Action(diagnose_out) -# action.run() -# -# return True - - def main(): for host in sys.argv[1:]: reboot(host)