Skip to content
Permalink
Browse files

Cleanup all direct config.is_ipv4_host calls

Change-Id: I9fec414de54a4b90be974cea7aaa288a80fbb069
  • Loading branch information
LarsMichelsen committed Apr 15, 2019
1 parent 6e270d6 commit a6ea57cb619bfe36c849eed8b64f1c16ec253d06
Showing with 5 additions and 11 deletions.
  1. +0 −5 cmk_base/config.py
  2. +2 −2 cmk_base/core_config.py
  3. +3 −3 cmk_base/core_nagios.py
  4. +0 −1 tests/unit/cmk_base/test_config.py
@@ -833,11 +833,6 @@ def parents_of(hostname):
#


# TODO: Replace call sites with HostConfig access and remove this
def is_ipv4_host(hostname):
return get_config_cache().get_host_config(hostname).is_ipv4_host


# 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
@@ -406,7 +406,7 @@ def get_host_attributes(hostname, config_cache):
attrs["alias"] = config.alias_of(hostname, hostname)

# Now lookup configured IP addresses
if config.is_ipv4_host(hostname):
if host_config.is_ipv4_host:
attrs["_ADDRESS_4"] = _ip_address_of(host_config, 4)
if attrs["_ADDRESS_4"] is None:
attrs["_ADDRESS_4"] = ""
@@ -482,7 +482,7 @@ def get_cluster_attributes(config_cache, host_config, nodes):
"_NODENAMES": " ".join(sorted_nodes),
}
node_ips_4 = []
if config.is_ipv4_host(host_config.hostname):
if host_config.is_ipv4_host:
for h in sorted_nodes:
node_config = config_cache.get_host_config(h)
addr = _ip_address_of(node_config, 4)
@@ -1122,14 +1122,14 @@ def _precompile_hostcheck(config_cache, hostname):
if config.is_cluster(hostname):
for node in config.nodes_of(hostname):
node_config = config_cache.get_host_config(node)
if config.is_ipv4_host(node):
if node_config.is_ipv4_host:
needed_ipaddresses[node] = ip_lookup.lookup_ipv4_address(node)

if node_config.is_ipv6_host:
needed_ipv6addresses[node] = ip_lookup.lookup_ipv6_address(node)

try:
if config.is_ipv4_host(hostname):
if host_config.is_ipv4_host:
needed_ipaddresses[hostname] = ip_lookup.lookup_ipv4_address(hostname)
except:
pass
@@ -1140,7 +1140,7 @@ def _precompile_hostcheck(config_cache, hostname):
except:
pass
else:
if config.is_ipv4_host(hostname):
if host_config.is_ipv4_host:
needed_ipaddresses[hostname] = ip_lookup.lookup_ipv4_address(hostname)

if host_config.is_ipv6_host:
@@ -24,7 +24,6 @@ def clear_config_caches(monkeypatch):
])
def test_is_ipv4_host(monkeypatch, hostname, tags, result):
config_cache = _setup_host(monkeypatch, hostname, tags)
assert config.is_ipv4_host(hostname) == result
assert config_cache.get_host_config(hostname).is_ipv4_host == result


0 comments on commit a6ea57c

Please sign in to comment.
You can’t perform that action at this time.