Module: check_mk
Branch: master
Commit: 7574c607c5a57cb7225708c536a97207a03855ab
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7574c607c5a57c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Apr 4 15:18:19 2019 +0200
Cleaned up config module agent type related global functions
Change-Id: I6f589800c1a924ba90ad2b908968e5a9ed15e1bb
---
cmk_base/config.py | 35 -----------------------------------
cmk_base/core_nagios.py | 6 ++++--
cmk_base/dump_host.py | 4 ++--
tests/unit/cmk_base/test_config.py | 5 -----
4 files changed, 6 insertions(+), 44 deletions(-)
diff --git a/cmk_base/config.py b/cmk_base/config.py
index 3322fb7..f2e092f 100644
--- a/cmk_base/config.py
+++ b/cmk_base/config.py
@@ -820,41 +820,6 @@ def clusters_of(hostname):
#
-# Agent type
-#
-
-
-# TODO: Replace call sites with HostConfig access and remove this
-def is_tcp_host(hostname):
- return get_config_cache().get_host_config(hostname).is_tcp_host
-
-
-# TODO: Replace call sites with HostConfig access and remove this
-def is_ping_host(hostname):
- return get_config_cache().get_host_config(hostname).is_ping_host
-
-
-# TODO: Replace call sites with HostConfig access and remove this
-def is_agent_host(hostname):
- return get_config_cache().get_host_config(hostname).is_agent_host
-
-
-# TODO: Replace call sites with HostConfig access and remove this
-def is_dual_host(hostname):
- return get_config_cache().get_host_config(hostname).is_dual_host
-
-
-# TODO: Replace call sites with HostConfig access and remove this
-def is_all_agents_host(hostname):
- return get_config_cache().get_host_config(hostname).is_all_agents_host
-
-
-# TODO: Replace call sites with HostConfig access and remove this
-def is_all_special_agents_host(hostname):
- return get_config_cache().get_host_config(hostname).is_all_special_agents_host
-
-
-#
# IPv4/IPv6
#
diff --git a/cmk_base/core_nagios.py b/cmk_base/core_nagios.py
index 0abe81d..600b381 100644
--- a/cmk_base/core_nagios.py
+++ b/cmk_base/core_nagios.py
@@ -256,6 +256,8 @@ def _create_nagios_servicedefs(cfg, config_cache, hostname,
host_attrs):
outfile = cfg.outfile
import cmk_base.check_table as check_table
+ host_config = config_cache.get_host_config(hostname)
+
# _____
# |___ /
# |_ \
@@ -411,7 +413,7 @@ def _create_nagios_servicedefs(cfg, config_cache, hostname,
host_attrs):
if entries:
# Skip Check_MK HW/SW Inventory for all ping hosts, even when the user has
enabled
# the inventory for ping only hosts
- if acttype == "cmk_inv" and config.is_ping_host(hostname):
+ if acttype == "cmk_inv" and host_config.is_ping_host:
continue
cfg.active_checks_to_define.add(acttype)
@@ -563,7 +565,7 @@ def _create_nagios_servicedefs(cfg, config_cache, hostname,
host_attrs):
# Inventory checks - if user has configured them.
if params["check_interval"] \
and not config.service_ignored(hostname, None, service_discovery_name) \
- and not config.is_ping_host(hostname):
+ and not host_config.is_ping_host:
service_spec = {
"use": config.inventory_check_template,
"host_name": hostname,
diff --git a/cmk_base/dump_host.py b/cmk_base/dump_host.py
index aa8bb10..7e4067a 100644
--- a/cmk_base/dump_host.py
+++ b/cmk_base/dump_host.py
@@ -40,8 +40,8 @@ import cmk_base.checking as checking
def dump_host(hostname):
-
config_cache = config.get_config_cache()
+ host_config = config_cache.get_host_config(hostname)
console.output("\n")
if config.is_cluster(hostname):
@@ -99,7 +99,7 @@ def dump_host(hostname):
for source in sources.get_data_sources():
agenttypes.append(source.describe())
- if config.is_ping_host(hostname):
+ if host_config.is_ping_host:
agenttypes.append('PING only')
console.output(tty.yellow + "Agent mode: " + tty.normal)
diff --git a/tests/unit/cmk_base/test_config.py b/tests/unit/cmk_base/test_config.py
index 570ed0c..3a65b18 100644
--- a/tests/unit/cmk_base/test_config.py
+++ b/tests/unit/cmk_base/test_config.py
@@ -145,7 +145,6 @@ def test_management_address_of(monkeypatch, attrs, result):
])
def test_is_tcp_host(monkeypatch, hostname, tags, result):
config_cache = _setup_host(monkeypatch, hostname, tags)
- assert config.is_tcp_host(hostname) == result
assert config_cache.get_host_config(hostname).is_tcp_host == result
@@ -161,7 +160,6 @@ def test_is_tcp_host(monkeypatch, hostname, tags, result):
])
def test_is_ping_host(monkeypatch, hostname, tags, result):
config_cache = _setup_host(monkeypatch, hostname, tags)
- assert config.is_ping_host(hostname) == result
assert config_cache.get_host_config(hostname).is_ping_host == result
@@ -203,7 +201,6 @@ def test_is_usewalk_host(monkeypatch):
])
def test_is_dual_host(monkeypatch, hostname, tags, result):
config_cache = _setup_host(monkeypatch, hostname, tags)
- assert config.is_dual_host(hostname) == result
assert config_cache.get_host_config(hostname).is_dual_host == result
@@ -216,7 +213,6 @@ def test_is_dual_host(monkeypatch, hostname, tags, result):
])
def test_is_all_agents_host(monkeypatch, hostname, tags, result):
config_cache = _setup_host(monkeypatch, hostname, tags)
- assert config.is_all_agents_host(hostname) == result
assert config_cache.get_host_config(hostname).is_all_agents_host == result
@@ -229,7 +225,6 @@ def test_is_all_agents_host(monkeypatch, hostname, tags, result):
])
def test_is_all_special_agents_host(monkeypatch, hostname, tags, result):
config_cache = _setup_host(monkeypatch, hostname, tags)
- assert config.is_all_special_agents_host(hostname) == result
assert config_cache.get_host_config(hostname).is_all_special_agents_host == result