Module: check_mk
Branch: master
Commit: 6d609df4edd0137f39c09dfc2da0421911c12a54
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6d609df4edd013…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Mar 28 08:34:02 2019 +0100
Minor refactoring of lnx_distro inventory plugin
CMK-1818
Change-Id: I4aba64c80d54a53e0764582c04531d97ddc72683
---
inventory/lnx_distro | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/inventory/lnx_distro b/inventory/lnx_distro
index 933e9fa..52269c6 100644
--- a/inventory/lnx_distro
+++ b/inventory/lnx_distro
@@ -44,19 +44,10 @@
# /etc/oracle-release|Oracle LinuxServer release 7.1
-def inv_lnx_distro(info):
- parsed = {}
- filename = None
- for line in info:
- if line[0].startswith("[[[") and line[0].endswith("]]]"):
- filename = line[0][3:-3]
- elif filename is not None:
- parsed.setdefault(filename, line)
- elif filename is None:
- # stay compatible to older versions of output
- parsed.setdefault(line[0], line[1:])
+def inv_lnx_distro(info, inventory_tree):
+ parsed = _parse_lnx_distro(info)
- node = inv_tree("software.os.")
+ node = inventory_tree.get_dict("software.os.")
node["type"] = "Linux"
for file_name, handler in [
("/usr/share/cma/version", inv_lnx_parse_cma),
@@ -73,6 +64,20 @@ def inv_lnx_distro(info):
break
+def _parse_lnx_distro(info):
+ parsed = {}
+ filename = None
+ for line in info:
+ if line[0].startswith("[[[") and line[0].endswith("]]]"):
+ filename = line[0][3:-3]
+ elif filename is not None:
+ parsed.setdefault(filename, line)
+ elif filename is None:
+ # stay compatible to older versions of output
+ parsed.setdefault(line[0], line[1:])
+ return parsed
+
+
def inv_lnx_parse_os(node, line):
for entry in line:
if entry.count("=") == 0: