Module: check_mk
Branch: master
Commit: ef6578b1f556d15a947751930caa9e508fa56754
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ef6578b1f556d1…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Mon Sep 24 09:43:45 2018 +0200
6468 FIX docker_node_network: Fix crashing HW/SW inventory when labels are not set
Change-Id: I6024cad3c1d36a0a5b5432ecfb6ccc64758f4747
---
.werks/6468 | 11 +++++++++++
inventory/docker_node_network | 6 ++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/.werks/6468 b/.werks/6468
new file mode 100644
index 0000000..2f74612
--- /dev/null
+++ b/.werks/6468
@@ -0,0 +1,11 @@
+Title: docker_node_network: Fix crashing HW/SW inventory when labels are not set
+Level: 1
+Component: inv
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1537774944
+
+
diff --git a/inventory/docker_node_network b/inventory/docker_node_network
index 90e45f7..fe610d4 100644
--- a/inventory/docker_node_network
+++ b/inventory/docker_node_network
@@ -37,7 +37,7 @@ def inv_docker_node_network_networks(info, inventory_tree,
status_data_tree):
status_networks =
status_data_tree.get_dict("software.applications.docker.networks.")
for network in parsed:
- labels = sorted(["%s: %s" % (k,v) for k,v in
network["Labels"].items()])
+ labels = sorted(["%s: %s" % (k,v) for k,v in
network.get("Labels", {}).items()])
containers = []
for container_id, container in network["Containers"].items():
@@ -57,11 +57,13 @@ def inv_docker_node_network_networks(info, inventory_tree,
status_data_tree):
inventory_networks[network["Name"]] = {
"name" : network["Name"],
"host_ifname" :
network["Options"]["com.docker.network.bridge.name"],
- "labels" : ", ".join(labels),
"network_id" : network["Id"][:12],
"scope" : network["Scope"],
}
+ if labels:
+ inventory_networks[network["Name"]]["labels"] = ",
".join(labels)
+
inv_info["docker_node_network.networks"] = {
"inv_function": inv_docker_node_network_networks,