Module: check_mk
Branch: master
Commit: 8cc56434dcfa5035aa457ecfc3bc763906e92adc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8cc56434dcfa50…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Tue Feb 12 14:11:06 2019 +0100
docker_node_network: bug fix
also fix missing import and add some cosmetic changes along the way
Change-Id: I04599bc4f7bd80ad9cda3374b88e821d218ecd5c
---
checks/legacy_docker.include | 13 ++++++------
inventory/docker_node_network | 4 ++--
tests/unit/checks/test_docker_parse_node_images.py | 24 +++++++++++++++-------
3 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/checks/legacy_docker.include b/checks/legacy_docker.include
index 0ee07b6..0273d59 100644
--- a/checks/legacy_docker.include
+++ b/checks/legacy_docker.include
@@ -25,6 +25,7 @@
# Boston, MA 02110-1301 USA.
import json
import re
+import functools
class DeprecatedDict(dict):
@@ -118,7 +119,7 @@ def _get_repo_tag(string):
return string, "latest"
-def parse_legacy_docker_node_info(info):
+def parse_legacy_docker_node_info(info): # pylint: disable=too-many-branches
'''parse output of "docker info"'''
parsed = DeprecatedDict()
if not info:
@@ -199,9 +200,9 @@ def _legacy_docker_parse_table(rows, fields, keys):
indices = []
for field in fields:
rex = regex(field + r'\ *')
- m = rex.search(rows[0][0])
- if m is not None:
- start, end = m.start(), m.end()
+ match = rex.search(rows[0][0])
+ if match is not None:
+ start, end = match.start(), match.end()
if end - start == len(field):
end = None
indices.append((start, end))
@@ -222,8 +223,8 @@ def _legacy_docker_parse_table(rows, fields, keys):
def parse_legacy_docker_system_df(info):
- def int_or_zero(s):
- return int(s.strip() or 0)
+ def int_or_zero(string):
+ return int(string.strip() or 0)
field_map = (
('TYPE', 'TOTAL', 'ACTIVE', 'SIZE',
'RECLAIMABLE'),
diff --git a/inventory/docker_node_network b/inventory/docker_node_network
index bdf19c2..6b076dd 100644
--- a/inventory/docker_node_network
+++ b/inventory/docker_node_network
@@ -64,11 +64,11 @@ def inv_docker_node_network_networks(info, inventory_tree,
status_data_tree):
}
try:
- network["host_ifname"] =
network["Options"]["com.docker.network.bridge.name"]
+ network_["host_ifname"] =
network["Options"]["com.docker.network.bridge.name"]
except KeyError:
pass
- labels = docker_format_labels(network)
+ labels = docker_format_labels(network) # pylint: disable=undefined-variable
if labels:
network_["labels"] = labels
inventory_networks.update(network_)
diff --git a/tests/unit/checks/test_docker_parse_node_images.py
b/tests/unit/checks/test_docker_parse_node_images.py
index e982749..e208470 100644
--- a/tests/unit/checks/test_docker_parse_node_images.py
+++ b/tests/unit/checks/test_docker_parse_node_images.py
@@ -1,7 +1,10 @@
# *--encoding: UTF-8--*
-import pytest
+# pylint: disable=too-many-lines
+# pylint: disable=line-too-long
+# pylint: disable=invalid-name
import os
import re
+import pytest
pytestmark = pytest.mark.checks
@@ -11,16 +14,23 @@ execfile(os.path.join(os.path.dirname(__file__),
'../../../checks/legacy_docker.
REQUIRED_IMAGE_KEYS = (
- ("ID", (str, unicode)), ("Repository", (str, unicode)),
- ("Tag",(str, unicode)), ("CreatedAt", (str, unicode)),
- ("VirtualSize", int), ("Labels", dict),
("amount_containers", int),
+ ("ID", (str, unicode)),
+ ("Repository", (str, unicode)),
+ ("Tag", (str, unicode)),
+ ("CreatedAt", (str, unicode)),
+ ("VirtualSize", int),
+ ("Labels", dict),
+ ("amount_containers", int),
)
REQUIRED_CONTAINER_KEYS = (
- ("ID", (str, unicode)), ("Repository", (str, unicode)),
- ("Tag", (str, unicode)), ("CreatedAt", (str, unicode)),
- ("Labels", dict), ("Names", (str, unicode)),
+ ("ID", (str, unicode)),
+ ("Repository", (str, unicode)),
+ ("Tag", (str, unicode)),
+ ("CreatedAt", (str, unicode)),
+ ("Labels", dict),
+ ("Names", (str, unicode)),
("Status", (str, unicode)),
)