Module: check_mk
Branch: master
Commit: 435ac3e8e68947bfd39b41f9af789d556670fc5d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=435ac3e8e68947…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jul 5 13:09:26 2017 +0200
Fixed hw/sw inventory plugins that use check includes
Change-Id: I30313094553479c6061a068a00dfb30665c39819
---
cmk_base/checks.py | 4 ++--
cmk_base/inventory_plugins.py | 5 +++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/cmk_base/checks.py b/cmk_base/checks.py
index 1c578de..c23cbb6 100644
--- a/cmk_base/checks.py
+++ b/cmk_base/checks.py
@@ -115,7 +115,7 @@ def load_checks(filelist):
continue # skip already loaded files (e.g. from local)
try:
- check_context = _new_check_context(f)
+ check_context = new_check_context()
known_vars = check_context.keys()
known_checks = check_info.keys()
@@ -177,7 +177,7 @@ def load_checks(filelist):
# Constructs a new check context dictionary. It contains the whole check API.
-def _new_check_context(check_file_path):
+def new_check_context():
# Add the data structures where the checks register with Check_MK
context = {
"check_info" : check_info,
diff --git a/cmk_base/inventory_plugins.py b/cmk_base/inventory_plugins.py
index 22ccaf5..20118ed 100644
--- a/cmk_base/inventory_plugins.py
+++ b/cmk_base/inventory_plugins.py
@@ -112,6 +112,11 @@ def load_plugin_includes(check_file_path, plugin_context):
if not os.path.exists(include_file_path):
include_file_path = checks.check_include_file_path(include_file_name)
+ # In case a check include file is used the plugin context needs to be
+ # prepared with a check plugin context
+ for key, val in checks.new_check_context().items():
+ plugin_context.setdefault(key, val)
+
try:
execfile(include_file_path, plugin_context)
except Exception, e: