I am running this script on 2 different switch stacks, both 3650s running 16.3.6. One is a stack of 3 and the other is a stack of 4
On the stack of 3 it only comes back with the 1sw ports.
When I run it on the stack of 4 I get all the interfaces from all 4 switches.
I can run it from the CLI with no issue and get all the ports on the 3 switch stack
from netmiko import ConnectHandler
from operator import itemgetter
from getpass import getpass
import json
IP = input('IP of switch: ')
username = input('Enter your username: ')
password = getpass()
SW = {
'ip': IP,
'username': username,
'password': password,
'device_type': 'cisco_ios',
}
net_connect = ConnectHandler(**SW)
interfaces = net_connect.send_command('show interface switchport', use_textfsm=True)
l = len(interfaces)
print(json.dumps(interfaces, indent=2))
print ('total number of interfaces are ' + str(l))
No comments:
Post a Comment