Module: check_mk
Branch: master
Commit: 7cf365e365a95a31759d52aa1dd852b44ccb47fe
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7cf365e365a95a…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed May 2 12:43:52 2018 +0200
5996 FIX Fixed lookup of management protocol and credentials
If a host has configured a SNMP management board in Check_MK
version 1.4.0 and the site was upgraded to 1.5.0 or later versions,
then the SNMP management board protocol and credentials were not
found. Fixed that!
Change-Id: Ica7446639b802c0924d5f3740007723a2291c838
---
.werks/5996 | 13 +++++++++++++
cmk_base/config.py | 21 +++++++++++++++++++++
web/htdocs/watolib.py | 4 ++--
3 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/.werks/5996 b/.werks/5996
new file mode 100644
index 0000000..9e250ad
--- /dev/null
+++ b/.werks/5996
@@ -0,0 +1,13 @@
+Title: Fixed lookup of management protocol and credentials
+Level: 1
+Component: wato
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1525257689
+Class: fix
+
+If a host has configured a SNMP management board in Check_MK
+version 1.4.0 and the site was upgraded to 1.5.0 or later versions,
+then the SNMP management board protocol and credentials were not
+found. Fixed that!
diff --git a/cmk_base/config.py b/cmk_base/config.py
index 5b297c4..43df660 100644
--- a/cmk_base/config.py
+++ b/cmk_base/config.py
@@ -126,6 +126,8 @@ def load(with_conf_d=True, validate_hosts=True,
exclude_parents_mk=False):
_load_config(with_conf_d, exclude_parents_mk)
+ _transform_mgmt_config_vars_from_140_to_150()
+
initialize_config_caches()
initialize_service_levels()
@@ -196,6 +198,21 @@ def _load_config(with_conf_d, exclude_parents_mk):
del global_dict[helper_var]
+def _transform_mgmt_config_vars_from_140_to_150():
+ #FIXME We have to transform some configuration variables from host attributes
+ # to cmk_base configuration variables because during the migration step from
+ # 1.4.0 to 1.5.0 some config variables are not known in cmk_base. These variables
+ # are 'management_protocol' and 'management_snmp_community'.
+ # Clean this up one day!
+ for hostname, attributes in host_attributes.iteritems():
+ for name, var in [
+ ('management_protocol', management_protocol),
+ ('management_snmp_community', management_snmp_credentials),
+ ]:
+ if attributes.get(name):
+ var.setdefault(hostname, attributes[name])
+
+
# Create list of all files to be included during configuration loading
def _get_config_file_paths(with_conf_d):
if with_conf_d:
@@ -594,6 +611,10 @@ def alias_of(hostname, fallback):
def get_additional_ipaddresses_of(hostname):
+ #TODO Regarding the following configuration variables from WATO
+ # there's no inheritance, thus we use 'host_attributes'.
+ # Better would be to use cmk_base configuration variables,
+ # eg. like 'management_protocol'.
return (host_attributes.get(hostname, {}).get("additional_ipv4addresses",
[]),
host_attributes.get(hostname, {}).get("additional_ipv6addresses",
[]))
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 25adefe..a99f7d0 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -1465,9 +1465,9 @@ class CREFolder(BaseFolder):
("ipaddress", "ipaddresses", {},
"Explicit IPv4 addresses"),
("ipv6address", "ipv6addresses", {},
"Explicit IPv6 addresses"),
("snmp_community", "explicit_snmp_communities", {},
"Explicit SNMP communities"),
- ("management_snmp_community",
"management_snmp_credentials", {}, "Management board SNMP
credentials"),
+ ("management_snmp_community",
"management_snmp_credentials", {}, "Management board SNMP
credentials"),
("management_ipmi_credentials",
"management_ipmi_credentials", {}, "Management board IPMI
credentials"),
- ("management_protocol", "management_protocol",
{}, "Management board protocol"),
+ ("management_protocol", "management_protocol",
{}, "Management board protocol"),
]
for hostname in hostnames: