Use python to automatically obtain cisco configuration information

高洛峰
Release: 2017-03-10 19:04:48
Original
1759 people have browsed it

This article introduces the use of python to automatically obtain cisco configuration information

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
Copy after login


The above is the detailed content of Use python to automatically obtain cisco configuration information. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!