码迷,mamicode.com
首页 > 编程语言 > 详细

python自动获取cisco配置信息

时间:2017-03-06 15:15:43      阅读:393      评论:0      收藏:0      [点我收藏+]

标签:python   network   

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

本文出自 “7698164” 博客,请务必保留此出处http://7708164.blog.51cto.com/7698164/1903580

python自动获取cisco配置信息

标签:python   network   

原文地址:http://7708164.blog.51cto.com/7698164/1903580

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!