Module: check_mk
Branch: master
Commit: 76944178e36a5daa7d4ca03e3ee47b85e33495f6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=76944178e36a5d…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Apr 25 09:52:46 2019 +0200
Cleanup redundant host_extra_conf related logic
CMK-2030
Change-Id: Id2c41325574ccc5bcfe8158c8c4fde6902ce3e04
---
cmk_base/core_nagios.py | 28 +++++++---------------------
1 file changed, 7 insertions(+), 21 deletions(-)
diff --git a/cmk_base/core_nagios.py b/cmk_base/core_nagios.py
index dc96647..9865bc1 100644
--- a/cmk_base/core_nagios.py
+++ b/cmk_base/core_nagios.py
@@ -235,9 +235,11 @@ def _create_nagios_host_spec(cfg, config_cache, hostname, attrs):
host_spec["parents"] = ",".join(nodes)
# Custom configuration last -> user may override all other values
- host_spec.update(
- _extra_host_conf_of(
- config_cache, hostname, exclude=["parents"] if
host_config.is_cluster else []))
+ # TODO: Find a generic mechanism for CMC and Nagios
+ for key, value in host_config.extra_host_attributes.iteritems():
+ if host_config.is_cluster and key == "parents":
+ continue
+ host_spec[key] = value
return host_spec
@@ -821,12 +823,6 @@ def _quote_nagios_string(s):
return "'" + s.replace('\\',
'\\\\').replace("'",
"'\"'\"'").replace('!', '\\!') +
"'"
-def _extra_host_conf_of(config_cache, hostname, exclude=None):
- if exclude is None:
- exclude = []
- return _extra_conf_of(config_cache, config.extra_host_conf, hostname, None, exclude)
-
-
# Collect all extra configuration data for a service
def _extra_service_conf_of(cfg, config_cache, hostname, description):
service_spec = {}
@@ -850,20 +846,10 @@ def _extra_service_conf_of(cfg, config_cache, hostname,
description):
return service_spec
-def _extra_conf_of(config_cache, confdict, hostname, service, exclude=None):
- if exclude is None:
- exclude = []
-
+def _extra_conf_of(config_cache, confdict, hostname, service):
result = {}
for key, conflist in confdict.items():
- if service is not None:
- values = config_cache.service_extra_conf(hostname, service, conflist)
- else:
- values = config_cache.host_extra_conf(hostname, conflist)
-
- if exclude and key in exclude:
- continue
-
+ values = config_cache.service_extra_conf(hostname, service, conflist)
if values:
result[key] = values[0]