#!/usr/bin/python36
# -*- coding: UTF-8 -*-
import netmiko
from netmiko import ConnectHandler
#Netmiko example
iosv_l2_s5 = {
'device_type': 'cisco_ios',
'ip': '192.168.122.75',
'username': 'cisco',
'password': 'cisco'
'secret':'cisco'
}
with open('iosv_l2_config') as f:
lines = f.read().splitlines()
print (lines)
all_devices = [iosv_l2_s5]
for devices in all_devices:
net_connect = ConnectHandler(**devices)
output = net_connect.send_config_set(lines) #配置交换机
print (output)
iosv_l2_config #配置命令所在的文件
#Configure Context
#vlan 2
# name Data
#interface FastEthernet0/23
#switch mode access
#switch access vlan 20