Module: check_mk
Branch: master
Commit: 910b85e3e797a41c2bc8ddcff35ba38ed8e7a541
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=910b85e3e797a4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Sat May 26 18:32:56 2018 +0200
6178 Add inventory views for docker images and containers
There are several new inventory based views available which are based
on the inventory (and structured status) data of docker nodes. They
show docker images and docker containers.
Change-Id: Id7f3928b8651909f3df689ff3e1f7f8fc158d956
---
.werks/6178 | 13 +++++++++++++
web/plugins/views/inventory.py | 32 ++++++++++++++++++++++++--------
2 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/.werks/6178 b/.werks/6178
new file mode 100644
index 0000000..5161949
--- /dev/null
+++ b/.werks/6178
@@ -0,0 +1,13 @@
+Title: Add inventory views for docker images and containers
+Level: 1
+Component: inv
+Class: feature
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1527352293
+
+There are several new inventory based views available which are based
+on the inventory (and structured status) data of docker nodes. They
+show docker images and docker containers.
diff --git a/web/plugins/views/inventory.py b/web/plugins/views/inventory.py
index da26d3d..e2e526f 100644
--- a/web/plugins/views/inventory.py
+++ b/web/plugins/views/inventory.py
@@ -773,6 +773,7 @@ inventory_displayhints.update({
".software.applications.docker.images:": {
"title" : _("Images"),
"keyorder": ["repository", "tag", "id", "creation", "size", "labels", "amount_containers"],
+ "view" : "invdockerimages_of_host",
},
".software.applications.docker.images:*.id" : { "title" : _("ID"), },
".software.applications.docker.images:*.amount_containers" : { "title" : _("# Containers"), },
@@ -1053,12 +1054,16 @@ def inv_multisite_table(infoname, invpath, columns, add_headers, only_sites, lim
rows.append(subrow)
return rows
-# Find the name of all columns of an embedded table that have a display
-# hint. Respects the order of the columns if one is specified in the
-# display hint:
def inv_find_subtable_columns(invpath):
+ """Find the name of all columns of an embedded table that have a display
+ hint. Respects the order of the columns if one is specified in the
+ display hint.
+
+ Also use the names found in keyorder to get even more of the available columns."""
+ subtable_hint = inventory_displayhints[invpath]
+
# Create dict from column name to its order number in the list
- with_numbers = enumerate(inventory_displayhints[invpath].get("keyorder", []))
+ with_numbers = enumerate(subtable_hint.get("keyorder", []))
swapped = map(lambda t: (t[1], t[0]), with_numbers)
order = dict(swapped)
@@ -1068,13 +1073,19 @@ def inv_find_subtable_columns(invpath):
# ".networking.interfaces:*.port_type" -> "port_type"
columns.append(path.split(".")[-1])
+ for key in subtable_hint.get("keyorder", []):
+ if key not in columns:
+ columns.append(key)
+
columns.sort(cmp = lambda a,b: cmp(order.get(a, 999), order.get(b, 999)) or cmp(a,b))
return columns
def declare_invtable_columns(infoname, invpath, topic):
for name in inv_find_subtable_columns(invpath):
- hint = inventory_displayhints.get(invpath + "*." + name, {})
+ sub_invpath = invpath + "*." + name
+ hint = inventory_displayhints.get(sub_invpath, {})
+
sortfunc = hint.get("sort", cmp)
if "paint" in hint:
paint_name = hint["paint"]
@@ -1094,8 +1105,10 @@ def declare_invtable_columns(infoname, invpath, topic):
else:
filter_class = visuals.FilterInvtableIDRange
- declare_invtable_column(infoname, name, topic, hint["title"],
- hint.get("short", hint["title"]), sortfunc, paint_function, filter_class)
+ title = inv_titleinfo(sub_invpath, None)[1]
+
+ declare_invtable_column(infoname, name, topic, title,
+ hint.get("short", title), sortfunc, paint_function, filter_class)
def declare_invtable_column(infoname, name, topic, title, short_title,
@@ -1248,11 +1261,14 @@ def _create_view_enabled_check_func(invpath):
declare_invtable_view("invswpac", ".software.packages:", _("Software package"), _("Software packages"))
declare_invtable_view("invinterface", ".networking.interfaces:", _("Network interface"), _("Network interfaces"))
+declare_invtable_view("invdockerimages", ".software.applications.docker.images:", _("Docker images"), _("Docker images"))
+declare_invtable_view("invdockercontainers", ".software.applications.docker.containers:", _("Docker containers"), _("Docker containers"))
+
declare_invtable_view("invother", ".hardware.components.others:", _("Other entity"), _("Other entities"))
declare_invtable_view("invunknown", ".hardware.components.unknowns:", _("Unknown entity"), _("Unknown entities"))
declare_invtable_view("invchassis", ".hardware.components.chassis:", _("Chassis"), _("Chassis"))
declare_invtable_view("invbackplane", ".hardware.components.backplanes:", _("Backplane"), _("Backplanes"))
-declare_invtable_view("invcontainer", ".hardware.components.containers:", _("Container"), _("Containers"))
+declare_invtable_view("invcontainer", ".hardware.components.containers:", _("HW container"), _("HW containers"))
declare_invtable_view("invpsu", ".hardware.components.psus:", _("Power supply"), _("Power supplies"))
declare_invtable_view("invfan", ".hardware.components.fans:", _("Fan"), _("Fans"))
declare_invtable_view("invsensor", ".hardware.components.sensors:", _("Sensor"), _("Sensors"))
Module: check_mk
Branch: master
Commit: 83d47f49aa605b1ac51f6da3c98fc8bbb17c135b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=83d47f49aa605b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon May 28 07:52:33 2018 +0200
Inventory: Attributes can now have a keyorder
Change-Id: I4bab97fc6a5c9d2f41ecccb5305ddacdc6adbf3c
---
web/plugins/views/inventory.py | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/web/plugins/views/inventory.py b/web/plugins/views/inventory.py
index 6f223db..3268f69 100644
--- a/web/plugins/views/inventory.py
+++ b/web/plugins/views/inventory.py
@@ -1754,8 +1754,24 @@ class NodeRenderer(object):
def show_attributes(self, attributes, path=None):
invpath = ".%s" % self._get_raw_path(path)
+ hint = _inv_display_hint(invpath)
+
+ def _sort_attributes(item):
+ """Sort the attributes by the configured key order. In case no key order
+ is given sort by the key. In case there is a key order and a key is not
+ in the list, put it at the end and sort all of those by key."""
+ key = item[0]
+ keyorder = hint.get("keyorder")
+ if not keyorder:
+ return key
+
+ try:
+ return keyorder.index(key)
+ except ValueError:
+ return len(keyorder) + 1, key
+
html.open_table()
- for key, value in attributes.get_child_data().iteritems():
+ for key, value in sorted(attributes.get_child_data().iteritems(), key=_sort_attributes):
sub_invpath = "%s.%s" % (invpath, key)
icon, title = inv_titleinfo(sub_invpath, key)
hint = _inv_display_hint(sub_invpath)
Module: check_mk
Branch: master
Commit: aa1e61093accbed362b33794fef715baa9b2242a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=aa1e61093accbe…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Sat May 26 20:56:55 2018 +0200
Inventory: Fixed merging of Numerations
When two structured data trees are merged while there is no key
intersection found, e.g. because there are no entries in the Numeration
in the origin tree, then the merged tree contained only one item of the
Numeration.
Change-Id: Idaa1995c602cbef83355b08f453e77c935a776e3
---
cmk/structured_data.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/cmk/structured_data.py b/cmk/structured_data.py
index ce1d56a..b6cfde5 100644
--- a/cmk/structured_data.py
+++ b/cmk/structured_data.py
@@ -896,13 +896,24 @@ class Numeration(Leaf):
foreign_keys = foreign._get_numeration_keys()
my_keys = self._get_numeration_keys()
intersect_keys = my_keys.intersection(foreign_keys)
+
+ # In case there is no intersection, append all foreign rows without
+ # merging with own rows
+ if not intersect_keys:
+ self._numeration += foreign._numeration
+ return
+
+ # Try to match rows of both trees based on the keys that are found in
+ # both. Matching rows are updated. Others are appended.
foreign_num = {foreign._prepare_key(entry, intersect_keys): entry
for entry in foreign._numeration}
+
for entry in self._numeration:
key = self._prepare_key(entry, intersect_keys)
if key in foreign_num:
entry.update(foreign_num[key])
del foreign_num[key]
+
self._numeration += foreign_num.values()