Module: check_mk
Branch: master
Commit: e0629fe6b6308516cf223585a4c63c181c3d74e5
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e0629fe6b63085…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed May 9 09:42:23 2018 +0200
6060 FIX Clusters: Add missing custom variable containing the node names
In addition to the existing custom attributes _NODEIPS, _NODEIPS_4 and
_NODEIPS_6 this change adds a new variable _NODENAMES. All the entries
in this variables are now sorted by the node name. This means that e.g.
the 2nd entry in all of the above variables belongs to the same node.
Change-Id: Ie8d4ffeadd50397666fe6eca6327bf0a54c265d1
---
.werks/6060 | 14 ++++++++++++++
cmk_base/core_config.py | 12 +++++++++---
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/.werks/6060 b/.werks/6060
new file mode 100644
index 0000000..07f0f0f
--- /dev/null
+++ b/.werks/6060
@@ -0,0 +1,14 @@
+Title: Clusters: Add missing custom variable containing the node names
+Level: 1
+Component: core
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1525851596
+
+In addition to the existing custom attributes _NODEIPS, _NODEIPS_4 and
+_NODEIPS_6 this change adds a new variable _NODENAMES. All the entries
+in this variables are now sorted by the node name. This means that e.g.
+the 2nd entry in all of the above variables belongs to the same node.
diff --git a/cmk_base/core_config.py b/cmk_base/core_config.py
index ce7ec8e..2e9621c 100644
--- a/cmk_base/core_config.py
+++ b/cmk_base/core_config.py
@@ -434,10 +434,14 @@ def _extra_host_attributes(hostname):
def get_cluster_attributes(hostname, nodes):
- attrs = {}
+ sorted_nodes = sorted(nodes)
+
+ attrs = {
+ "_NODENAMES": " ".join(sorted_nodes),
+ }
node_ips_4 = []
if config.is_ipv4_host(hostname):
- for h in nodes:
+ for h in sorted_nodes:
addr = ip_address_of(h, 4)
if addr != None:
node_ips_4.append(addr)
@@ -446,7 +450,7 @@ def get_cluster_attributes(hostname, nodes):
node_ips_6 = []
if config.is_ipv6_host(hostname):
- for h in nodes:
+ for h in sorted_nodes:
addr = ip_address_of(h, 6)
if addr != None:
node_ips_6.append(addr)
@@ -461,6 +465,8 @@ def get_cluster_attributes(hostname, nodes):
for suffix, val in [ ("", node_ips), ("_4", node_ips_4),
("_6", node_ips_6) ]:
attrs["_NODEIPS%s" % suffix] = " ".join(val)
+ print attrs
+
return attrs