From 41f0b04d007188539d581bb98db9a9c0c8c32851 Mon Sep 17 00:00:00 2001 From: Cyrinux Date: Tue, 9 Jun 2020 09:05:35 +0200 Subject: [PATCH 1/3] Add missing N/A fallback on DIMM memory (#129) --- netbox_agent/lshw.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox_agent/lshw.py b/netbox_agent/lshw.py index 6e11fb7..c7841a1 100644 --- a/netbox_agent/lshw.py +++ b/netbox_agent/lshw.py @@ -129,7 +129,7 @@ class LSHW(): d["id"] = dimm.get("id") d["serial"] = dimm.get("serial", 'N/A') d["vendor"] = dimm.get("vendor", 'N/A') - d["product"] = dimm.get("product") + d["product"] = dimm.get("product", 'N/A') d["size"] = dimm.get("size", 0) / 2 ** 20 / 1024 self.memories.append(d) -- 2.47.0 From 610c85af4e682d2c6c2fb59faf95b50fc5c76547 Mon Sep 17 00:00:00 2001 From: Cyril Levis Date: Wed, 10 Jun 2020 14:20:18 +0200 Subject: [PATCH 2/3] Some messages about the cache for example, with indentation level 0 break the parsing. I ignore line indentation if indentation level and line dont match REGEXP_CONTROLLER_HP. ```bash DC1|server-01:~# hpacucli ctrl all show detail Smart Array P244br in Slot 0 (Embedded) A cache backup failure has occurred. Please execute the "reenablecache" command to enable the cache. Your controller may require a reboot after the operation to complete the cache recovery process. Bus Interface: PCI Slot: 0 Serial Number: PDZVU0WLM241FP Cache Serial Number: PDZVU0WLM241FP RAID 6 (ADG) Status: Enabled Controller Status: OK Hardware Revision: B Firmware Version: 7.00-0 ... ``` --- netbox_agent/raid/hp.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/netbox_agent/raid/hp.py b/netbox_agent/raid/hp.py index 40a9a27..229ce19 100644 --- a/netbox_agent/raid/hp.py +++ b/netbox_agent/raid/hp.py @@ -54,6 +54,13 @@ def _get_dict(lines, start_index, indentation): continue current_line_indentation = _get_indentation(current_line) + # This check ignore some useless information that make + # crash the parsing + product_name = REGEXP_CONTROLLER_HP.search(current_line) + if current_line_indentation == 0 and not product_name: + i = i + 1 + continue + if current_line_indentation == indentation: current_item = current_line.lstrip(' ') -- 2.47.0 From 6cec26b0fdd88560a493f14e6a7b0c348cfb5ffb Mon Sep 17 00:00:00 2001 From: Cyril Levis Date: Wed, 10 Jun 2020 15:15:57 +0200 Subject: [PATCH 3/3] Remove whitespace --- netbox_agent/raid/hp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox_agent/raid/hp.py b/netbox_agent/raid/hp.py index 229ce19..144e73b 100644 --- a/netbox_agent/raid/hp.py +++ b/netbox_agent/raid/hp.py @@ -60,7 +60,7 @@ def _get_dict(lines, start_index, indentation): if current_line_indentation == 0 and not product_name: i = i + 1 continue - + if current_line_indentation == indentation: current_item = current_line.lstrip(' ') -- 2.47.0