Module: check_mk
Branch: master
Commit: bb405766fdec85d271061844ab9587b29ef387ed
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bb405766fdec85…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Apr 24 10:36:47 2018 +0200
5992 FIX HW/SW Inventory: Fixed AttributeError if any plugin provides wrong data
structure
Change-Id: I00f4176cc865f17096526ba18d41525220189f4b
---
.werks/5992 | 10 ++++++++++
cmk/structured_data.py | 23 ++++++++++++++++-------
2 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/.werks/5992 b/.werks/5992
new file mode 100644
index 0000000..cd7f7f9
--- /dev/null
+++ b/.werks/5992
@@ -0,0 +1,10 @@
+Title: HW/SW Inventory: Fixed AttributeError if any plugin provides wrong data structure
+Level: 1
+Component: multisite
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1524558923
+Class: fix
+
+
diff --git a/cmk/structured_data.py b/cmk/structured_data.py
index cdfd557..209e4fe 100644
--- a/cmk/structured_data.py
+++ b/cmk/structured_data.py
@@ -207,13 +207,14 @@ class StructuredDataTree(object):
def _is_numeration(self, entries):
for entry in entries:
- #TODO Skipping invalid entries such as
- # esx_vsphere_clusters: {u'hostsystems': [LIST OF STRINGS], ...}
- #if not isinstance(entry, dict):
- # continue
- for k, v in entry.iteritems():
- if isinstance(v, list):
- return False
+ # Skipping invalid entries such as
+ # {u'KEY': [LIST OF STRINGS], ...}
+ try:
+ for k, v in entry.iteritems():
+ if isinstance(v, list):
+ return False
+ except AttributeError:
+ return False
return True
# ---delegators-----------------------------------------------------------
@@ -301,6 +302,10 @@ class StructuredDataTree(object):
# Just for testing
return self._root.get_tree_repr()
+
+ def __repr__(self):
+ return "%s(%s)" % (self.__class__.__name__,
pprint.pformat(self.get_raw_tree()))
+
# ---web------------------------------------------------------------------
def show(self, renderer, path=None):
@@ -362,6 +367,10 @@ class NodeAttribute(object):
# Just for testing
raise NotImplementedError()
+
+ def __repr__(self):
+ return "%s(%s)" % (self.__class__.__name__,
pprint.pformat(self.get_raw_tree()))
+
# ---web------------------------------------------------------------------
def show(self, renderer, path=None):