X-Git-Url: http://git.onelab.eu/?p=monitor.git;a=blobdiff_plain;f=monitor%2Fdatabase%2Finfo%2Finterface.py;h=e9a08a639f69ad4e5f0c5ffaa7a91f27c44a00d2;hp=0692edeb8482f70561ff5cf681608998e3ffce41;hb=6481ba179a2fa6ab22cbed7f37a8104b152f77b3;hpb=a3fc470196242dafcf1144d78d64887e888b1453 diff --git a/monitor/database/info/interface.py b/monitor/database/info/interface.py index 0692ede..e9a08a6 100644 --- a/monitor/database/info/interface.py +++ b/monitor/database/info/interface.py @@ -111,7 +111,12 @@ class SiteInterface(HistorySiteRecord): # TODO: catch any errors here, and add an ActionRecord that contains # those errors. - args = {'loginbase' : self.db.loginbase, 'penalty_level' : self.db.penalty_level} + args = {'loginbase' : self.db.loginbase, + 'penalty_level' : self.db.penalty_level, + 'monitor_hostname' : config.MONITOR_HOSTNAME, + 'support_email' : config.support_email, + 'plc_name' : config.PLC_NAME, + 'plc_hostname' : config.PLC_WWW_HOSTNAME} args.update(kwargs) hostname = None @@ -121,10 +126,16 @@ class SiteInterface(HistorySiteRecord): if hasattr(mailtxt, type): message = getattr(mailtxt, type) + + saveact = True viart = True - if 'viart' in kwargs: + if 'viart' in kwargs: + saveact = kwargs['viart'] viart = kwargs['viart'] + if 'saveact' in kwargs: + saveact = kwargs['saveact'] + if viart: self.getTicketStatus() # get current message status if self.db.message_status not in ['open', 'new']: @@ -133,6 +144,7 @@ class SiteInterface(HistorySiteRecord): m = Message(message[0] % args, message[1] % args, viart, self.db.message_id) contacts = self.getContacts() + #contacts = [config.cc_email] print "sending message: %s to site %s for host %s" % (type, self.db.loginbase, hostname) @@ -142,6 +154,7 @@ class SiteInterface(HistorySiteRecord): # reset to previous status, since a new subject 'opens' RT tickets. self.setTicketStatus(self.db.message_status) + if saveact: # NOTE: only make a record of it if it's in RT. act = ActionRecord(loginbase=self.db.loginbase, hostname=hostname, action='notice', action_type=type, message_id=self.db.message_id) @@ -154,12 +167,12 @@ class SiteInterface(HistorySiteRecord): return def closeTicket(self): - # TODO: close the rt ticket before overwriting the message_id - mailer.closeTicketViaRT(self.db.message_id, "Ticket Closed by Monitor") - act = ActionRecord(loginbase=self.db.loginbase, action='notice', - action_type='close_ticket', message_id=self.db.message_id) - self.db.message_id = 0 - self.db.message_status = "new" + if self.db.message_id: + mailer.closeTicketViaRT(self.db.message_id, "Ticket Closed by Monitor") + act = ActionRecord(loginbase=self.db.loginbase, action='notice', + action_type='close_ticket', message_id=self.db.message_id) + self.db.message_id = 0 + self.db.message_status = "new" def runBootManager(self, hostname): from monitor import bootman