Update ping trước khi load ios, license
This commit is contained in:
parent
c18b8aeff2
commit
0bb2ce2e63
|
|
@ -142,6 +142,8 @@ export default class LineConnection {
|
||||||
private testingPortPoE: boolean
|
private testingPortPoE: boolean
|
||||||
private outputTestingPortPoE: string
|
private outputTestingPortPoE: string
|
||||||
private debounceSendSummaryReport: NodeJS.Timeout | null = null
|
private debounceSendSummaryReport: NodeJS.Timeout | null = null
|
||||||
|
private isPingToServer: boolean
|
||||||
|
private outputPingToServer: string
|
||||||
|
|
||||||
constructor(config: LineConfig, socketIO: any, handleClearLine: () => void) {
|
constructor(config: LineConfig, socketIO: any, handleClearLine: () => void) {
|
||||||
this.config = config
|
this.config = config
|
||||||
|
|
@ -175,6 +177,8 @@ export default class LineConnection {
|
||||||
this.debounceSendSummaryReport = null
|
this.debounceSendSummaryReport = null
|
||||||
this.testingPortPoE = false
|
this.testingPortPoE = false
|
||||||
this.outputTestingPortPoE = ''
|
this.outputTestingPortPoE = ''
|
||||||
|
this.isPingToServer = false
|
||||||
|
this.outputPingToServer = ''
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Connect to line with socket
|
* Connect to line with socket
|
||||||
|
|
@ -237,6 +241,8 @@ export default class LineConnection {
|
||||||
this.flushLogBuffer()
|
this.flushLogBuffer()
|
||||||
}, 1000) // 1s debounce
|
}, 1000) // 1s debounce
|
||||||
}
|
}
|
||||||
|
if (this.isPingToServer) this.outputPingToServer += cleanData(data.toString())
|
||||||
|
|
||||||
if (data.toString().includes('More') || data.toString().includes('MORE'))
|
if (data.toString().includes('More') || data.toString().includes('MORE'))
|
||||||
this.writeCommand(' ')
|
this.writeCommand(' ')
|
||||||
|
|
||||||
|
|
@ -1946,4 +1952,26 @@ ${log}
|
||||||
this.sendFeatureTested()
|
this.sendFeatureTested()
|
||||||
console.log('Reset DPELP data and features', this.config.id, this.config.listFeatureTested)
|
console.log('Reset DPELP data and features', this.config.id, this.config.listFeatureTested)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async pingToServer(serverIP: string) {
|
||||||
|
this.isPingToServer = true
|
||||||
|
this.writeCommand('\r\n')
|
||||||
|
this.writeCommand('enable\r\n')
|
||||||
|
await sleep(500)
|
||||||
|
this.writeCommand(`ping ${serverIP}\r\n`)
|
||||||
|
await sleep(500)
|
||||||
|
const start = Date.now()
|
||||||
|
// console.log('[EXPECT]', expect, timeout)
|
||||||
|
while (Date.now() - start < 60000) {
|
||||||
|
if (this.outputPingToServer.includes('Success rate')) {
|
||||||
|
this.outputPingToServer = ''
|
||||||
|
this.isPingToServer = false
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
await sleep(500)
|
||||||
|
}
|
||||||
|
this.isPingToServer = false
|
||||||
|
this.outputPingToServer = ''
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -961,6 +961,9 @@ export function buildBody(
|
||||||
note: '',
|
note: '',
|
||||||
},
|
},
|
||||||
{ expect: '', send: ``, delay: '4', repeat: '1', note: '' },
|
{ expect: '', send: ``, delay: '4', repeat: '1', note: '' },
|
||||||
|
{ expect: '', send: `ping ${tftpIp}`, delay: '3', repeat: '1', note: '' },
|
||||||
|
{ expect: 'Success rate', send: ``, delay: '2', repeat: '1', note: '' },
|
||||||
|
{ expect: '', send: ``, delay: '2', repeat: '1', note: '' },
|
||||||
{
|
{
|
||||||
expect: '#',
|
expect: '#',
|
||||||
send: listDeviceIos?.includes(fileName) ? '' : `copy tftp: flash:`,
|
send: listDeviceIos?.includes(fileName) ? '' : `copy tftp: flash:`,
|
||||||
|
|
@ -1145,6 +1148,9 @@ export function buildBody(
|
||||||
repeat: '1',
|
repeat: '1',
|
||||||
note: '',
|
note: '',
|
||||||
},
|
},
|
||||||
|
{ expect: '', send: `ping ${tftpIp}`, delay: '3', repeat: '1', note: '' },
|
||||||
|
{ expect: 'Success rate', send: ``, delay: '2', repeat: '1', note: '' },
|
||||||
|
{ expect: '', send: ``, delay: '2', repeat: '1', note: '' },
|
||||||
{
|
{
|
||||||
expect: '#',
|
expect: '#',
|
||||||
send: `license install tftp://${tftpIp}/License/${fileName}`,
|
send: `license install tftp://${tftpIp}/License/${fileName}`,
|
||||||
|
|
@ -1306,6 +1312,9 @@ export function buildBody(
|
||||||
repeat: '1',
|
repeat: '1',
|
||||||
note: '',
|
note: '',
|
||||||
},
|
},
|
||||||
|
{ expect: '', send: `ping ${tftpIp}`, delay: '3', repeat: '1', note: '' },
|
||||||
|
{ expect: 'Success rate', send: ``, delay: '2', repeat: '1', note: '' },
|
||||||
|
{ expect: '', send: ``, delay: '2', repeat: '1', note: '' },
|
||||||
{
|
{
|
||||||
expect: '#',
|
expect: '#',
|
||||||
send: `license install tftp://${tftpIp}/License/${fileName}`,
|
send: `license install tftp://${tftpIp}/License/${fileName}`,
|
||||||
|
|
|
||||||
|
|
@ -763,6 +763,8 @@ export class WebSocketIo {
|
||||||
[lineId],
|
[lineId],
|
||||||
async (lineCon) => {
|
async (lineCon) => {
|
||||||
if (isReboot) {
|
if (isReboot) {
|
||||||
|
const pingSuccess = await lineCon.pingToServer(station?.tftp_ip || '172.16.7.69')
|
||||||
|
if (!pingSuccess) return
|
||||||
await lineCon.backupIos(iosName)
|
await lineCon.backupIos(iosName)
|
||||||
if (!outletNumber || outletNumber < 0) return
|
if (!outletNumber || outletNumber < 0) return
|
||||||
if (!station) return
|
if (!station) return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue