Skip to content

Commit

Permalink
Merge pull request #7 from Uninett/feature/convey-severity-properly
Browse files Browse the repository at this point in the history
Use verbatim severity value on NAV >= 5.2
  • Loading branch information
lunkwill42 authored Sep 22, 2021
2 parents c165719 + eda8039 commit ee03571
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/navargus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from nav.models.event import AlertHistory, STATE_START, STATE_STATELESS, STATE_END
from nav.logs import init_stderr_logging
from nav.config import open_configfile
from nav.buildconf import VERSION as _NAV_VERSION

from django.urls import reverse
from django.db.models import Q
Expand All @@ -56,6 +57,8 @@
_client = None
_config = None # type: Configuration
NOT_WHITESPACE = re.compile(r"[^\s]")
NAV_SERIES = tuple(int(i) for i in _NAV_VERSION.split(".")[:2])
NAV_VERSION_WITH_SEVERITY = (5, 2)


def main():
Expand Down Expand Up @@ -227,12 +230,11 @@ def convert_alerthistory_object_to_argus_incident(alert: AlertHistory) -> Incide


def convert_severity_to_level(severity: int) -> int:
"""Converts a NAV severity level into an Argus Incident level.
ATM, NAV severities are poorly defined, so this just falls back to the default
level as set in the config file
"""
return _config.get_default_level()
"""Converts a NAV severity level into an Argus Incident level"""
if NAV_SERIES >= NAV_VERSION_WITH_SEVERITY:
return severity # NAV severity levels match Argus levels from this version on
else:
return _config.get_default_level()


def get_short_start_description(alerthist: AlertHistory):
Expand Down

0 comments on commit ee03571

Please sign in to comment.