Python learning | Part 23 |Netmiko Cisco configuration backup to file with time stamp in filename

Опубликовано: 12 Апрель 2019
на канале: NetworkEvolution
6,830
52

𝗙𝗼𝗿 𝗖𝗼𝗺𝗽𝗹𝗲𝘁𝗲 𝗣𝘆𝘁𝗵𝗼𝗻 𝗙𝗼𝗿 𝗡𝗲𝘁𝘄𝗼𝗿𝗸 𝗘𝗻𝗴𝗶𝗻𝗲𝗲𝗿𝘀 𝗖𝗼𝘂𝗿𝘀𝗲:
𝗘𝗻𝗿𝗼𝗹𝗹 𝗳𝗼𝗿 𝗯𝗲𝗹𝗼𝘄 𝗨𝗱𝗲𝗺𝘆 𝗖𝗹𝗮𝘀𝘀: 𝟐𝟎𝟐𝟐 𝐕𝐞𝐫𝐬𝐢𝐨𝐧
𝑫𝒊𝒔𝒄𝒐𝒖𝒏𝒕𝒆𝒅 𝑹𝒆𝒇𝒆𝒓𝒓𝒂𝒍 𝑳𝒊𝒏𝒌:
https://www.udemy.com/course/python-f... Python Series Complete video Playlist URL :   • Python learning for Network Engineers...  
To stay updated with my latest videos Please subscribe to my channel by clicking below
   / @networkevolution  
This video demonstrates how to take Cisco IOS device configuration backup from the terminal using netmiko and save the file with timestamp.
from netmiko import ConnectHandler
from netmiko.ssh_exception import NetMikoTimeoutException
from paramiko.ssh_exception import SSHException
from netmiko.ssh_exception import AuthenticationException
import time
import datetime

TNOW = datetime.datetime.now().replace(microsecond=0)
IP_LIST = open('15_devices')
for IP in IP_LIST:
print ('\n '+ IP.strip() + ' \n' )
RTR = {
'ip': IP,
'username': 'admin',
'password': 'admin1',
'device_type': 'cisco_ios',
}

try:
net_connect = ConnectHandler(**RTR)
except NetMikoTimeoutException:
print ('Device not reachable.')
continue
except AuthenticationException:
print ('Authentication Failure.')
continue
except SSHException:
print ('Make sure SSH is enabled in device.')
continue

print ('Initiating cofig backup')
output = net_connect.send_command('show run')

SAVE_FILE = open("RTR_"+IP +'_'+ str(TNOW), 'w')
SAVE_FILE.write(output)
SAVE_FILE.close
print ('Finished config backup')
#CiscoConfigbackupNetmiko
#CiscoPythonBackup
#CiscoScheduleBackup


Смотрите видео Python learning | Part 23 |Netmiko Cisco configuration backup to file with time stamp in filename онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь NetworkEvolution 12 Апрель 2019, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 6,830 раз и оно понравилось 52 людям.