From 610c85af4e682d2c6c2fb59faf95b50fc5c76547 Mon Sep 17 00:00:00 2001 From: Cyril Levis Date: Wed, 10 Jun 2020 14:20:18 +0200 Subject: [PATCH] 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(' ')