Exemple #1
0
    def __roster(self, event):
        '''
        At startup, set the recipient's state based on the roster.
        '''
        if log.isEnabledFor(salt.log.TRACE):
            roster = [addr for addr in self.client_roster]
            log.trace('roster changed: %s', roster)
        for recipient in self.recipients.values():
            if recipient.state == UNKNOWN:
                if recipient.addr in self.client_roster:
                    roster_item = self.client_roster[recipient.addr]
                else:
                    roster_item = None
                self.__set_state(recipient, roster_item)
#        self.del_event_handler('roster_update', self.__roster)
        self.__pending()
Exemple #2
0
 def _load_msg_config(self, config):
     '''
     Load the email message configuration from /etc/salt/alert.
     '''
     self.sender = config.get('from', DEFAULT_SENDER)
     self.headers = config.get('headers', DEFAULT_HEADERS)
     self.subject = string.Template(config.get('subject', DEFAULT_SUBJECT))
     self.body = string.Template(config.get('body', DEFAULT_BODY))
     if log.isEnabledFor(salt.log.TRACE):
         log.trace(
             '''email alert message:
 from:    %s
 subject: %s
 headers: %s
 body:    %s''', self.sender, self.subject.safe_substitute({}),
             self.headers,
             '\n        '.join(self.body.safe_substitute({}).splitlines()))
Exemple #3
0
    def __roster(self, event):
        '''
        At startup, set the recipient's state based on the roster.
        '''
        if log.isEnabledFor(salt.log.TRACE):
            roster = [addr for addr in self.client_roster]
            log.trace('roster changed: %s', roster)
        for recipient in self.recipients.values():
            if recipient.state == UNKNOWN:
                if recipient.addr in self.client_roster:
                    roster_item = self.client_roster[recipient.addr]
                else:
                    roster_item = None
                self.__set_state(recipient, roster_item)


#        self.del_event_handler('roster_update', self.__roster)
        self.__pending()
Exemple #4
0
 def _load_msg_config(self, config):
     """
     Load the email message configuration from /etc/salt/alert.
     """
     self.sender = config.get("from", DEFAULT_SENDER)
     self.headers = config.get("headers", DEFAULT_HEADERS)
     self.subject = string.Template(config.get("subject", DEFAULT_SUBJECT))
     self.body = string.Template(config.get("body", DEFAULT_BODY))
     if log.isEnabledFor(salt.log.TRACE):
         log.trace(
             """email alert message:
 from:    %s
 subject: %s
 headers: %s
 body:    %s""",
             self.sender,
             self.subject.safe_substitute({}),
             self.headers,
             "\n        ".join(self.body.safe_substitute({}).splitlines()),
         )