networktocode / ntc-templates

TextFSM templates for parsing show commands of network devices
https://ntc-templates.readthedocs.io/
Other
1.07k stars 699 forks source link

Update to Arista "show ip ospf neighbor", running version 4.27.0F #1058

Open JulioPDX opened 2 years ago

JulioPDX commented 2 years ago
ISSUE TYPE
TEMPLATE USING
Value NEIGHBOR_ID (\d+.\d+.\d+.\d+)
Value INSTANCE (\d+)
Value VRF (\S+)
Value PRIORITY (\d+)
Value STATE (\S+|\S+\s+\S+)
Value DEAD_TIME (\d+:\d+:\d+)
Value ADDRESS (\d+.\d+.\d+.\d+)
Value INTERFACE (\S+)

Start
  ^${NEIGHBOR_ID}\s+${INSTANCE}\s+${VRF}\s+${PRIORITY}\s+${STATE}\s+${DEAD_TIME}\s+${ADDRESS}\s+${INTERFACE} -> Record
SAMPLE COMMAND OUTPUT
Neighbor ID     Instance VRF      Pri State                  Dead Time   Address         Interface
0.0.0.5         1        default  0   FULL                   00:00:37    10.0.0.3        Ethernet2
0.0.0.2         1        default  0   EXCH START             00:00:31    10.0.0.1        Ethernet1
0.0.0.9         1        default  0   FULL                   00:00:35    10.0.0.21       Ethernet4
0.0.0.8         1        default  0   FULL                   00:00:31    10.0.0.19       Ethernet3
SUMMARY

Seems "instance" was added in the show ip ospf neighbor output on at least the version of Arista I am using. 4.27.0F

STEPS TO REPRODUCE

I updated the template above and seems to be working with this version, I'm not sure how to make it backwards compatible but I thought I would share.

EXPECTED RESULTS
ACTUAL RESULTS

Results with using the included sample output and template.

[
    {
        'neighbor_id': '0.0.0.5',
        'instance': '1',
        'vrf': 'default',
        'priority': '0',
        'state': 'FULL',
        'dead_time': '00:00:29',
        'address': '10.0.0.3',
        'interface': 'Ethernet2'
    },
    {
        'neighbor_id': '0.0.0.2',
        'instance': '1',
        'vrf': 'default',
        'priority': '0',
        'state': 'EXCH START',
        'dead_time': '00:00:33',
        'address': '10.0.0.1',
        'interface': 'Ethernet1'
    },
    {
        'neighbor_id': '0.0.0.9',
        'instance': '1',
        'vrf': 'default',
        'priority': '0',
        'state': 'FULL',
        'dead_time': '00:00:36',
        'address': '10.0.0.21',
        'interface': 'Ethernet4'
    },
    {
        'neighbor_id': '0.0.0.8',
        'instance': '1',
        'vrf': 'default',
        'priority': '0',
        'state': 'FULL',
        'dead_time': '00:00:32',
        'address': '10.0.0.19',
        'interface': 'Ethernet3'
    }
]
JulioPDX commented 2 years ago

Give me a sec, output was not correct at all. Need to account for spacing in dual string possibility

JulioPDX commented 2 years ago

Okay thats much better, please let me know what you all think :)

JulioPDX commented 2 years ago

I think I see another bug in this. When in DR FULL in the text output it displays FULL/DR

jvanderaa commented 2 years ago

The update makes sense. Want to take a crack at the fix on it @JulioPDX ? Otherwise it may be just a little bit yet.

JulioPDX commented 2 years ago

The update makes sense. Want to take a crack at the fix on it @JulioPDX ? Otherwise it may be just a little bit yet.

The template I posted above will work for new versions of EOS, I'm just not sure how to make it compatible with previous versions that do not add instance as a return value in the output.

ryanmerolle commented 2 weeks ago

What are the next steps here?

jvanderaa commented 2 weeks ago

@ryanmerolle next steps are to submit a PR.

jvanderaa commented 2 weeks ago

@JulioPDX you want to take a crack at this one?