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 vlans sometimes return extra whitespaces that breaks parsing #1838

Closed
gertzakis opened this issue Sep 18, 2024 · 0 comments · Fixed by #1840
Closed

Cisco IOS show vlans sometimes return extra whitespaces that breaks parsing #1838

gertzakis opened this issue Sep 18, 2024 · 0 comments · Fixed by #1840

Comments

@gertzakis
Copy link
Contributor

ISSUE TYPE
  • Template Issue with error and raw data
TEMPLATE USING
Value Required VLAN_ID (\d+)
Value List INTERFACES ([\w\./-]+)
Value List IP_ADDRESSES (\S+)
Value List IPV6_ADDRESSES (\S+)

Start
  ^VLAN\s+ID:\s+${VLAN_ID} -> Data
  ^Virtual\s+LAN\s+ID\:\s+${VLAN_ID} -> Data
  ^No\s+Virtual\s+LANs\s+configured
  ^\s*$$
  ^. -> Error

Data
  ^Virtual\s+LAN\s+ID\:\s+\d.* -> Continue.Record
  ^Virtual\s+LAN\s+ID\:\s+${VLAN_ID}.*
  ^VLAN\s+ID:\s+\d+ -> Continue.Record
  ^VLAN\s+ID:\s+${VLAN_ID}
  ^\s+This\s+is\s+configured\s+as\s+native\s+Vlan\s+for\s+the\s+following\s+interface\(s\)\s+:\s*$$
  ^\S+(\s+Native-vlan\s+Tx-type:\s+\S+)?\s*$$
  ^\s+Protocols\s+Configured
  ^\s+IP\s+\d+\s+\d+
  ^\s+MPLS\s+\d+\s+\d+
  ^\s+MPLS\:\s+\S+
  ^\s+[vV]LAN\s+Trunk\s+Interfaces?\:\s+${INTERFACES} -> Interface
  ^VLAN\s+trunk\s+interfaces -> Interface
  ^[\w\./]+\s*$$
  ^${INTERFACES}\s+\(\d+\)\s*$$
  ^\s+IP:\s+${IP_ADDRESSES}\s*$$
  ^\s+IP\s+${IP_ADDRESSES}\s+
  ^\s+IPv6:\s+${IPV6_ADDRESSES}\s*$$
  ^\s+IPv6\s+${IPV6_ADDRESSES}\s+\d+\s+\d+
  ^\s+Other\s+
  ^\s+IPv6\s+\d+\s+\d+
  ^\s+Total\s\d+
  ^\s+\d+\s+packets,
  ^\s*$$
  ^. -> Error Data

Interface
  ^\s*${INTERFACES}\s*$$
  ^\s*\S+\s+\(\S+\)$$
  ^\s+Total\s+\d+\s+
  ^\s+IP\:\s+${IP_ADDRESSES}
  ^\s+IPv6\:\s+${IPV6_ADDRESSES}
  ^\s+MPLS\:\s+
  ^\s+Protocols\s+Configured\: -> Data
  ^\s+This\s+is\s+configured\s+as\s+native\s+Vlan -> Data
  ^Virtual\s+LAN\s+ID\:\s+\d.* -> Continue.Record
  ^Virtual\s+LAN\s+ID\:\s+${VLAN_ID}.* -> Data
  ^VLAN\s+ID:\s+\d+ -> Continue.Record
  ^VLAN\s+ID:\s+${VLAN_ID} -> Data
  ^. -> Error Interface
SAMPLE COMMAND OUTPUT

Please notice the extra white spaces & tabs at the empty line between "vLAN Trunk Interface" and "Protocols Configured".


Virtual LAN ID:  1280 (IEEE 802.1Q Encapsulation)

   vLAN Trunk Interface:   GigabitEthernet9.1280
          
   Protocols Configured:   Address:              Received:        Transmitted:

GigabitEthernet9.1280 (1280)
           IP              10.49.14.129                 0                   0
        Other                                           0                   2

   0 packets, 0 bytes input
   2 packets, 92 bytes output

SUMMARY

The extra white spaces break the parsing of the command.

STEPS TO REPRODUCE
EXPECTED RESULTS

The output to be parsed without any issues and get data.

ACTUAL RESULTS

Parsing failed with the below error.

"Error: Interface. Rule Line: 52. Input Line:           ."
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 a pull request may close this issue.

1 participant