这篇文章介绍使用python自动获取cisco配置信息
from netmiko import connecthandler
from datetime import datetime
jtn_core={“device_type”:”cisco_ios”,”ip”:”172.16.5.254″,”username”:”test”,”password”:”#”}
jts_core={“device_type”:”cisco_ios”,”ip”:”172.16.4.254″,”username”:”test”,”password”:””}
start_time=datetime.now()
time=str(start_time)
all_devices=[jtn_core,jts_core]
all_devices_filename=[“jtn_core”+time,”jts_core”+time,]
i=0
for a_device in all_devices:
net_connect=connecthandler(**a_device)
showrun=str(net_connect.send_command(“show run”))
file=all_devices_filename[i]
i=i+1
f=open(file,’w’)
f.write(showrun)
f.close
end_time=datetime.now()
total_time=end_time-start_time
print total_time
以上就是使用python自动获取cisco配置信息的详细内容,更多请关注 第一php社区 其它相关文章!