X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=monitor%2Fmodel.py;h=5d0fc0579bdcf707bb8be3bd087b8ddd83eeeb1e;hb=fbe2fbd7f5d866205f878e68968dcef14a3812ab;hp=ce941f2c9000f78db8c2e33083715309f9df4767;hpb=da913fbd1629fc4669b186915df8ff3a340482d3;p=monitor.git diff --git a/monitor/model.py b/monitor/model.py index ce941f2..5d0fc05 100755 --- a/monitor/model.py +++ b/monitor/model.py @@ -2,7 +2,7 @@ from monitor import database -from monitor.wrapper import plc, plccache +from monitor.wrapper import plc from monitor.wrapper import mailer import time @@ -413,6 +413,7 @@ class Target: class Record(object): def __init__(self, hostname, data): + from monitor.wrapper import plccache self.hostname = hostname self.data = data self.plcdb_hn2lb = plccache.plcdb_hn2lb @@ -527,6 +528,8 @@ class Record(object): else: print "takeAction: increasing penalty for %s"%self.hostname pp.increase() + + print "takeAction: applying penalty to %s as index %s"% (self.hostname, index) pp.index = index pp.apply(self.hostname) pp.save() @@ -580,7 +583,7 @@ class Record(object): contacts += plc.getTechEmails(self.loginbase) if PI & roles: #contacts += [PIEMAIL % self.loginbase] - contacts += plc.getSliceUserEmails(self.loginbase) + contacts += plc.getPIEmails(self.loginbase) if USER & roles: contacts += plc.getSliceUserEmails(self.loginbase) slices = plc.slices(self.loginbase) @@ -600,6 +603,45 @@ class NodeRecord: self.ticket = None self.target = target + +class MonRecord(object): + def __init__(self, data): + self.keys = data.keys() + self.keys.sort() + self.__dict__.update(data) + return + + def get(self): + ret= {} + for k in self.keys: + ret[k] = self.__dict__[k] + return ret + + def __repr__(self): + str = "" + str += self.host + "\n" + for k in self.keys: + if "message" in k or "msg" in k: + continue + if 'time' in k: + s_time=time.strftime("%Y/%m/%d %H:%M:%S", + time.gmtime(self.__dict__[k])) + str += "\t'%s' : %s\n" % (k, s_time) + else: + str += "\t'%s' : %s\n" % (k, self.__dict__[k]) + str += "\t--" + return str + + def delField(self, field): + if field in self.__dict__: + del self.__dict__[field] + + if field in self.keys: + for i in range(0,len(self.keys)): + if self.keys[i] == field: + del self.keys[i] + break + class Action(MonRecord): def __init__(self, host, data): self.host = host @@ -647,43 +689,6 @@ def node_end_record(node): del act_all return True -class MonRecord(object): - def __init__(self, data): - self.keys = data.keys() - self.keys.sort() - self.__dict__.update(data) - return - - def get(self): - ret= {} - for k in self.keys: - ret[k] = self.__dict__[k] - return ret - - def __repr__(self): - str = "" - str += self.host + "\n" - for k in self.keys: - if "message" in k or "msg" in k: - continue - if 'time' in k: - s_time=time.strftime("%Y/%m/%d %H:%M:%S", - time.gmtime(self.__dict__[k])) - str += "\t'%s' : %s\n" % (k, s_time) - else: - str += "\t'%s' : %s\n" % (k, self.__dict__[k]) - str += "\t--" - return str - - def delField(self, field): - if field in self.__dict__: - del self.__dict__[field] - - if field in self.keys: - for i in range(0,len(self.keys)): - if self.keys[i] == field: - del self.keys[i] - break class LogRoll: def __init__(self, list=None):