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_ios_show_interfaces_switchport.template broken #537

Closed
vnetman opened this issue Nov 10, 2019 · 1 comment · Fixed by #538
Closed

cisco_ios_show_interfaces_switchport.template broken #537

vnetman opened this issue Nov 10, 2019 · 1 comment · Fixed by #538

Comments

@vnetman
Copy link

vnetman commented Nov 10, 2019

ISSUE TYPE
  • Bug Report
TEMPLATE USING
    Value Required INTERFACE (\S+)
    Value SWITCHPORT (.+)
    Value SWITCHPORT_MONITOR (.+)
    Value SWITCHPORT_NEGOTIATION (.+)
    Value MODE (.+)
    Value ACCESS_VLAN (\d+)
    Value NATIVE_VLAN (\d+)
    Value VOICE_VLAN (\S+)
    Value TRUNKING_VLANS (.+)
    
    Start
      ^Name: -> Continue.Record
      ^Name:\s+${INTERFACE}
      ^\s*Switchport:\s+${SWITCHPORT}
      ^\s*Switchport\s+Monitor:\s+${SWITCHPORT_MONITOR}
      ^\s*Operational\s+Mode:\s+${MODE}
      ^\s*Negotiation\s+of\s+Trunking:\s+${SWITCHPORT_NEGOTIATION}
      ^\s*Access\s+Mode\s+VLAN:\s+${ACCESS_VLAN}
      ^\s*Trunking\s+Native\s+Mode\s+VLAN:\s+${NATIVE_VLAN}
      ^\s*Voice\s+VLAN:\s+${VOICE_VLAN}
      ^\s*Trunking\s+VLANs\s+Enabled:\s+${TRUNKING_VLANS}
      ^\s*Administrative\s+Mode
      ^\s*(?:Operational|Administrative)\s+(?:Trunking|Native\s+VLAN|private-vlan)
      ^\s*Voice\s+VLAN:
      ^\s*Pruning\s+VLANs
      ^\s*Capture\s+(?:Mode|VLANs)
      ^\s*Protected
      ^\s*Appliance\s+trust
      ^\s*$$
      # Capture time-stamp if vty line has command time-stamping turned on
      ^Load\s+for\s+
      ^Time\s+source\s+is
      ^. -> Error
SAMPLE COMMAND OUTPUT
    sn-6am-318-43#show interfaces switchport
    Name: Fa0/1
    Switchport: Enabled
    Administrative Mode: dynamic auto
    Operational Mode: static access
    Administrative Trunking Encapsulation: dot1q
    Operational Trunking Encapsulation: native
    Negotiation of Trunking: On
    Access Mode VLAN: 1 (default)
    Trunking Native Mode VLAN: 1 (default)
    Administrative Native VLAN tagging: enabled
    Voice VLAN: none
    Administrative private-vlan host-association: none 
    Administrative private-vlan mapping: none 
    Administrative private-vlan trunk native VLAN: none
    Administrative private-vlan trunk Native VLAN tagging: enabled
    Administrative private-vlan trunk encapsulation: dot1q
    Administrative private-vlan trunk normal VLANs: none
    Administrative private-vlan trunk associations: none
    Administrative private-vlan trunk mappings: none
    Operational private-vlan: none
    Trunking VLANs Enabled: ALL
    Pruning VLANs Enabled: 2-1001
    Capture Mode Disabled
    Capture VLANs Allowed: ALL
    
    Protected: false
    Unknown unicast blocked: disabled
    Unknown multicast blocked: disabled
    Appliance trust: none
    
    Name: Fa0/2
    ...
SUMMARY

Parsing fails with textfsm.parser.TextFSMError: State Error raised. Rule Line: 34. Input Line: Unknown unicast blocked: disabled

It seems as if the template has no rule to match the "Unknown unicast blocked" and "Unknown multicast blocked" lines.

Earlier versions (I tried 1.2.1) work fine because they have a ^.+$$ entry at the end.

STEPS TO REPRODUCE

I am using Netmiko send_command() with the use_textfsm=True argument

    show_vlan_result = device.send_command('show interface switchport', use_textfsm=True)
    pprint.pprint(show_vlan_result)
EXPECTED RESULTS
    [{'access_vlan': '1',
      'interface': 'Fa0/1',
      'mode': 'static access',
      'native_vlan': '1',
      'switchport': 'Enabled',
      'switchport_monitor': '',
      'switchport_negotiation': 'On',
      'trunking_vlans': 'ALL',
      'voice_vlan': 'none'},
     {'access_vlan': '1',
     ...
ACTUAL RESULTS
  File "/usr/local/lib/python3.5/dist-packages/netmiko/base_connection.py", line 1355, in send_command
    output, platform=self.device_type, command=command_string.strip()
  File "/usr/local/lib/python3.5/dist-packages/netmiko/utilities.py", line 268, in get_structured_data
    textfsm_obj.ParseCmd(raw_output, attrs)
  File "/usr/local/lib/python3.5/dist-packages/netmiko/_textfsm/_clitable.py", line 272, in ParseCmd
    self.table = self._ParseCmdItem(self.raw, template_file=template_files[0])
  File "/usr/local/lib/python3.5/dist-packages/netmiko/_textfsm/_clitable.py", line 303, in _ParseCmdItem
    for record in fsm.ParseText(cmd_input):
  File "/usr/local/lib/python3.5/dist-packages/textfsm/parser.py", line 895, in ParseText
    self._CheckLine(line)
  File "/usr/local/lib/python3.5/dist-packages/textfsm/parser.py", line 944, in _CheckLine
    if self._Operations(rule, line):
  File "/usr/local/lib/python3.5/dist-packages/textfsm/parser.py", line 1025, in _Operations
    % (rule.line_num, line))
textfsm.parser.TextFSMError: State Error raised. Rule Line: 34. Input Line: Unknown unicast blocked: disabled
@FragmentedPacket
Copy link
Contributor

Do you mind trying #538 and letting us know if that fixes your issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants