Multiple line parsing using lists with textfsm extracting wrong details
Closed this issue · 0 comments
ISSUE TYPE
- Bug Report
TEMPLATE USING
Value Required vlan (\d+)
Value List name (\S*)
Value List encap (\S+)
Value List ports (\S+ \S+ \S*|\S+ \S+|\S+)
Start
^ \d+ -> Continue.Record
^\s*${vlan}\s*${name}\s*${encap}\s*${ports}
^\s+${name}\s*${encap} \s+${ports}
^\s+${ports}
SAMPLE COMMAND OUTPUT
apic1# fabric 203 show vlan extended
----------------------------------------------------------------
Node 203 (lab1r00002-ne-RDC-LF3)
----------------------------------------------------------------
VLAN Name Encap Ports
---- -------------------------------- ---------------- ------------------------
9 5GC-N6:N3-INT:l3out-UPF-N3-INT- vxlan-15171532, Eth1/1, Eth1/2, Eth1/3,
VRF-FLT:vlan-541 vlan-541 Eth1/4, Eth1/5, Eth1/6,
Eth1/7, Eth1/8, Eth1/9,
Eth1/10, Eth1/11,
Eth1/12, Eth1/13,
Eth1/14, Eth1/15,
Eth1/16, Eth1/17,
Eth1/18, Eth1/19,
Eth1/20, Eth1/21,
Eth1/22, Eth1/23,
Eth1/24, Eth1/28,
Eth1/29, Eth1/30,
Eth1/31, Eth1/32,
Eth1/33, Eth1/34,
Eth1/35, Eth1/36,
Eth1/37, Eth1/38,
Eth1/39, Eth1/40,
Eth1/41, Eth1/42,
Eth1/43, Po1, Po2
11 NSO-XDOMAIN:Source-TG-BD vxlan-16318378 Eth1/16
12 NSO-XDOMAIN:Traffic- vlan-621 Eth1/16
Generators:source-tg-epg
14 infra:default vxlan-16777209, Eth1/1, Eth1/48
vlan-3914
SUMMARY
I am trying to create a textfsm template for the command fabric show vlan extended on an APIC controller. The output here is such that some of the outputs spill over to the next lines. I used list to handle this. But since the output format is different for different instances, the template does not work for all cases.
The template works perfectly for vlan ID 9 and 11. But for the other ones, it pushes some elements to the wrong value lists.
How can this template be made to work for all the output scenarios?
STEPS TO REPRODUCE
EXPECTED RESULTS
The results are as expected for some of the VLAN IDs where the ports column is in multiple lines. If "name" or "encap" values are in multiple lines and "ports" is in a single line, then the entries get into wrong lists.
ACTUAL RESULTS
For the VLAN ID 14, encap value vlan-3914 which is in next line gets into ports list.
{
"encap": [
"vxlan-16777209,"
],
"name": [
"infra:default"
],
"ports": [
"Eth1/1, Eth1/48 ",
"vlan-3914"
],
"vlan": "14"
}