예제 #1
0
    def handle(self):
        event = self.event
        alert = AlertGenerator(event)
        interface = event.get_subject()
        is_unresolved = unresolved.refers_to_unresolved_alert(event)

        if event.state == event.STATE_START:
            alert.alert_type = 'linkDegraded'
            if is_unresolved:
                return self._handle_duplicate(alert, is_unresolved)
            if not interface.is_degraded():
                return self._ignore("Got aggregateLinkState start event, but "
                                    "the interface is not currently degraded.")

        elif event.state == event.STATE_END:
            alert.alert_type = 'linkRestored'
            if not is_unresolved:
                return self._ignore("Got aggregateLinkState end event, but "
                                    "there is no currently active alert to "
                                    "resolve.")
            if interface.is_degraded():
                return self._ignore("Got aggregateLinkState end event, but the "
                                    "interface still appears to be degraded.")

        if self._box_is_on_maintenance():
            alert.post_alert_history()
        else:
            alert.post()

        event.delete()
예제 #2
0
    def handle(self):
        event = self.event
        alert = AlertGenerator(event)

        if event.state in [event.STATE_START, event.STATE_END]:
            service = self._update_service()
            self._set_alert_type(alert, service)

        self._populate_alert(alert)

        if self._box_is_on_maintenance():
            alert.post_alert_history()
        else:
            alert.post()

        event.delete()
예제 #3
0
    def handle(self):
        event = self.event
        alert = AlertGenerator(event)

        if event.state in [event.STATE_START, event.STATE_END]:
            service = self._update_service()
            self._set_alert_type(alert, service)

        self._populate_alert(alert)

        if self._box_is_on_maintenance():
            alert.post_alert_history()
        else:
            alert.post()

        event.delete()
예제 #4
0
파일: engine.py 프로젝트: snauman817/nav
    def _post_generic_alert(self, event):
        alert = AlertGenerator(event)
        if 'alerttype' in event.varmap:
            alert.alert_type = event.varmap['alerttype']

        is_stateless = event.state == Event.STATE_STATELESS
        if is_stateless or not alert.is_event_duplicate():
            if self._box_is_on_maintenance(event):
                self._logger.debug('%s is on maintenance, only posting to '
                                   'alert history for %s event',
                                   event.netbox, event.event_type)
                alert.post_alert_history()
            else:
                self._logger.debug('Posting %s event', event.event_type)
                alert.post()
        else:
            self._logger.info('Ignoring duplicate %s event for %s',
                              event.event_type, event.netbox)
            self._logger.debug('ignored alert details: %r', event)
        event.delete()