Commit 95d20cf2 authored by Dmitry Volodin's avatar Dmitry Volodin

Merge branch 'noc-1245' into 'master'

#1245 Move configvalidation umbrella to 'Config | Object Policy Violation' AlarmClass.

See merge request !3169
parents be31a99a 22399e0c
......@@ -6,8 +6,12 @@
# See LICENSE for details
# ----------------------------------------------------------------------
# Third-party modules
import cachetools
# NOC modules
from import DiscoveryCheck
from import AlarmClass
class ConfigValidationCheck(DiscoveryCheck):
......@@ -18,21 +22,49 @@ class ConfigValidationCheck(DiscoveryCheck):
name = "configvalidation"
required_artefacts = ["config_acquired"]
def get_ac_cm_violations():
return AlarmClass.get_by_name("Config | Policy Violations")
def handler(self):"Running config validation")
is_changed = self.get_artefact("config_changed") or False
# Legacy CLIPS path, problems are passed via Facts
# New ConfDB path, problems are passed via alarms
n = 0
alarms = []
for problem in self.object.iter_validation_problems(is_changed):
n += 1
if n:"%d problem(s) detected", n)
alarms += [self.get_umbrella_alarm_cfg(**problem)]
# self.set_problem(**problem)
if alarms:"%d problem(s) detected", len(alarms))
else:"No problems detected")
self.job.update_umbrella(self.get_ac_cm_violations(), alarms)
def is_enabled(self):
checks = self.job.attrs.get("_checks", set())
return not checks or "config" in checks
def get_umbrella_alarm_cfg(
self, alarm_class=None, path=None, message=None, fatal=False, **kwargs
Getting Umbrella Alarm Cfg
:param alarm_class: Alarm class instance or name
:param path: Additional path
:param message: Text message
:param fatal: True if problem is fatal and all following checks
must be disabled
:param kwargs: Dict containing optional variables
alarm_cfg = {
"alarm_class": AlarmClass.get_by_name(alarm_class),
"path": " | ".join(path),
"vars": kwargs,
alarm_cfg["vars"]["message"] = message
alarm_cfg["vars"]["path"] = path
return alarm_cfg
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment