代码拉取完成,页面将自动刷新
同步操作将从 张鹏/qytang_Python 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/python3
import multiprocessing
from telnetlib import Telnet
from copyrouter import copyrouter
from copysw import copysw
from copyasafinal import copyasa
from copyips import copyips
from finalqytclearLine import routerclearline
from ftp import putfile
from qytmail import qytmail
#from ftp import ftp_up
import time
import os
import shutil
#veconfig = {'R1':'','R2':'','R3':'','R4':'','R5':'','R6':'','ASA1':'','ASA2':'','ASA3sys':'','ASA3admin':'','ASA3c1':'','ASA3c2':'','ASA4':'','SW1':'','SW2':'','SW3':'','SW4':'','SW5':'','SW6':'','IPS':''}
#vfconfig = {'R1':'','R2':'','R3':'','R4':'','R5':'','R6':'','ASA1sys':'','ASA1admin':'','ASA1c1':'','ASA1c2':'','ASA2sys':'','ASA2admin':'','ASA2c1':'','ASA2c2':'','ASA3':'','ASA4':'','SW1':'','SW2':'','SW3':'','SW4':'','SW5':'','SW6':'','IPS':''}
#v10config = {'R1':'','R2':'','R3':'','R4':'','R5':'','R6':'','ASA1':'','ASA3sys':'','ASA3admin':'','ASA3c1':'','ASA3c2':'','ASA4':'','SW1':'','SW2':'','SW3':'','SW4':'','SW5':'','SW6':'','IPS':''}
#v11config = {'R1':'','R2':'','R3':'','R4':'','R5':'','R6':'','ASA1':'','ASA2':'','ASA3sys':'','ASA3admin':'','ASA3c1':'','ASA3c2':'','ASA4':'','SW1':'','SW2':'','SW3':'','SW4':'','SW5':'','SW6':'','IPS':''}
#v12config = {'R1':'','R2':'','R3':'','R4':'','R5':'','R6':'','ASA1sys':'','ASA1admin':'','ASA1c1':'','ASA1c2':'','ASA2sys':'','ASA2admin':'','ASA2c1':'','ASA2c2':'','ASA3':'','ASA4':'','SW1':'','SW2':'','SW3':'','SW4':'','SW5':'','SW6':'','IPS':''}
def copyallconfig(username, password, rackno, verno):
index = []
for i in range(30):
index.append(1)
processes = []
allDone = 0
#清除所有占用的line,准备配置设备
clearlinemp = multiprocessing.Process(target=routerclearline, args=(username, password, rackno))
clearlinemp.start()
time.sleep(10)
# print(clearlinemp.exitcode)
if clearlinemp.exitcode == 3:
os._exit(0)
else:
pass
devices = []
#配置六台路由器
for i in range(6):
newri = i + 1
strri = str(newri)
copyroutermp = multiprocessing.Process(target=copyrouter, args=(username, password, rackno, verno, strri))
processes.append(copyroutermp)
copyroutermp.start()
devices.append('R%s' % str(newri))
time.sleep(10)
#配置六台交换机
for i in range(6):
newsi = i + 1
strsi = str(newsi)
copyswmp = multiprocessing.Process(target=copysw, args=(username, password, rackno, verno, strsi))
processes.append(copyswmp)
copyswmp.start()
devices.append('SW%s' % strsi)
time.sleep(10)
copyipsmp = multiprocessing.Process(target=copyips, args=(username, password, rackno, verno))
processes.append(copyipsmp)
copyipsmp.start()
devices.append('IPS')
if verno == 've'or verno == 'v11':
copyasa1 = multiprocessing.Process(target=copyasa, args=(username, password, rackno, verno, '1'))
processes.append(copyasa1)
devices.append('ASA1')
copyasa1.start()
copyasa2 = multiprocessing.Process(target=copyasa, args=(username, password, rackno, verno, '2'))
processes.append(copyasa2)
devices.append('ASA2')
copyasa2.start()
if verno == 've':
copyasa3sys = multiprocessing.Process(target=copyasa, args=(username, password, rackno, verno, '3', ['admin', 'c1', 'c2']))
processes.append(copyasa3sys)
devices.append('ASA3')
copyasa3sys.start()
else:
copyasa3sys = multiprocessing.Process(target=copyasa, args=(username, password, rackno, verno, '3', ['Admin', 'C1', 'C2']))
processes.append(copyasa3sys)
devices.append('ASA3')
copyasa3sys.start()
copyasa4 = multiprocessing.Process(target=copyasa, args=(username, password, rackno, verno, '4'))
processes.append(copyasa4)
devices.append('ASA4')
copyasa4.start()
if verno == 'vf'or verno == 'v12':
if verno == 'vf':
copyasa1 = multiprocessing.Process(target=copyasa, args=(username, password, rackno, verno, '1', ['admin', 'c1', 'c2']))
processes.append(copyasa1)
devices.append('ASA1')
copyasa1.start()
copyasa2 = multiprocessing.Process(target=copyasa, args=(username, password, rackno, verno, '2', ['admin', 'c1', 'c2']))
processes.append(copyasa2)
devices.append('ASA2')
copyasa2.start()
else:
copyasa1 = multiprocessing.Process(target=copyasa, args=(username, password, rackno, verno, '1', ['Admin', 'C1', 'C2']))
processes.append(copyasa1)
devices.append('ASA1')
copyasa1.start()
copyasa2 = multiprocessing.Process(target=copyasa, args=(username, password, rackno, verno, '2', ['Admin', 'C1', 'C2']))
processes.append(copyasa2)
devices.append('ASA2')
copyasa2.start()
copyasa3 = multiprocessing.Process(target=copyasa, args=(username, password, rackno, verno, '3'))
processes.append(copyasa3)
devices.append('ASA3')
copyasa3.start()
copyasa4 = multiprocessing.Process(target=copyasa, args=(username, password, rackno, verno, '4'))
processes.append(copyasa4)
devices.append('ASA4')
copyasa4.start()
if verno == 'v10':
copyasa1 = multiprocessing.Process(target=copyasa, args=(username, password, rackno, verno, '1'))
processes.append(copyasa1)
devices.append('ASA1')
copyasa1.start()
copyasa3 = multiprocessing.Process(target=copyasa, args=(username, password, rackno, verno, '3', ['admin', 'c1', 'c2']))
processes.append(copyasa3)
devices.append('ASA3')
copyasa3.start()
copyasa4 = multiprocessing.Process(target=copyasa, args=(username, password, rackno, verno, '4'))
processes.append(copyasa4)
devices.append('ASA4')
copyasa4.start()
#等待配置结束的信息
clock1 = time.clock()
while True:
clock2 = time.clock()
timetouse = int((clock2 - clock1) * 1000)
stringtimetouse = str(timetouse)
print('Use time: ' + stringtimetouse)
if verno == 'v10':
os.system('clear')
allDone = index.count(0)
if allDone == 16: break
for i in range(16):
if processes[i].exitcode == 0:
index[i] = 0
print('%s done' % devices[i])
else:
print('%s copying' % devices[i])
else:
os.system('clear')
allDone = index.count(0)
if allDone == 17: break
for i in range(17):
if processes[i].exitcode == 0:
index[i] = 0
print('%s done' % devices[i])
else:
print('%s copying' % devices[i])
if timetouse > 60:
print('Timeout')
if verno == 'v10':
for i in range(16):
try:
processes[i].terminate()
except:
pass
result = 0
else:
for i in range(17):
try:
processes[i].terminate()
except:
pass
result = 0
break
time.sleep(3)
timelst = time.asctime().split(' ')
finalconfigfile = '/python/cgi-bin/bakconfig/' + rackno + '-' + verno + '-' + yourname + '-' + timelst[5] + '-' + timelst[1] + '-' + timelst[3] + '.txt'
fianlconfig = open(finalconfigfile, 'w')
os.system('clear')
print('Waiting For create finalconfig')
for i in range(6):
i = i + 1
routerno = str(i)
configfile = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'R' + routerno + '.txt'
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'R' + routerno + '=' * 30 + '\n')
config = (open(configfile, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
os.system('clear')
print('Router config joined in finalconfig')
if verno == 've':
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA1' + '=' * 30 + '\n')
configfileasa1 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA1' + '.txt'
config = (open(configfileasa1, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA2' + '=' * 30 + '\n')
configfileasa2 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA2' + '.txt'
config = (open(configfileasa2, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA3/SYS' + '=' * 30 + '\n')
configfileasa3 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA3' + '.txt'
config = (open(configfileasa3, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA3/admin' + '=' * 30 + '\n')
configfileasa3admin = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA3admin' + '.txt'
config = (open(configfileasa3admin, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA3/c1' + '=' * 30 + '\n')
configfileasa3c1 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA3c1' + '.txt'
config = (open(configfileasa3c1, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA3/c2' + '=' * 30 + '\n')
configfileasa3c2 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA3c2' + '.txt'
config = (open(configfileasa3c2, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA4' + '=' * 30 + '\n')
configfileasa4 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA4' + '.txt'
config = (open(configfileasa4, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
if verno == 'v11':
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA1' + '=' * 30 + '\n')
configfileasa1 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA1' + '.txt'
config = (open(configfileasa1, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA2' + '=' * 30 + '\n')
configfileasa2 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA2' + '.txt'
config = (open(configfileasa2, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA3/SYS' + '=' * 30 + '\n')
configfileasa3 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA3' + '.txt'
config = (open(configfileasa3, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA3/admin' + '=' * 30 + '\n')
configfileasa3admin = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA3Admin' + '.txt'
config = (open(configfileasa3admin, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA3/c1' + '=' * 30 + '\n')
configfileasa3c1 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA3C1' + '.txt'
config = (open(configfileasa3c1, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA3/c2' + '=' * 30 + '\n')
configfileasa3c2 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA3C2' + '.txt'
config = (open(configfileasa3c2, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA4' + '=' * 30 + '\n')
configfileasa4 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA4' + '.txt'
config = (open(configfileasa4, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
if verno == 'vf':
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA1/SYS' + '=' * 30 + '\n')
configfileasa1 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA1' + '.txt'
config = (open(configfileasa1, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA1/admin' + '=' * 30 + '\n')
configfileasa1admin = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA1admin' + '.txt'
config = (open(configfileasa1admin, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA1/c1' + '=' * 30 + '\n')
configfileasa1c1 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA1c1' + '.txt'
config = (open(configfileasa1c1, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA1/c2' + '=' * 30 + '\n')
configfileasa1c2 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA1c2' + '.txt'
config = (open(configfileasa1c2, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA2/SYS' + '=' * 30 + '\n')
configfileasa2 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA2' + '.txt'
config = (open(configfileasa2, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA2/admin' + '=' * 30 + '\n')
configfileasa2admin = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA2admin' + '.txt'
config = (open(configfileasa2admin, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA2/c1' + '=' * 30 + '\n')
configfileasa2c1 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA2c1' + '.txt'
config = (open(configfileasa2c1, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA2/c2' + '=' * 30 + '\n')
configfileasa2c2 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA2c2' + '.txt'
config = (open(configfileasa2c2, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA3' + '=' * 30 + '\n')
configfileasa3 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA3' + '.txt'
config = (open(configfileasa3, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA4' + '=' * 30 + '\n')
configfileasa4 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA4' + '.txt'
config = (open(configfileasa4, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
if verno == 'v12':
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA1/SYS' + '=' * 30 + '\n')
configfileasa1 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA1' + '.txt'
config = (open(configfileasa1, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA1/admin' + '=' * 30 + '\n')
configfileasa1admin = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA1Admin' + '.txt'
config = (open(configfileasa1admin, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA1/c1' + '=' * 30 + '\n')
configfileasa1c1 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA1C1' + '.txt'
config = (open(configfileasa1c1, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA1/c2' + '=' * 30 + '\n')
configfileasa1c2 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA1C2' + '.txt'
config = (open(configfileasa1c2, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA2/SYS' + '=' * 30 + '\n')
configfileasa2 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA2' + '.txt'
config = (open(configfileasa2, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA2/admin' + '=' * 30 + '\n')
configfileasa2admin = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA2Admin' + '.txt'
config = (open(configfileasa2admin, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA2/c1' + '=' * 30 + '\n')
configfileasa2c1 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA2C1' + '.txt'
config = (open(configfileasa2c1, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA2/c2' + '=' * 30 + '\n')
configfileasa2c2 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA2C2' + '.txt'
config = (open(configfileasa2c2, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA3' + '=' * 30 + '\n')
configfileasa3 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA3' + '.txt'
config = (open(configfileasa3, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA4' + '=' * 30 + '\n')
configfileasa4 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA4' + '.txt'
config = (open(configfileasa4, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
if verno == 'v10':
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA1'+ '=' * 30 + '\n')
configfileasa1 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA1' + '.txt'
config = (open(configfileasa1, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA3/SYS' + '=' * 30 + '\n')
configfileasa3 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA3' + '.txt'
config = (open(configfileasa3, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA3/admin' + '=' * 30 + '\n')
configfileasa3admin = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA3admin' + '.txt'
config = (open(configfileasa3admin, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA3/c1' + '=' * 30 + '\n')
configfileasa3c1 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA3c1' + '.txt'
config = (open(configfileasa3c1, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA3/c2' + '=' * 30 + '\n')
configfileasa3c2 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA3c2' + '.txt'
config = (open(configfileasa3c2, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'ASA4' + '=' * 30 + '\n')
configfileasa4 = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'ASA4' + '.txt'
config = (open(configfileasa4, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
os.system('clear')
print('ASA config joined in finalconfig')
for i in range(6):
i = i + 1
swno = str(i)
configfile = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'SW' + swno + '.txt'
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'SW' + swno + '=' * 30 + '\n')
config = (open(configfile, 'r')).read()
fianlconfig.write(config)
time.sleep(2)
except:
pass
os.system('clear')
print('SW config joined in finalconfig')
try:
fianlconfig.write('\n')
fianlconfig.write('=' * 30 + 'IPS' + '=' * 30 + '\n')
configfileips = '/python/cgi-bin/tmpconfig/' + verno + '/' + 'IPS' + '.txt'
config = (open(configfileips, 'r')).read()
print(config)
fianlconfig.write(config)
time.sleep(2)
except:
print('IPS config error')
fianlconfig.close()
os.system('clear')
print('IPS config joined in finalconfig')
tmpfiledir = '/python/cgi-bin/tmpconfig/' + verno + '/'
for file in os.listdir(tmpfiledir):
removefile = os.path.join(tmpfiledir, file)
if os.path.isfile(removefile):
os.remove(removefile)
os.system('clear')
print('Clearing tmp config')
# finalconfigfile = '/python/cgi-bin/bakconfig/' + rackno + '-' + verno + '-' + yourname + '-' + timelst[5] + '-' + timelst[1] + '-' + timelst[3] + '.txt'
os.chdir('/python/cgi-bin/bakconfig')
uploadfile = rackno + '-' + verno + '-' + yourname + '-' + timelst[5] + '-' + timelst[1] + '-' + timelst[3] + '.txt'
cmd = 'unix2dos %s' % uploadfile
os.system(cmd)
site = '172.17.100.205'
dir = '.'
os.system('clear')
print('uploading finalconfig file')
putfile(uploadfile, site, dir, user = ('labtest', 'Cisc0123'))
os.system('clear')
# ftp_up(configfileips)
print('ALL DONE!!!!!!')
mailtext = 'copy rack config ' + rackno + ' ' + verno
qytmail(username, mailtext)
if __name__ == "__main__":
import getpass
yourname = input('Your Username: ')
if yourname.strip() == '':
print('!' * 60)
print(' ' * 18 + 'Need Username')
print('!' * 60)
os._exit(0)
yourpw = getpass.getpass('Your Password: ')
if yourpw.strip() == '':
print('!' * 60)
print(' ' * 18 + 'Need Password')
print('!' * 60)
os._exit(0)
print('ve or vf or v10 or v11 or v12')
version = input('Your want to export which version: ')
if version == 've' or version == 'vf' or version == 'v10' or version == 'v11' or version == 'v12':
pass
else:
print('!' * 60)
print(" Version must in 've or vf or v10 or v11 or v12'")
print('!' * 60)
os._exit(0)
print('Serious attention the Rack is in you control')
print('BJRack01 or BJRack02 or BJRack03')
rackno1 = input('The Rack you want to config: ')
rackno2 = input('Reconfirm the Rack: ')
if rackno1 == rackno2:
rackno = rackno1
if rackno == 'BJRack01' or rackno == 'BJRack02' or rackno == 'BJRack03':
copyallconfig(yourname, yourpw, rackno, version)
else:
print('!' * 60)
print(" Rack Name must in 'BJRack01 or BJRack02 or BJRack03'")
print('!' * 60)
else:
print('!' * 60)
print(' Rackno Missmatch, Try again')
print('!' * 60)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。