Module: check_mk
Branch: master
Commit: 004791e564d909bd05d4ba18ab4c7577b9d11708
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=004791e564d909…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Dec 15 11:51:01 2016 +0100
4141 FIX Fixed possible exception in web cron: argument of type 'NoneType' is not
iterable (g_host_attribute)
Change-Id: Ieb9b9e9b8219983097aa3316ce7e116e97e3524e
---
.werks/4141 | 9 +++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 16 ++++++++--------
web/htdocs/watolib.py | 30 ++++++++++++++++++++----------
4 files changed, 38 insertions(+), 18 deletions(-)
diff --git a/.werks/4141 b/.werks/4141
new file mode 100644
index 0000000..56188ec
--- /dev/null
+++ b/.werks/4141
@@ -0,0 +1,9 @@
+Title: Fixed possible exception in web cron: argument of type 'NoneType' is not
iterable (g_host_attribute)
+Level: 1
+Component: wato
+Compatible: compat
+Version: 1.4.0i3
+Date: 1481799024
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 79fe8bb..62ba1e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -129,6 +129,7 @@
* 4133 FIX: Do not suppress site specific global issues during WATO activation
* 4134 FIX: Unified ineffective rulesets view with other ruleset list views
* 3999 FIX: Added core restart note to bulk host rename page
+ * 4141 FIX: Fixed possible exception in web cron: argument of type 'NoneType'
is not iterable (g_host_attribute)
* 4150 FIX: Avoid exception in host search when searching for empty texts
Notifications:
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 5cbadf4..65a374a 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -14447,7 +14447,7 @@ def save_changed_custom_attrs(all_attrs, what):
def declare_custom_host_attrs():
# First remove all previously registered custom host attributes
- for attr_name in g_host_attribute.keys():
+ for attr_name in all_host_attribute_names():
if attr_name not in builtin_host_attribute_names and not\
attr_name.startswith("tag_"):
undeclare_host_attribute(attr_name)
@@ -16350,14 +16350,13 @@ loaded_with_language = False
def load_plugins(force):
global builtin_host_attribute_names
- # Do not cache the custom attributes. They can be created by the user
- # during runtime, means they need to be loaded during each page request.
- # But delete the old definitions before to also apply removals of attributes
- if builtin_host_attribute_names:
- declare_custom_host_attrs()
-
global loaded_with_language
if loaded_with_language == current_language and not force:
+ # Do not cache the custom attributes. They can be created by the user
+ # during runtime, means they need to be loaded during each page request.
+ # But delete the old definitions before to also apply removals of attributes
+ if builtin_host_attribute_names:
+ declare_custom_host_attrs()
return
# Reset global vars
@@ -16365,6 +16364,7 @@ def load_plugins(force):
extra_buttons = []
modules = []
+ initialize_host_attribute_structures()
undeclare_all_host_attributes()
load_notification_table()
initialize_global_configvars()
@@ -16620,7 +16620,7 @@ def load_plugins(force):
declare_host_tag_attributes(force = True)
- builtin_host_attribute_names = g_host_attribute.keys()
+ builtin_host_attribute_names = all_host_attribute_names()
declare_custom_host_attrs()
# This must be set after plugin loading to make broken plugins raise
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index a41460c..f47438a 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -65,9 +65,11 @@ replication_paths = []
backup_paths = []
backup_domains = {}
automation_commands = {}
+g_rulespecs = None
def initialize_before_loading_plugins():
- g_rulespecs.clear()
+ if g_rulespecs:
+ g_rulespecs.clear()
# Directories and files to synchronize during replication
global replication_paths
@@ -2918,16 +2920,20 @@ class ContactGroupsAttribute(Attribute):
return True
-# Global datastructure holding all attributes (in a defined order)
-# as pairs of (attr, topic). Topic is the title under which the
-# attribute is being displayed. All builtin attributes use the
-# topic None. As long as only one topic is used, no topics will
-# be displayed. They are useful if you have a great number of
-# custom attributes.
-g_host_attributes = []
+def initialize_host_attribute_structures():
+ global g_host_attributes, g_host_attribute
+
+ # Global datastructure holding all attributes (in a defined order)
+ # as pairs of (attr, topic). Topic is the title under which the
+ # attribute is being displayed. All builtin attributes use the
+ # topic None. As long as only one topic is used, no topics will
+ # be displayed. They are useful if you have a great number of
+ # custom attributes.
+ g_host_attributes = []
+
+ # Dictionary for quick access
+ g_host_attribute = {}
-# Dictionary for quick access
-g_host_attribute = {}
# Declare attributes with this method
def declare_host_attribute(a, show_in_table = True, show_in_folder = True,
show_in_host_search = True,
@@ -2971,6 +2977,10 @@ def all_host_attributes():
return g_host_attributes
+def all_host_attribute_names():
+ return g_host_attribute.keys()
+
+
def host_attribute(name):
return g_host_attribute[name]