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

cisco_wlc_ssh_show_wlan_sum update - make PMIP_MOBILITY optional #872

Merged
merged 1 commit into from
Mar 1, 2021

Conversation

progala
Copy link
Contributor

@progala progala commented Mar 1, 2021

ISSUE TYPE
  • Template Bug
TEMPLATE USING

cisco_wlc_ssh_show_wlan_sum.textfsm

Value WLANID (\d+)
Value PROFILE (.+?)
Value SSID (.+?)
Value STATUS (Enabled|Disabled)
Value INTERFACE (\w+(.?\w+)+)
Value PMIP_MOBILITY (\S+)


Start
  ^Number\s+of\s+WLANs
  ^WLAN\s+ID\s+WLAN\s+Profile\s+Name\s+\/\s+SSID\s+Status\s+Interface\s+Name\s+PMIPv6\s+Mobility\s*$$
  ^-------\s+
  ^${WLANID}\s+${PROFILE}\s/\s${SSID}\s+${STATUS}\s+${INTERFACE}\s+${PMIP_MOBILITY}\s*$$ -> Record
  ^\s*$$
  ^. -> Error

SAMPLE COMMAND OUTPUT

Number of WLANs.................................. 3

WLAN ID  WLAN Profile Name / SSID               Status    Interface Name
-------  -------------------------------------  --------  --------------------
4        OfficeFloor / OfficeFloor              Enabled   officefloor_int
5        OfficeLobby / OfficeLobby              Enabled   officelobby_int
6        LoadingBay / LoadingBay                Enabled   loadingbay_int
SUMMARY
STEPS TO REPRODUCE
  • Save the above SAMPLE OUTPUT as cisco_wlc_ssh_show_wlan_sum2.raw
  • Try parsing raw data by running:
python development_scripts.py -c tests/cisco_wlc_ssh/show_wlan_sum/cisco_wlc_ssh_show_wlan_sum2.raw
EXPECTED RESULTS

Raw output should be parsed into the below yaml:

---
parsed_sample:
  - wlanid: "4"
    profile: "OfficeFloor"
    ssid: "OfficeFloor"
    status: "Enabled"
    interface: "officefloor_int"
    pmip_mobility: ""
  - wlanid: "5"
    profile: "OfficeLobby"
    ssid: "OfficeLobby"
    status: "Enabled"
    interface: "officelobby_int"
    pmip_mobility: ""
  - wlanid: "6"
    profile: "LoadingBay"
    ssid: "LoadingBay"
    status: "Enabled"
    interface: "loadingbay_int"
    pmip_mobility: ""
ACTUAL RESULTS
❯ python development_scripts.py -c tests/cisco_wlc_ssh/show_wlan_sum/cisco_wlc_ssh_show_wlan_sum2.raw
Traceback (most recent call last):
  File "development_scripts.py", line 491, in <module>
    build_parsed_data_from_output(command_file)
  File "development_scripts.py", line 421, in build_parsed_data_from_output
    structured_data = parse_output(platform, command, output_data)
  File "/home/przemek/ntc-os/ntc-templates/lib/ntc_templates/parse.py", line 57, in parse_output
    cli_table.ParseCmd(data, attrs)
  File "/home/przemek/ntc-os/.venv/lib/python3.8/site-packages/textfsm/clitable.py", line 282, in ParseCmd
    self.table = self._ParseCmdItem(self.raw, template_file=template_files[0])
  File "/home/przemek/ntc-os/.venv/lib/python3.8/site-packages/textfsm/clitable.py", line 315, in _ParseCmdItem
    for record in fsm.ParseText(cmd_input):
  File "/home/przemek/ntc-os/.venv/lib/python3.8/site-packages/textfsm/parser.py", line 895, in ParseText
    self._CheckLine(line)
  File "/home/przemek/ntc-os/.venv/lib/python3.8/site-packages/textfsm/parser.py", line 944, in _CheckLine
    if self._Operations(rule, line):
  File "/home/przemek/ntc-os/.venv/lib/python3.8/site-packages/textfsm/parser.py", line 1024, in _Operations
    raise TextFSMError('State Error raised. Rule Line: %s. Input Line: %s'
textfsm.parser.TextFSMError: State Error raised. Rule Line: 15. Input Line: WLAN ID  WLAN Profile Name / SSID
    Status    Interface Name
PROPOSED FIX
  • Update cisco_wlc_ssh_show_wlan_sum.textfsm to make PMIP_MOBILITY optional.
Value WLANID (\d+)
Value PROFILE (.+?)
Value SSID (.+?)
Value STATUS (Enabled|Disabled)
Value INTERFACE (\w+(.?\w+)+)
Value PMIP_MOBILITY (\S+)


Start
  ^Number\s+of\s+WLANs
  ^WLAN\s+ID\s+WLAN\s+Profile\s+Name\s+\/\s+SSID\s+Status\s+Interface\s+Name(\s+PMIPv6\s+Mobility)?\s*$$
  ^-------\s+
  ^${WLANID}\s+${PROFILE}\s/\s${SSID}\s+${STATUS}\s+${INTERFACE}(\s+${PMIP_MOBILITY})?\s*$$ -> Record
  ^\s*$$
  ^. -> Error

  • Added tests:
    • raw: cisco_wlc_ssh_show_wlan_sum2.raw
    • parsed: cisco_wlc_ssh_show_wlan_sum2.yml

@jmcgill298 jmcgill298 merged commit d0fed69 into networktocode:master Mar 1, 2021
@jmcgill298
Copy link
Contributor

Thanks @progala

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