生活随笔
收集整理的這篇文章主要介紹了
交换机用python定时备份
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#!/usr/bin/env?python
#?encoding:?utf-8from?netmiko?import?ConnectHandlerclass?switch(object):def?__init__(self):self.switch_list?=?['1.1.1.1','2.2.2.2',]def?con_switch(self):for?i?in?self.switch_list:huawei?=?{'device_type':?'huawei','ip':?i,'username':?'xxxx','password':?'xxxx','port'?:?22,??????????'verbose':?False,???????#?optional,?defaults?to?False?????????}try:net_connect?=?ConnectHandler(**huawei)except?expression?as?identifier:print?iexitoutput?=?net_connect.send_command('tftp?3.3.3.3?put?startup.cfg?%s_startup.cfg'?%?i)print?i?+?':'?+?outputif?__name__?==?"__main__":run?=?switch()run.con_switch()
yum?install?xinetd?tftp-server?tftp?-y
mkdir?/data/network
cat?/etc/xinetd.d/tftp????#?default:?off
#?description:?The?tftp?server?serves?files?using?the?trivial?file?transfer?\
#???????protocol.??The?tftp?protocol?is?often?used?to?boot?diskless?\
#???????workstations,?download?configuration?files?to?network-aware?printers,?\
#???????and?to?start?the?installation?process?for?some?operating?systems.
service?tftp
{socket_type?????????????=?dgramprotocol????????????????=?udpwait????????????????????=?yesuser????????????????????=?rootserver??????????????????=?/usr/sbin/in.tftpdserver_args?????????????=?-s?/data/network/?-cdisable?????????????????=?noper_source??????????????=?11cps?????????????????????=?100?2flags???????????????????=?IPv4
}
systemctl?start?xinetd.service
systemctl?enable?tftp.service
轉載于:https://blog.51cto.com/6545438/2335157
總結
以上是生活随笔為你收集整理的交换机用python定时备份的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。