X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=monitor_policy.py;h=5049db212eff1dbc075e22d80a3aa1a85c6cad70;hb=170be1fae6fd5956641668443245c50fbf7fd566;hp=f7c3edbeccd378e14b80f8797fe31155e0744cad;hpb=944d143a6528c4157b71f51ed480aec806cbaa06;p=monitor.git diff --git a/monitor_policy.py b/monitor_policy.py index f7c3edb..5049db2 100644 --- a/monitor_policy.py +++ b/monitor_policy.py @@ -6,6 +6,7 @@ from unified_model import cmpCategoryVal import sys import emailTxt import string +from monitor.wrapper import plccache from rt import is_host_in_rt_tickets import plc @@ -56,7 +57,7 @@ class Merge: self.merge_list = l_merge # the hostname to loginbase mapping - self.plcdb_hn2lb = database.dbLoad("plcdb_hn2lb") + self.plcdb_hn2lb = plccache.plcdb_hn2lb # Previous actions taken on nodes. self.act_all = database.if_cached_else(1, "act_all", lambda : {}) @@ -264,7 +265,7 @@ class RT: class Diagnose: def __init__(self, record_list): self.record_list = record_list - self.plcdb_hn2lb = database.dbLoad("plcdb_hn2lb") + self.plcdb_hn2lb = plccache.plcdb_hn2lb self.findbad = database.if_cached_else(1, "findbad", lambda : {}) self.diagnose_in = {} @@ -845,7 +846,7 @@ def reboot_node(args): class Action: def __init__(self, diagnose_out): # the hostname to loginbase mapping - self.plcdb_hn2lb = database.dbLoad("plcdb_hn2lb") + self.plcdb_hn2lb = plccache.plcdb_hn2lb # Actions to take. self.diagnose_db = diagnose_out @@ -937,18 +938,22 @@ class Action: if ADMIN & roles: contacts += [config.email] if TECH & roles: - contacts += [TECHEMAIL % loginbase] + #contacts += [TECHEMAIL % loginbase] + contacts += plc.getTechEmails(loginbase) if PI & roles: - contacts += [PIEMAIL % loginbase] + #contacts += [PIEMAIL % loginbase] + contacts += plc.getPIEmails(loginbase) if USER & roles: + contacts += plc.getSliceUserEmails(loginbase) slices = plc.slices(loginbase) if len(slices) >= 1: - for slice in slices: - contacts += [SLICEMAIL % slice] print "SLIC: %20s : %d slices" % (loginbase, len(slices)) else: print "SLIC: %20s : 0 slices" % loginbase + unique_contacts = set(contacts) + contacts = [ c for c in unique_contacts ] # convert back into list + try: subject = message[0] % args body = message[1] % args