From Netmiko import connecthandlerfrom datetime import datetimejtn_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=0for 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+1f=open (file, ' W ') F.write (Showrun) f.closeend_time=datetime.now () Total_time=end_time-start_timeprint total_time
This article is from the "7698164" blog, please be sure to keep this source http://7708164.blog.51cto.com/7698164/1903580
Python automatically acquires Cisco configuration information