コード例 #1
0
ファイル: alert.py プロジェクト: jshpng/alerta
    def from_action(self, action, text='', timeout=None):
        if action == actions.ACTION_UNACK:
            self.status = status_code.OPEN

        if action == actions.ACTION_SHELVE:
            self.status = status_code.SHELVED

        if action == actions.ACTION_UNSHELVE:
            self.status = status_code.OPEN

        if action == actions.ACTION_ACK:
            self.status = status_code.ACK

        if action == actions.ACTION_CLOSE:
            self.severity = current_app.config['DEFAULT_NORMAL_SEVERITY']
            self.status = status_code.CLOSED

        self.timeout = timeout or current_app.config['ALERT_TIMEOUT']
        history = History(id=self.id,
                          event=self.event,
                          severity=self.severity,
                          status=self.status,
                          text=text,
                          change_type="action",
                          update_time=datetime.utcnow())
        return db.set_severity_and_status(self.id, self.severity, self.status,
                                          self.timeout, history)
コード例 #2
0
ファイル: alert.py プロジェクト: Toniob/alerta
 def set_severity_and_status(self, severity, status, text='', timeout=None):
     timeout = timeout or current_app.config['ALERT_TIMEOUT']
     history = History(id=self.id,
                       event=self.event,
                       severity=severity,
                       status=status,
                       text=text,
                       change_type='action',
                       update_time=datetime.utcnow())
     return db.set_severity_and_status(self.id, severity, status, timeout,
                                       history)