I want to parse a command out put with TextFSM. But I want to avoid unmatched values in the output. I am not sure if that is even possible with TextFSM. I have attached the temple, the text to parse, the current output and the desired output below.
TextFSM template:
Value PLATFORM (\S+)
Value MODEL (.*)
Value SERIAL (.*)
Value SLOT (\d)
Value DESCR (.*)
Value LOM_STATUS (\S+)
Value LOM_REV (\S+)
Start
^Platform:\s${PLATFORM}
^Model:\s${MODEL}
^Serial Number:\s${SERIAL} -> Record
^LOM\sStatus:\s${LOM_STATUS}
^LOM\sFirmware\sRevision:\s${LOM_REV} -> Record
^Line\scard\s${SLOT}\smodel:\s${MODEL}
^Line\scard\s${SLOT}\stype:\s${DESCR} -> Record
Text to parse:
Platform: PH-20-00
Model: Check Point 15400
Serial Number: LR7575757575757
CPU Model: Intel(R) Xeon(R) CPU E5-2630 v3
CPU Frequency: 2400.040 Mhz
Number of Cores: 16
CPU Hyperthreading: Enabled
Number of disks: 2
Disk 1 Model: ST1000NM0033-9ZM173
Disk 1 Capacity: 1.00 TB
Disk 2 Model: ST1000NM0033-9ZM173
Disk 2 Capacity: 1.00 TB
Total Disks size: 2.00 TB
Total Memory: 24576 MB
Memory Slot 1 Size: 8192 MB
Memory Slot 2 Size: 8192 MB
Memory Slot 3 Size: 8192 MB
Power supply 1 name: Power Supply #1
Power supply 1 status: Up
Power supply 2 name: Power Supply #2
Power supply 2 status: Up
LOM Status: Installed
LOM Firmware Revision: 3.43
Number of line cards: 3
Line card 1 model: CPAC-4-10F-B
Line card 1 type: 4 ports 10GbE SFP+ Rev 2.0
Line card 2 model: CPAC-8-1C-B
Line card 2 type: 8 ports 1GbE RJ45 Rev 1.0
Line card 3 model: CPAC-2-10F-B
Line card 3 type: 2 ports 1/10GbE SFP+ Rev 2.0
AC Present: No
Output:
[
{
"PLATFORM": "PH-20-00",
"MODEL": "Check Point 15400",
"SERIAL": "LR201606001133",
"SLOT": "",
"DESCR": "",
"LOM_STATUS": "",
"LOM_REV": ""
},
{
"PLATFORM": "",
"MODEL": "",
"SERIAL": "",
"SLOT": "",
"DESCR": "",
"LOM_STATUS": "Installed",
"LOM_REV": "3.43"
},
{
"PLATFORM": "",
"MODEL": "CPAC-4-10F-B",
"SERIAL": "",
"SLOT": "1",
"DESCR": "4 ports 10GbE SFP+ Rev 2.0",
"LOM_STATUS": "",
"LOM_REV": ""
},
{
"PLATFORM": "",
"MODEL": "CPAC-8-1C-B",
"SERIAL": "",
"SLOT": "2",
"DESCR": "8 ports 1GbE RJ45 Rev 1.0",
"LOM_STATUS": "",
"LOM_REV": ""
},
{
"PLATFORM": "",
"MODEL": "CPAC-2-10F-B",
"SERIAL": "",
"SLOT": "3",
"DESCR": "2 ports 1/10GbE SFP+ Rev 2.0",
"LOM_STATUS": "",
"LOM_REV": ""
}
]
Desired Output:
[
{
"PLATFORM": "PH-20-00",
"MODEL": "Check Point 15400",
"SERIAL": "LR201606001133"
},
{
"LOM_STATUS": "Installed",
"LOM_REV": "3.43"
},
{
"MODEL": "CPAC-4-10F-B",
"SERIAL": "",
"SLOT": "1",
"DESCR": "4 ports 10GbE SFP+ Rev 2.0"
},
{
"MODEL": "CPAC-8-1C-B",
"SERIAL": "",
"SLOT": "2",
"DESCR": "8 ports 1GbE RJ45 Rev 1.0"
},
{
"MODEL": "CPAC-2-10F-B",
"SERIAL": "",
"SLOT": "3",
"DESCR": "2 ports 1/10GbE SFP+ Rev 2.0"
}
]