Print

如何实现定期报错设备配置到目标主机

2020-10-30 发表

组网及说明

不涉及

问题描述

客户需求:定期备份配置文件到目标主机

过程分析

定时任务+python脚本实现

解决方法

命令行配置:

# scheduler job backcfg 

 command 1 save fo 

 command 2 python HXbackcfg.py

 # scheduler schedule backcfgauto 

 user-role network-operator 

 user-role network-admin 

 job backcfg time 

 repeating at 02:30

 #


py脚本:

#!/usr/bin/python 

#_*_ coding:utf-8 _*_ 

import time 

import comware 

import socket 

a=str(socket.gethostname()) 

b=str(time.strftime('%d%b%Y')) 

c=('tftp 1.1.1.1 put startup.cfg /'+a+'/'+a+'_'+b+'.cfg vpn-instance vpn-mgt') 

comware.CLI(c)