networktocode/ntc-templates

Bug with cisco_ios_show_ap_summary.textfsm

Closed this issue · 1 comments

ISSUE TYPE
  • Template Issue with error and raw data
TEMPLATE USING

cisco_ios_show_ap_summary.textfsm

Value AP_NAME (\S+)
Value SLOT (\d+)
Value AP_MODEL (\S+)
Value MAC_ADDRESS ([a-fA-F0-9:.]+)
Value RADIO_MAC ([a-fA-F0-9:.]+)
Value LOCATION (.+?)
Value COUNTRY (\S+)
Value IP_ADDRESS ([a-fA-F0-9:.]+)
Value STATE (\S+)

Start
^[a-zA-Z]+\s[a-z]+\s[a-zA-z]+:\s\d+$$
^AP\s+Name\s+Slots\s+AP\s+Model\s+Ethernet\s+MAC\s+Radio\sMAC\s+Location\s+Country\s+IP\s+Address\s+State\s*$$
^-+\s*$$
^${AP_NAME}\s+${SLOT}\s+${AP_MODEL}\s+${MAC_ADDRESS}\s+${RADIO_MAC}\s+${LOCATION}\s+${COUNTRY}\s+${IP_ADDRESS}\s+${STATE}\s*$$ -> Record
^\s*$$
^. -> Error

SAMPLE COMMAND OUTPUT

EK-WLC#sh ap summary
Number of APs: 44

CC = Country Code
RD = Regulatory Domain

AP Name Slots AP Model Ethernet MAC Radio MAC CC RD IP Address State Location

XWL3-2702-ICT02 2 AIR-CAP2702I-E-K9 002c.c82c.aefc 002c.c8f1.8cf0 CH -E 10.198.90.22 Registered Bin7-Reisende

SUMMARY

Cisco added
CC = Country Code
RD = Regulatory Domain
to the show output in the new Cisco 9800 ios WLAN Controller. With the actual TextFSM Template, it ends in a error.

EXPECTED RESULTS

[
{
"ap_name": "XWL3-2702-ICT02",
"slot": "2",
"ap_model": "AIR-CAP2702I-E-K9",
"mac": "002c.c82c.aefc",
"radio_mac": "002c.c8f1.8cf0",
"location": "Bin7-Reisende",
"country": "CH",
"regulatorydomain": "-E",
"ip": "10.198.90.22",
"ipv6": "",
"state": "Registered",
"clients": "",
"dse_location": ""
}
]

SAMPLE COMMAND OUTPUT

Created a working Template:
Value AP_NAME (\S+)
Value SLOT (\d+)
Value AP_MODEL (\S+)
Value MAC ([a-fA-F0-9:.]+)
Value RADIO_MAC ([a-fA-F0-9:.]+)
Value LOCATION (.+?)
Value COUNTRY (\S+)
Value REGULATORYDOMAIN (\S+)
Value IP ([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})
Value IPV6 ([0-9a-fA-F]{1,4}:[a-fA-F0-9:]+)
Value STATE (\S+)
Value CLIENTS (\d+)
Value DSE_LOCATION ([.+])

Start
^Number.*
^${AP_NAME}\s+${SLOT}\s+${AP_MODEL}\s+${MAC}\s+${LOCATION}\s+${COUNTRY}\s+${IP}\s+${CLIENTS}\s+${DSE_LOCATION}\s*$$ -> Record
^${AP_NAME}\s+${SLOT}\s+${AP_MODEL}\s+${MAC}\s+${LOCATION}\s+${COUNTRY}\s+${IPV6}\s+${CLIENTS}\s+${DSE_LOCATION}\s*$$ -> Record
^${AP_NAME}\s+${SLOT}\s+${AP_MODEL}\s+${MAC}\s+${RADIO_MAC}\s+${COUNTRY}\s+${REGULATORYDOMAIN}\s+${IP}\s+${STATE}\s+${LOCATION}$$ -> Record
^${AP_NAME}\s+${SLOT}\s+${AP_MODEL}\s+${MAC}\s+${RADIO_MAC}\s+${COUNTRY}\s+${REGULATORYDOMAIN}\s+${IPV6}\s+${STATE}\s+${LOCATION}$$ -> Record
^${AP_NAME}\s+${SLOT}\s+${AP_MODEL}\s+${MAC}\s+${RADIO_MAC}\s+${LOCATION}\s+${COUNTRY}\s+${IP}\s+${STATE}\s*$$ -> Record
^${AP_NAME}\s+${SLOT}\s+${AP_MODEL}\s+${MAC}\s+${RADIO_MAC}\s+${LOCATION}\s+${COUNTRY}\s+${IPV6}\s+${STATE}\s*$$ -> Record
^${AP_NAME}\s+${SLOT}\s+${AP_MODEL}\s+${MAC}\s+${LOCATION}\s+${COUNTRY}\s+${IP}\s+.$$ -> Record
^${AP_NAME}\s+${SLOT}\s+${AP_MODEL}\s+${MAC}\s+${LOCATION}\s+${COUNTRY}\s+${IPV6}\s+.
$$ -> Record
^.+.+
^\s*$$
^AP\s+Name\s.*
^AP\ds
^CC\s*=\sCountry\sCode.*
^RD\s*=\sRegulatory\sDomain.*
^-+
^. -> Error

Hello @wet17
I'm going to suggest we may make changes in incremental stages because NTC has a policy regarding breaking changes. Breaking changes must wait for a major version release.

Spot on with the regulatory domain addition!

With that aside, a few things:

  • DSE_LOCATION appears to be the same as LOCATION
  • splitting out IPv4 and IPv6 constitutes a breaking change and may not be necessary at this point (although that can certainly be open for discussion)
  • In my solution, the CC = abbreviation legend pattern I used should be flexible enough to capture any other abbreviations Cisco may add later on
  • I added a few comments in the textfsm in addition to shuffling a few lines (no impact on parsing)

https://github.com/networktocode/ntc-templates/pull/1739/files#diff-2fd0f359ac70f1a92d624fd450be97aa7ae04eabd07f316691e5bf289e78a09e

Please give my PR #1739 a look if you would. This PR resolves the addition of the Regulatory Domain.
Thank you.