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

show mac address-table Error: State Error raised. Rule Line: 41. #715

Closed
alepodj opened this issue May 21, 2020 · 7 comments
Closed

show mac address-table Error: State Error raised. Rule Line: 41. #715

alepodj opened this issue May 21, 2020 · 7 comments

Comments

@alepodj
Copy link
Contributor

alepodj commented May 21, 2020

ISSUE TYPE

  • Bug Report? Not certain is an actual bug, i could be doing something wrong!

Context

netmiko==3.1.0
ntc-templates==1.4.1
textfsm==1.1.0
TEMPLATE USING
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 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*${VLAN}\s+${DESTINATION_ADDRESS}\s+${TYPE}\s+\S+\s+\S+\s+${DESTINATION_PORT} -> Record
  ^-+\+-+
  ^Displaying\s+entries
  ^\s+vlan\s+mac address\s+type\s+learn\s+age\s+ports
  ^\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

SAMPLE COMMAND OUTPUT
--> As typed directly on the switch <--
router#show mac address-table
Unicast Entries
 vlan     mac address     type        protocols               port
---------+---------------+--------+---------------------+-------------------------
   1      0000.1111.2222   dynamic ip,ipx,assigned,other GigabitEthernet1/19
   10    5555.6666.7777   dynamic ip,ipx,assigned,other Switch
   20    33aa.00bb.9999   dynamic ip,ipx,assigned,other Port-channel2
   Gi1/1 aaaa.bbbb.cccc    dynamic ip,ipx,assigned,other GigabitEthernet1/1

.....Output is too long to display, collected lines as is that show variety of types of entries, last line displayed above is the one that throws the error, some vlan entries are not just numbers but interface ids
SUMMARY
show mac address table throws and error
STEPS TO REPRODUCE
import os 
import json
import ntc_templates
from netmiko import Netmiko
from netmiko import NetMikoAuthenticationException

switch = {'device_type': 'cisco_ios',
                'ip': '192.168.0.1',
                'username': 'admin',
                'password': 'admin',
                'secret': 'admin',
                'timeout': 10000,
                'session_timeout': 10000}
try: 
    c = Netmiko(**switch)
    c.enable()
    show_mac_addr_table = c.send_command(f'show mac address-table', use_textfsm=True)
    print(show_mac_addr_table)
except Exception as e:
    print(e)
EXPECTED RESULTS
A list of dictionaries for each line returned as the usual default behavior
ACTUAL RESULTS
Error's out
State Error raised. Rule Line: 41. Input Line: Gi1/1     aaaa.bbbb.cccc   dynamic ip,ipx,assigned,other GigabitEthernet1/1
@jmcgill298
Copy link
Contributor

This was fixed in 66d5f45

@alepodj
Copy link
Contributor Author

alepodj commented May 21, 2020

So is this error specific to me? Cause i still get it and i have the latest updates.

Seems to happen when Gi1/1 shows in the VLAN field, instead of just spaces and numbers

My template file matches the changes made at commit above:

Value TYPE (\S+)
Value VLAN (\S+)

@jmcgill298
Copy link
Contributor

I'm not sure how you installed the templates, but if you did a git clone, then you can just pull down the latest updates. If you installed the templates in another way, then you would have to replicate the update into your environment.

@jmcgill298
Copy link
Contributor

It doesn't appear that Netmiko is using the template that you have with the updates. I took your data and used it against the current template, and it parsed fine for me.

@alepodj
Copy link
Contributor Author

alepodj commented May 22, 2020

Spot on! Thanks @jmcgill298 i manually downloaded the templates folder and copied/replaced the one in the python package as well as the parse.py and init.py for good measure and lo and behold it now works :)

Interesting part i only installed this package via package via pip and never touched it, so that's a head scratcher...but nonetheless is working now. Thanks a lot for the assist!

Cheers

@jmcgill298
Copy link
Contributor

well pip installed the official release on PyPI. The update was pretty recent, and so PyPI has not had a new release added yet.

@alepodj
Copy link
Contributor Author

alepodj commented May 27, 2020

:)

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

No branches or pull requests

2 participants