Module: check_mk
Branch: master
Commit: 04079c18b3d4083cac6be576393402f8433992ac
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=04079c18b3d408…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Fri Jan 11 13:26:56 2019 +0100
prtconf: refactor to parse function
Change-Id: I180d26141631a33fc4f3bffe4b47fe6610b22efa
---
inventory/prtconf | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/inventory/prtconf b/inventory/prtconf
index 3164545..e94618b 100644
--- a/inventory/prtconf
+++ b/inventory/prtconf
@@ -48,20 +48,28 @@
# not being parsed.
-def inv_prtconf(info):
- confdict = {}
+def parse_prtconf(info):
+ parsed = {}
+
for line in info:
+ if not line:
+ continue
+ if line[0].startswith("========="):
+ break # ignore the rest of the output currently
if len(line) == 2:
varname = line[0]
value = line[1].strip()
- confdict[varname] = value
+ parsed[varname] = value
- if line[0].startswith("========="):
- break # ignore the rest of the output currently
+ return parsed
+
+
+def inv_prtconf(info):
+ parsed = parse_prtconf(info)
cpu_dict = inv_tree("hardware.cpu.")
- for varname, value in confdict.items():
+ for varname, value in parsed.items():
if varname == "CPU Type":
if value == "64-bit":
arch = "ppc64"