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

Ciso IOS show mac and show module fix #1006

Merged
merged 7 commits into from
Oct 27, 2021

Conversation

armartirosyan
Copy link
Contributor

ISSUE TYPE
  • Bugfix Pull Request
  • Additional Testing Data
COMPONENT

Cisco IOS show mac-address-table
Cisco IOS show module

SUMMARY

Cisco IOS show mac-address-table
Added new logic for Type 2 since found a new output that was not matching the current template.

Cisco IOS show module
Added new logic to the template since found a new output that was not matching the current template. Also added some -> End statements to prevent the parser from failing. Supporting examples were added to the tests folder.

Cisco IOS show mac-address-table

Value DESTINATION_ADDRESS ([0-9a-fA-F]{4}\.[0-9a-fA-F]{4}\.[0-9a-fA-F]{4})
Value TYPE (\S+)
Value VLAN (\S+)
Value List DESTINATION_PORT (\S+?)

Start
  ^Destination\s+Address\s+Address\s+Type\s+VLAN\s+Destination\s+Port -> TYPE1
  ^\s+vlan\s+mac address\s+type\s+learn\s+age\s+ports -> TYPE2
  ^\s+vlan\s+mac address\s+type\s+protocols\s+port -> TYPE3
  ^Vlan\s+Mac Address\s+Type\s+Ports -> TYPE4
  # Capture time-stamp if vty line has command time-stamping turned on
  ^Load\s+for\s+
  ^Time\s+source\s+is

TYPE1
  ^${DESTINATION_ADDRESS}\s+${TYPE}\s+${VLAN}\s+${DESTINATION_PORT}$$ -> Record
  ^-+\s+-+
  ^Displaying\s+entries
  ^Destination\s+Address\s+Address\s+Type\s+VLAN\s+Destination\s+Port
  ^\s*$$
  ^Multicast\s+Entries -> End
  ^. -> Error

TYPE2
  # Order of the group in brackets here matters
  ^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+) -> Continue.Record
  ^\s*(?:\*\s+R|\*|R|\s)\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s*$$ -> Continue
  ^\s*(?:\*\s+R|\*|R|\s)\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?!\S+?,)${DESTINATION_PORT}\s*$$ -> Continue
  ^\s*(?:\*\s+R|\*|R|\s)\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+${DESTINATION_PORT}, -> Continue
  ^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+\S+?,${DESTINATION_PORT}, -> Continue
  ^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+?,){2}${DESTINATION_PORT}, -> Continue
  ^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+?,){3}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+?,){4}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+?,){5}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+?,){6}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+?,){7}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^\s{20}\s+${DESTINATION_PORT}, -> Continue
  ^\s{20}\s+(?:\S+?,)${DESTINATION_PORT}, -> Continue
  ^\s{20}\s+(?:\S+?,){2}${DESTINATION_PORT}, -> Continue
  ^\s{20}\s+(?:\S+?,){3}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^\s{20}\s+(?:\S+?,){4}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^\s{20}\s+(?:\S+?,){5}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^\s{20}\s+(?:\S+?,){6}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^\s{20}\s+(?:\S+?,){7}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^-+\+-+
  ^Displaying\s+entries
  ^\s+vlan\s+mac address\s+type\s+learn\s+age\s+ports
  ^\s*$$
  ^\s*\S+
  ^Multicast\s+Entries -> End
  ^. -> Error

TYPE3
  ^\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+${DESTINATION_PORT}$$ -> Record
  ^-+\+-+
  ^Displaying\s+entries
  ^\s+vlan\s+mac address\s+type\s+protocols\s+port
  ^\s*$$
  ^Multicast\s+Entries -> End
  ^. -> Error

TYPE4
  ^\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+${DESTINATION_PORT}$$ -> Record
  ^-+\s+-+
  ^Displaying\s+entries
  ^Vlan\s+Mac Address\s+Type\s+Ports
  ^\s*$$
  ^Total\s+Mac\s+Addresses
  ^MultiCast\s+Entries -> End
  ^. -> Error
Value DESTINATION_ADDRESS ([0-9a-fA-F]{4}\.[0-9a-fA-F]{4}\.[0-9a-fA-F]{4})
Value TYPE (\S+)
Value VLAN (\S+)
Value List DESTINATION_PORT (\S+?)

Start
  ^Destination\s+Address\s+Address\s+Type\s+VLAN\s+Destination\s+Port -> TYPE1
  ^\s+vlan\s+mac address\s+type\s+learn\s+age\s+ports -> TYPE2
  ^\s+vlan\s+mac address\s+type\s+protocols\s+port -> TYPE3
  ^Vlan\s+Mac Address\s+Type\s+Ports -> TYPE4
  # Capture time-stamp if vty line has command time-stamping turned on
  ^Load\s+for\s+
  ^Time\s+source\s+is

TYPE1
  ^${DESTINATION_ADDRESS}\s+${TYPE}\s+${VLAN}\s+${DESTINATION_PORT}$$ -> Record
  ^-+\s+-+
  ^Displaying\s+entries
  ^Destination\s+Address\s+Address\s+Type\s+VLAN\s+Destination\s+Port
  ^\s*$$
  ^Multicast\s+Entries -> End
  ^. -> Error

TYPE2
  # Order of the group in brackets here matters
  ^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+) -> Continue.Record
  ^\s*(?:\*\s+R|\*|R|\s)\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s*$$ -> Continue
  ^\s*(?:\*\s+R|\*|R|\s)\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?!\S+?,)${DESTINATION_PORT}\s*$$ -> Record
  ^\s*(?:\*\s+R|\*|R|\s+)\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+${DESTINATION_PORT}  -> Continue
  ^\s*(?:\*\s+R|\*|R|\s+)\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+\S+? ${DESTINATION_PORT}  -> Continue
  ^\s*(?:\*\s+R|\*|R|\s+)\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+? ){2}${DESTINATION_PORT}  -> Continue
  ^\s*(?:\*\s+R|\*|R|\s+)\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+? ){3}${DESTINATION_PORT}(?: |$$) -> Continue
  ^\s*(?:\*\s+R|\*|R|\s+)\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+? ){4}${DESTINATION_PORT}(?: |$$) -> Continue
  ^\s*(?:\*\s+R|\*|R|\s+)\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+? ){5}${DESTINATION_PORT}(?: |$$) -> Continue
  ^\s*(?:\*\s+R|\*|R|\s+)\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+? ){6}${DESTINATION_PORT}(?: |$$) -> Continue
  ^\s*(?:\*\s+R|\*|R|\s+)\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+? ){7}${DESTINATION_PORT}(?: |$$) -> Continue
  ^\s{20}\s+${DESTINATION_PORT}  -> Continue
  ^\s{20}\s+(?:\S+? )${DESTINATION_PORT}  -> Continue
  ^\s{20}\s+(?:\S+? ){2}${DESTINATION_PORT}  -> Continue
  ^\s{20}\s+(?:\S+? ){3}${DESTINATION_PORT}(?: |$$) -> Continue
  ^\s{20}\s+(?:\S+? ){4}${DESTINATION_PORT}(?: |$$) -> Continue
  ^\s{20}\s+(?:\S+? ){5}${DESTINATION_PORT}(?: |$$) -> Continue
  ^\s{20}\s+(?:\S+? ){6}${DESTINATION_PORT}(?: |$$) -> Continue
  ^\s{20}\s+(?:\S+? ){7}${DESTINATION_PORT}(?: |$$) -> Continue
  ^\s*(?:\*\s+R|\*|R|\s)\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+${DESTINATION_PORT}, -> Continue
  ^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+\S+?,${DESTINATION_PORT}, -> Continue
  ^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+?,){2}${DESTINATION_PORT}, -> Continue
  ^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+?,){3}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+?,){4}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+?,){5}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+?,){6}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^\s*(?:\*\s+R|\*|R|\s)\s*(?:\d+|-+)\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+(?:\S+?,){7}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^\s{20}\s+${DESTINATION_PORT}, -> Continue
  ^\s{20}\s+(?:\S+?,)${DESTINATION_PORT}, -> Continue
  ^\s{20}\s+(?:\S+?,){2}${DESTINATION_PORT}, -> Continue
  ^\s{20}\s+(?:\S+?,){3}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^\s{20}\s+(?:\S+?,){4}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^\s{20}\s+(?:\S+?,){5}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^\s{20}\s+(?:\S+?,){6}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^\s{20}\s+(?:\S+?,){7}${DESTINATION_PORT}(?:,|$$) -> Continue
  ^-+\+-+
  ^Displaying\s+entries
  ^\s+vlan\s+mac address\s+type\s+learn\s+age\s+ports
  ^\s*$$
  ^\s*\S+
  ^Multicast\s+Entries -> End
  ^. -> Error

TYPE3
  ^\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+${DESTINATION_PORT}$$ -> Record
  ^-+\+-+
  ^Displaying\s+entries
  ^\s+vlan\s+mac address\s+type\s+protocols\s+port
  ^\s*$$
  ^Multicast\s+Entries -> End
  ^. -> Error

TYPE4
  ^\s*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+${DESTINATION_PORT}$$ -> Record
  ^-+\s+-+
  ^Displaying\s+entries
  ^Vlan\s+Mac Address\s+Type\s+Ports
  ^\s*$$
  ^Total\s+Mac\s+Addresses
  ^MultiCast\s+Entries -> End
  ^. -> Error

Cisco IOS show module

Value Key MODULE (\d+)
Value PORT (\d+)
Value CARDTYPE (.+?)
Value MODEL (\S+)
Value SERIAL (\w+)


Start
  ^Mod\s+Ports\s+Card\s+Type\s+Model\s+Serial -> Status

Status
  ^-+
  ^\s*${MODULE}\s+${PORT}\s+${CARDTYPE}\s+${MODEL}\s+${SERIAL}\s*$$ -> Record
  ^Mod\s+MAC\s+addresses\s+Hw\s+Fw\s+Sw\s+Status -> End
  ^Mod\s+Sub-Module\s+Model\s+Serial\s+Hw\s+Status -> End
  ^Mod\s+Online\s+Diag\s+Status -> End
  ^\s*$$
  ^. -> Error

End
Value Key MODULE (\d+)
Value PORT (\d+| {1})
Value CARDTYPE (.+?)
Value MODEL (\S+| {1})
Value SERIAL (\w+| {1})


Start
  ^Mod\s+Ports\s+Card\s+Type\s+Model\s+Serial -> HWInfo

HWInfo
  ^-+
  ^\s*${MODULE}\s+${PORT}\s+${CARDTYPE}\s+${MODEL}\s+${SERIAL}\s*$$ -> Record
  ^(?:Mod|\s+M)\s+MAC\s+addresses\s+Hw\s+Fw\s+Sw\s+Status -> End
  ^Mod\s+Sub-Module\s+Model\s+Serial\s+Hw\s+Status -> End
  ^Mod\s+Redundancy\s+Role\s+Operating\s+Redundancy\s+Mode\s+Configured\s+Redundancy\s+Mode -> End
  ^Mod\s+Redundancy\s+Role\s+Operating\s+Mode\s+Configured\s+Mode\s+Redundancy\s+Status -> End
  ^Mod\s+Online\s+Diag\s+Status -> End
  ^\s*$$
  ^. -> Error

End

Copy link
Contributor

@jmcgill298 jmcgill298 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmcgill298 jmcgill298 merged commit ec76c69 into master Oct 27, 2021
@jmcgill298 jmcgill298 deleted the ciso_ios_show_mac_and_show_module_fix branch October 27, 2021 18:44
guillaume-mbali pushed a commit to unyc-io/ntc-templates that referenced this pull request Apr 12, 2023
cppmonkey pushed a commit to cppmonkey/ntc-templates that referenced this pull request Oct 25, 2023
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.

2 participants