Module: check_mk
Branch: master
Commit: 49df9f3a0b0423156d4bd140c315c858330261d6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=49df9f3a0b0423…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Mar 5 16:12:58 2018 +0100
Fixed config registration while reloading of checks (currently only happens during tests)
Change-Id: Iec6729660e0913f14fab1166c4bab169ddda89f5
---
cmk_base/checks.py | 1 +
cmk_base/config.py | 16 +++++++++++-----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/cmk_base/checks.py b/cmk_base/checks.py
index debe872..478454f 100644
--- a/cmk_base/checks.py
+++ b/cmk_base/checks.py
@@ -104,6 +104,7 @@ def get_plugin_paths(*dirs):
# normal structure, then only the file in local/ must be read!
def load_checks(filelist):
# Initialize some data structures which are populated while loading the checks
+ config.clear_check_variable_names(_check_variables.keys())
_check_variables.clear()
cmk_global_vars = set(config.get_variable_names())
diff --git a/cmk_base/config.py b/cmk_base/config.py
index d11f39d..1888df8 100644
--- a/cmk_base/config.py
+++ b/cmk_base/config.py
@@ -70,11 +70,20 @@ def register(name, default_value):
setattr(default_config, name, default_value)
-# Add configuration variables registered by checks to config module
def add_check_variables(check_variables):
+ """Add configuration variables registered by checks to config
module"""
default_config.__dict__.update(check_variables)
+def clear_check_variable_names(check_variable_names):
+ """Remove previously registered check variables from the config
module"""
+ for varname in check_variable_names:
+ try:
+ delattr(default_config, varname)
+ except AttributeError:
+ pass
+
+
# Load user configured values of check related configuration variables
# into the check module to make it available during checking.
#
@@ -88,10 +97,7 @@ def set_check_variables_for_checks():
for varname in cmk_base.checks.check_variable_names():
cmk_base.checks.set_check_variable(varname, global_dict.pop(varname))
- try:
- delattr(default_config, varname)
- except AttributeError:
- pass
+ clear_check_variable_names(cmk_base.checks.check_variable_names())
#.