TextFSMError "show mac address-table interface <port>" & "port-security" get error message #2587
Unanswered
khanhvc2003
asked this question in
Q&A
Replies: 1 comment 1 reply
-
You will have to provide some more details on what the error/issue that you are seeing? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I using "show mac address-table interface " and use_textfsm, but the code is not work when cli "switchport port-security" be config on interface.
Please kindly give me advice for this one.
Thanks in advance
This is my code:
`'''
====== if we config 'switchport port-security' it will be got error at use_textfsm
interface FastEthernet0/3
switchport access vlan 105
switchport mode access
switchport port-security
spanning-tree portfast
end
'''
from netmiko import ConnectHandler
def sh_mac_int(port):
sh_mac_int_cmd = f"show mac address-table interface {port}" # (02)
sh_mac_int_cmd = net_connect.send_command(sh_mac_int_cmd, use_textfsm = True)
print (sh_mac_int_cmd)
if type(sh_mac_int_cmd) is str:
return "unknown"
else:
if len(sh_mac_int_cmd) == 1:
return "End point device"
else:
return "Link to other"
Sw_1 = {
"host":"192.168.100.18",
"username":"admin",
"password":"l2Hsv-Tw!!)",
"device_type":"cisco_ios"
}
print(f"Connecting to a host: {Sw_1['host']} ...\n")
net_connect = ConnectHandler(**Sw_1)
print("Connected successfully")
port = "f0/3"
print (sh_mac_int(port))
`
Beta Was this translation helpful? Give feedback.
All reactions