Automatizando Backup de OLTs Fiberhome via terminal

Share Button

English title: Automating Backups of Fiberhome OLTs over line comand

downloadbk-olt-fiberhome.py é um simples script para automatização de backup de OLTs Fiberhome, sem a necessidade do software de gerencia ANM2000 instalado.

Usage
./bk-olt-fiberhome.py IP_ADDRESS

Configuration
Don’t forgot to configure all variables in file bk-olt-fiberhome.py
=======================================================================
user = ‘GEPON’
password = ‘GEPON’
FTPSERVER = ‘200.200.200.200’
ftpuser = ‘user’
ftppassword = ‘123456’
=======================================================================

Link para o GitHub


#!/usr/bin/python
#-------------------------------------
#by Jorge Luiz Taioque
#jorgeluiztaioque at gmail dot com
#www.networktips.com.br
#-------------------------------------
#backup OLTs and ONUs fiberhome
#Usage 
#./bk-olt-fiberhome.py IP_ADDRESS


import sys,pexpect
import getpass
import time

HOST = sys.argv[1]

#configure here all variables following you system 
#=======================================================================
user = 'GEPON'
password = 'GEPON'
FTPSERVER = '200.200.200.200'
ftpuser = 'user'
ftppassword = '123456'
#=======================================================================


child = pexpect.spawn ('telnet '+HOST) #option needs to be a list
child.timeout = 150
child.logfile = sys.stdout #display progress on screen

#loging to OLT IP
time.sleep(2)
child.expect ('Login: ') #waiting for login
child.sendline (user) #sending login name
child.expect('Password:') #waiting for password
child.sendline (password) #sending password
child.expect('>')

time.sleep(3)

#go up enable configuration
child.sendline ('EN'+'\r') #going to ENABLE configuration
child.expect('Password:') #waiting enable password
child.sendline (password) #sending enable password 
time.sleep(3)
child.expect('#')

#sending commando to copy configuration file to remote FTP server
child.sendline ('upload ftp config '+FTPSERVER+' '+ftpuser+' '+ftppassword+' bk-olt-'+HOST+'-.cfg')
time.sleep(10)

#exiting connection
child.expect('#')
child.sendline ('exit \r')
child.sendline ('exit \r')