Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix standard regular expressions to skip headers #169

Closed
wants to merge 1 commit into from

Conversation

dagwieers
Copy link

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT

templates/cisco_ios_show_mac-address-table.template

SUMMARY

So we had an issue with the below output as it would repeat the headers as part of the returned values.

The solution is to fix the regular expressions, as they would match too broad. For instance the expression (\w+.\w+.\w+) would match things like A B C or Nightmare|On|ElmStreet. Dots should be matched using \. and for a mac-address the regexp could be much more strict.

Same for vlan numbers we know it's between 1 and 4 digits.

Legend: * - primary entry
        age - seconds since last seen
        n/a - not available
        S - secure entry
        R - router's gateway mac address entry
        D - Duplicate mac address entry

Displaying entries from DFC switch [1] linecard [1]:

     vlan   mac address    type   learn    age                 ports
----+----+---------------+-------+-----+----------+-----------------------------
      420 009e.1ead.eadd  dynamic  Yes      160     Po140


Displaying entries from DFC switch [1] linecard [2]:

     vlan   mac address    type   learn    age                 ports
----+----+---------------+-------+-----+----------+-----------------------------
*     420 009e.1ead.eadd  dynamic  Yes        5     Po140


Displaying entries from DFC switch [1] linecard [3]:

     vlan   mac address    type   learn    age                 ports
----+----+---------------+-------+-----+----------+-----------------------------
      420 009e.1ead.eadd  dynamic  Yes       45     Po140


Displaying entries from DFC switch [1] linecard [4]:

     vlan   mac address    type   learn    age                 ports
----+----+---------------+-------+-----+----------+-----------------------------
      420 009e.1ead.eadd  dynamic  Yes      175     Po140


Displaying entries from active supervisor:

     vlan   mac address    type   learn    age                 ports
----+----+---------------+-------+-----+----------+-----------------------------
      420 009e.1ead.eadd  dynamic  Yes       65     Po140


Displaying entries from DFC switch [2] linecard [1]:

     vlan   mac address    type   learn    age                 ports
----+----+---------------+-------+-----+----------+-----------------------------
      420 009e.1ead.eadd  dynamic  Yes      140     Po140


Displaying entries from DFC switch [2] linecard [2]:

     vlan   mac address    type   learn    age                 ports
----+----+---------------+-------+-----+----------+-----------------------------
*     420 009e.1ead.eadd  dynamic  Yes        5     Po140


Displaying entries from DFC switch [2] linecard [3]:

     vlan   mac address    type   learn    age                 ports
----+----+---------------+-------+-----+----------+-----------------------------
      420 009e.1ead.eadd  dynamic  Yes      120     Po140


Displaying entries from DFC switch [2] linecard [4]:

     vlan   mac address    type   learn    age                 ports
----+----+---------------+-------+-----+----------+-----------------------------
      420 009e.1ead.eadd  dynamic  Yes      180     Po140


Displaying entries from standby supervisor:

     vlan   mac address    type   learn    age                 ports
----+----+---------------+-------+-----+----------+-----------------------------
      420 009e.1ead.eadd  dynamic  Yes      115     Po140

So we had an issue with the below output as it would repeat the headers as part of the returned values.

The solution is to fix the regular expressions, as they would match too broad. For instance the expression `(\w+.\w+.\w+)` would match things like `A B C` or `Nightmare|On|ElmStreet`. Dots should be matched using `\.` and for a mac-address the regexp could be much more strict.

Same for vlan numbers we know it's between 1 and 4 digits.
@itdependsnetworks
Copy link
Contributor

@dagwieers A little concerned there may be a non-number in that slot. Can you just do?

TYPE1
  ^---
  ^${DESTINATION_ADDRESS}\s+${TYPE}\s+${VLAN}\s+${DESTINATION_PORT} -> Record

Also same as previous, looking to remove any chance of unknown matches.

@jmcgill298
Copy link
Contributor

#342

@jmcgill298 jmcgill298 closed this Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants