You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 | include 0000.1111.2222|3333.4444.5555|6666.7777.8888
10 0000.1111.2222 dynamic ip,ipx,assigned,other GigabitEthernet2/9
10 3333.4444.5555 dynamic ip,ipx,assigned,other GigabitEthernet2/4
10 6666.7777.8888 dynamic ip,ipx,assigned,other GigabitEthernet2/5
SUMMARY
show mac address table is not returning a dictionary. At first i figure it was cause i was using a pipe to filter the output in cisco, but turns out that same setup works for `show ip arp | include {macs}`
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}
macs = '0000.1111.2222|3333.4444.5555|6666.7777.8888'
try:
c = Netmiko(**switch)
c.enable()
show_mac_addr_table = c.send_command(f'show mac address-table | include {macs}', use_textfsm=True)
print(show_mac_addr_table)
except Exception as e:
print(e)
EXPECTED RESULTS
A a list of dictionaries for each line returned as the usual default behavior
When parsing, there is an assumption that the template receives the entire output. At times, I am sure there is no effect by using an include as you have here, but in this case it does. The header is used to determine which of the four different potential table outputs you could have.
So removing the | include 0000.1111.2222|3333.4444.5555|6666.7777.8888 should return data
If you have any other questions, likely easier to continue convo on Slack, can sign up here: https://networktocode.herokuapp.com/ and best to ask on the #networktocode channel within that slack community.
Yeah i see now, piping the show mac address-table command responds without table header but so does show ip arp | include xxx which is interesting i see both rules are quite different. Thanks for the heads up
ISSUE TYPE
Context
TEMPLATE USING
SAMPLE COMMAND OUTPUT
SUMMARY
STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: