From e14d4ca216900a8cb754ac567c81de0fbba31d8f Mon Sep 17 00:00:00 2001 From: nguyentrungthat <80239428+nguentrungthat@users.noreply.github.com> Date: Mon, 5 Jan 2026 16:59:00 +0700 Subject: [PATCH] Update load IOS switch --- BACKEND/app/services/line_connection.ts | 184 +++++++++++------- .../src/components/Modal/ModalTerminal.tsx | 36 ++-- 2 files changed, 133 insertions(+), 87 deletions(-) diff --git a/BACKEND/app/services/line_connection.ts b/BACKEND/app/services/line_connection.ts index a4db2c0..6f9880b 100644 --- a/BACKEND/app/services/line_connection.ts +++ b/BACKEND/app/services/line_connection.ts @@ -1146,6 +1146,13 @@ export default class LineConnection { repeat: '1', note: '', }, + { + expect: '#', + send: `show version`, + delay: '1', + repeat: '1', + note: '', + }, { expect: '#', send: `configure terminal`, @@ -1205,76 +1212,6 @@ export default class LineConnection { const timeZone = process.env.TIME_ZONE || 'Australia/Sydney' const startTime = momentTZ().tz(timeZone).format('YYYY/MM/DD, HH:mm:ss') const body = [ - { - expect: '', - send: ``, - delay: '1', - repeat: '1', - note: '', - }, - { - expect: '', - send: `IP_ADDRESS=${a}.${b}.100.${this.config.id < 254 ? this.config.id : 254 - this.config.id}`, - delay: '1', - repeat: '1', - note: '', - }, - { - expect: 'switch:', - send: `IP_SUBNET_MASK=255.255.0.0`, - delay: '1', - repeat: '1', - note: '', - }, - { - expect: 'switch:', - send: `DEFAULT_GATEWAY=${station?.gateway ? station?.gateway : '0.0.0.0'}`, - delay: '1', - repeat: '1', - note: '', - }, - { - expect: 'switch:', - send: `TFTP_SERVER=${station?.tftp_ip}`, - delay: '1', - repeat: '1', - note: '', - }, - { - expect: 'switch:', - send: `TFTP_FILE=ios/${nameIos}`, - delay: '1', - repeat: '1', - note: '', - }, - { - expect: 'switch:', - send: `tftpdnld`, - delay: '1', - repeat: '1', - note: '', - }, - { - expect: 'y/n', - send: `y`, - delay: '2', - repeat: '1', - note: '', - }, - { - expect: 'switch:', - send: `boot flash:${nameIos}`, - delay: '1', - repeat: '1', - note: '', - }, - { - expect: 'Press RETURN to get started', - send: ``, - delay: '1', - repeat: '1', - note: '', - }, { expect: '', send: ``, @@ -1296,9 +1233,79 @@ export default class LineConnection { repeat: '1', note: '', }, + { + expect: '#', + send: `interface vlan 1`, + delay: '1', + repeat: '1', + note: '', + }, + { + expect: '#', + send: `ip address ${a}.${b}.100.${this.config.id < 254 ? this.config.id : 254 - this.config.id} 255.255.0.0`, + delay: '1', + repeat: '1', + note: '', + }, + { + expect: '#', + send: `no shutdown`, + delay: '1', + repeat: '1', + note: '', + }, + { + expect: '#', + send: `end`, + delay: '1', + repeat: '1', + note: '', + }, + { + expect: '#', + send: `copy tftp: flash:`, + delay: '1', + repeat: '1', + note: '', + }, { expect: '', - send: `boot system usbflash0:${nameIos}`, + send: `${station?.tftp_ip}`, + delay: '1', + repeat: '1', + note: '', + }, + { + expect: '', + send: `ios/${nameIos}`, + delay: '1', + repeat: '1', + note: '', + }, + { + expect: '', + send: ``, + delay: '1', + repeat: '1', + note: '', + }, + { + expect: '', + send: ``, + delay: '1', + repeat: '1', + note: '', + }, + { + expect: '#', + send: `configure terminal`, + delay: '1', + repeat: '1', + note: '', + }, + { + expect: '#', + send: `boot system flash:${nameIos}`, delay: '1', repeat: '1', note: '', @@ -1317,6 +1324,13 @@ export default class LineConnection { repeat: '1', note: '', }, + { + expect: '', + send: `reload`, + delay: '1', + repeat: '1', + note: '', + }, { expect: '', send: ``, @@ -1324,6 +1338,34 @@ export default class LineConnection { repeat: '1', note: '', }, + { + expect: 'Press RETURN to get started!', + send: ``, + delay: '1', + repeat: '1', + note: '', + }, + { + expect: '', + send: ``, + delay: '1', + repeat: '1', + note: '', + }, + { + expect: '', + send: `enable`, + delay: '3', + repeat: '1', + note: '', + }, + { + expect: '#', + send: `show version`, + delay: '1', + repeat: '1', + note: '', + }, ] const script = { diff --git a/FRONTEND/src/components/Modal/ModalTerminal.tsx b/FRONTEND/src/components/Modal/ModalTerminal.tsx index 2a118f9..219ad07 100644 --- a/FRONTEND/src/components/Modal/ModalTerminal.tsx +++ b/FRONTEND/src/components/Modal/ModalTerminal.tsx @@ -539,7 +539,7 @@ const ModalTerminal = ({ /> General - + - +
List ports{" "} - {line?.ports?.length - ? `(${line?.listPortsPhysical?.length}/${line?.ports?.length})` + {line?.runningPhysical + ? `(${line?.listPortsPhysical?.length || 0}/${ + line?.ports?.length || 0 + })` : ""} - {line?.ports?.map((port, i) => ( - - {port} - - ))} + {line?.runningPhysical && line?.ports + ? line?.ports?.map((port, i) => ( + + {port} + + )) + : ""}