X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=monitor%2Fdatabase%2Finfo%2Finterface.py;h=06c83a0cf0afc0ca5a6304400df7912afd389c3e;hb=45fea95bb898f254ea7e987d7417e9091885fbee;hp=e9a08a639f69ad4e5f0c5ffaa7a91f27c44a00d2;hpb=6481ba179a2fa6ab22cbed7f37a8104b152f77b3;p=monitor.git diff --git a/monitor/database/info/interface.py b/monitor/database/info/interface.py index e9a08a6..06c83a0 100644 --- a/monitor/database/info/interface.py +++ b/monitor/database/info/interface.py @@ -1,11 +1,13 @@ -from monitor import reboot from monitor.common import * from monitor.model import * from monitor.wrapper import plc from monitor.wrapper import plccache from monitor.wrapper.emailTxt import mailtxt from monitor.database.info.model import * +# NOTE: must import this after monitor.database.info.model b/c that imports +# pcucontro.reboot and blocks this version, if it comes last. +from monitor import reboot class SiteInterface(HistorySiteRecord): @classmethod @@ -112,7 +114,7 @@ class SiteInterface(HistorySiteRecord): # those errors. args = {'loginbase' : self.db.loginbase, - 'penalty_level' : self.db.penalty_level, + 'penalty_level' : -self.db.penalty_level, 'monitor_hostname' : config.MONITOR_HOSTNAME, 'support_email' : config.support_email, 'plc_name' : config.PLC_NAME, @@ -127,6 +129,7 @@ class SiteInterface(HistorySiteRecord): message = getattr(mailtxt, type) + ccemail = False saveact = True viart = True if 'viart' in kwargs: @@ -136,6 +139,9 @@ class SiteInterface(HistorySiteRecord): if 'saveact' in kwargs: saveact = kwargs['saveact'] + if 'ccemail' in kwargs: + ccemail = kwargs['ccemail'] + if viart: self.getTicketStatus() # get current message status if self.db.message_status not in ['open', 'new']: @@ -143,8 +149,10 @@ class SiteInterface(HistorySiteRecord): m = Message(message[0] % args, message[1] % args, viart, self.db.message_id) - contacts = self.getContacts() - #contacts = [config.cc_email] + if ccemail: + contacts = [config.exception_email] + else: + contacts = self.getContacts() print "sending message: %s to site %s for host %s" % (type, self.db.loginbase, hostname) @@ -177,7 +185,7 @@ class SiteInterface(HistorySiteRecord): def runBootManager(self, hostname): from monitor import bootman print "attempting BM reboot of %s" % hostname - ret = "" + ret = "error" try: ret = bootman.restore(self, hostname) err = "" @@ -185,10 +193,19 @@ class SiteInterface(HistorySiteRecord): err = traceback.format_exc() print err + # TODO: keep this record so that the policy.py can identify all + # bootmanager_* actions without explicitly listing every kind. act = ActionRecord(loginbase=self.db.loginbase, hostname=hostname, action='reboot', action_type='bootmanager_restore', + error_string="") + + if ret: + act = ActionRecord(loginbase=self.db.loginbase, + hostname=hostname, + action='reboot', + action_type='bootmanager_' + ret, error_string=err) return ret