Module: check_mk
Branch: master
Commit: b4751f09850c77cc128ab9a09b41fb460d3363ab
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b4751f09850c77…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Jun 14 09:14:41 2018 +0200
Simplified inventory context calculation.
Change-Id: Ib34671688e9e49b7662e21665ff13d950d380ad9
---
cmk_base/inventory.py | 8 ++++----
cmk_base/inventory_plugins.py | 19 ++++++-------------
2 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/cmk_base/inventory.py b/cmk_base/inventory.py
index e394a50..b289df3 100644
--- a/cmk_base/inventory.py
+++ b/cmk_base/inventory.py
@@ -385,7 +385,7 @@ def _run_inventory_export_hooks(hostname, inventory_tree):
# '----------------------------------------------------------------------'
def get_inventory_context():
- return [
- ("inv_tree_list", inv_tree_list),
- ("inv_tree", inv_tree),
- ]
+ return {
+ "inv_tree_list": inv_tree_list,
+ "inv_tree": inv_tree,
+ }
diff --git a/cmk_base/inventory_plugins.py b/cmk_base/inventory_plugins.py
index c9465dd..2b87058 100644
--- a/cmk_base/inventory_plugins.py
+++ b/cmk_base/inventory_plugins.py
@@ -86,14 +86,12 @@ def _new_inv_context(get_inventory_context):
"inv_info" : inv_info,
"inv_export" : inv_export,
}
-
- # Add the inventory plugin and check API
- #
- # For better separation it would be better to copy the check API objects, but
- # this might consume too much memory. So we simply reference it.
- for k, v in check_api._get_check_context() + get_inventory_context():
- context[k] = v
-
+ # NOTE: For better separation it would be better to copy the values, but
+ # this might consume too much memory, so we simply reference them.
+ # NOTE: It is possible that check includes are included, so we need the
+ # usual check context here, too.
+ context.update(checks.new_check_context())
+ context.update(get_inventory_context())
return context
@@ -112,11 +110,6 @@ 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: