Module: check_mk
Branch: master
Commit: e4e8149cbcd49f76b24d1c3148371cfaf3824b67
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e4e8149cbcd49f…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Apr 15 22:54:07 2019 +0200
Cleanup all direct config.is_no_ip_host calls
Change-Id: I48168b9ab43b362399183aaf106617ece9829c0e
---
cmk_base/config.py | 10 ----------
cmk_base/core_config.py | 14 +++++++-------
cmk_base/core_nagios.py | 2 +-
cmk_base/ip_lookup.py | 4 +++-
tests/unit/cmk_base/test_config.py | 1 -
5 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/cmk_base/config.py b/cmk_base/config.py
index e46dd33..748c64f 100644
--- a/cmk_base/config.py
+++ b/cmk_base/config.py
@@ -829,16 +829,6 @@ def parents_of(hostname):
#
-# IPv4/IPv6
-#
-
-
-# TODO: Replace call sites with HostConfig access and remove this
-def is_no_ip_host(hostname):
- return get_config_cache().get_host_config(hostname).is_no_ip_host
-
-
-#
# Management board
#
diff --git a/cmk_base/core_config.py b/cmk_base/core_config.py
index f41f1c9..be57b96 100644
--- a/cmk_base/core_config.py
+++ b/cmk_base/core_config.py
@@ -95,16 +95,16 @@ def get_configuration_warnings():
# TODO: Cleanup the hostcheck_commands_to_define, custom_commands_to_define thing
def host_check_command(config_cache,
- hostname,
+ host_config,
ip,
is_clust,
hostcheck_commands_to_define=None,
custom_commands_to_define=None):
# Check dedicated host check command
- values = config_cache.host_extra_conf(hostname, config.host_check_commands)
+ values = config_cache.host_extra_conf(host_config.hostname,
config.host_check_commands)
if values:
value = values[0]
- elif config.is_no_ip_host(hostname):
+ elif host_config.is_no_ip_host:
value = "ok"
elif config.monitoring_core == "cmc":
value = "smart"
@@ -118,7 +118,7 @@ def host_check_command(config_cache,
return "check-mk-host-smart"
elif value in ["ping", "smart"]: # Cluster host
- ping_args = check_icmp_arguments_of(config_cache, hostname)
+ ping_args = check_icmp_arguments_of(config_cache, host_config.hostname)
if is_clust and ip: # Do check cluster IP address if one is there
return "check-mk-host-ping!%s" % ping_args
@@ -141,8 +141,8 @@ def host_check_command(config_cache,
command = "check-mk-host-custom-%d" %
(len(hostcheck_commands_to_define) + 1)
hostcheck_commands_to_define.append(
(command, 'echo "$SERVICEOUTPUT:%s:%s$" && exit
$SERVICESTATEID:%s:%s$' %
- (hostname, service.replace('$HOSTNAME$', hostname), hostname,
- service.replace('$HOSTNAME$', hostname))))
+ (host_config.hostname, service.replace('$HOSTNAME$',
host_config.hostname),
+ host_config.hostname, service.replace('$HOSTNAME$',
host_config.hostname))))
return command
elif value[0] == "tcp":
@@ -156,7 +156,7 @@ def host_check_command(config_cache,
return "check-mk-custom!" + autodetect_plugin(value[1])
raise MKGeneralException(
- "Invalid value %r for host_check_command of host %s." % (value,
hostname))
+ "Invalid value %r for host_check_command of host %s." % (value,
host_config.hostname))
def autodetect_plugin(command_line):
diff --git a/cmk_base/core_nagios.py b/cmk_base/core_nagios.py
index 1ca279e..38be483 100644
--- a/cmk_base/core_nagios.py
+++ b/cmk_base/core_nagios.py
@@ -202,7 +202,7 @@ def _create_nagios_hostdefs(cfg, config_cache, hostname, attrs):
host_spec[key] = value
# Host check command might differ from default
- command = core_config.host_check_command(config_cache, hostname, ip, is_clust,
+ command = core_config.host_check_command(config_cache, host_config, ip, is_clust,
cfg.hostcheck_commands_to_define,
cfg.custom_commands_to_define)
if command:
diff --git a/cmk_base/ip_lookup.py b/cmk_base/ip_lookup.py
index 16fa58a..f90aede 100644
--- a/cmk_base/ip_lookup.py
+++ b/cmk_base/ip_lookup.py
@@ -123,7 +123,9 @@ def cached_dns_lookup(hostname, family):
cache[cache_id] = cached_ip
return cached_ip
- if config.is_no_ip_host(hostname):
+ host_config = config.get_config_cache().get_host_config(hostname)
+
+ if host_config.is_no_ip_host:
cache[cache_id] = None
return None
diff --git a/tests/unit/cmk_base/test_config.py b/tests/unit/cmk_base/test_config.py
index 9aac531..8bcc5af 100644
--- a/tests/unit/cmk_base/test_config.py
+++ b/tests/unit/cmk_base/test_config.py
@@ -83,7 +83,6 @@ def test_is_piggyback_host_auto(monkeypatch, hostname, tags, with_data,
result):
])
def test_is_no_ip_host(monkeypatch, hostname, tags, result):
config_cache = _setup_host(monkeypatch, hostname, tags)
- assert config.is_no_ip_host(hostname) == result
assert config_cache.get_host_config(hostname).is_no_ip_host == result