I have this data that is NOT separated by a blank line:
show environment power-supply
------------------------------------------------------------------------------
Product Serial PSU Input Voltage Wattage
Mbr/PSU Number Number Status Type Range Maximum
------------------------------------------------------------------------------
1/1 SL085C TTS22GZ1AAT OK AC 100V-240V 250
1/2 SL085C TTS23GZ2BBH OK AC 100V-240V 250
2/1 SL085C TTS23GZ3CC9 OK AC 100V-240V 250
2/2 SL085C TTS23GZ4DDB OK AC 100V-240V 250
show environment temperature
Temperature information
------------------------------------------------------------------------------
Current
Mbr/Slot-Sensor Module Type temperature Status
------------------------------------------------------------------------------
1/1-Switch-ASIC-Internal line-card-module 61.12 C normal
2/1-Switch-ASIC-Internal line-card-module 61.00 C normal
1/1-CPU management-module 45.00 C normal
1/1-CPU-Zone-0 management-module 40.00 C normal
1/1-CPU-Zone-1 management-module 40.00 C normal
I want to parse different sections of this. The TEXTFSM Parser I have written so far works fine on independent sections but it gives only record one I try to combine it. Can someone help me fix this.
TextFSM Parser:
Value List POWER_SUPPLY ((?P<MBR_PSU>^\d+\/\d+)\s*(?P<PRODUCT_NUMBER>\S+)\s*(?P<SERIAL_NUMBER>\S+)\s*(?P<PSU_STATUS>\S+)\s*(?P<INPUT_TYPE>AC|DC)\s*(?P<INPUT_VOLTAGE_RANGE>\d+V-\d+V)\s*(?P<MAX_WATTAGE>\d+))
Value List ENV_TEMP ((?P<MBR_SLOT>^\d+\/\d+)(?P<SENSOR_TYPE>\S+)\s+(?P<MODULE_TYPE>\S+)\s+(?P<TEMPERATURE>[-+]?\d*\.\d+\sC)\s+(?P<STATUS>\S+))
Start
^show environment power-supply -> PowerSupply
^show environment temperature -> EnvTemp
PowerSupply
^${POWER_SUPPLY} -> Start
^(?![^-{78}])
EnvTemp
^(?![^-{78}])
^${ENV_TEMP} -> Start
Also guide me if you can with the steps you took for me to understand your approach if it works fine.
The output right now looks like this but I want to capture all the lines in the respective section.
[{'ENV_TEMP': [{'MBR_SLOT': '1/1',
'MODULE_TYPE': 'line-card-module',
'SENSOR_TYPE': '-Switch-ASIC-Internal',
'STATUS': 'normal',
'TEMPERATURE': '61.12 C'}],
'POWER_SUPPLY': [{'INPUT_TYPE': 'AC',
'INPUT_VOLTAGE_RANGE': '100V-240V',
'MAX_WATTAGE': '250',
'MBR_PSU': '1/1',
'PRODUCT_NUMBER': 'JL085A',
'PSU_STATUS': 'OK',
'SERIAL_NUMBER': 'TTS22GZ1AAT'}]}]