Update load IOS switch

This commit is contained in:
nguyentrungthat 2026-01-05 16:59:00 +07:00
parent f160cd2905
commit e14d4ca216
2 changed files with 133 additions and 87 deletions

View File

@ -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 = {

View File

@ -539,7 +539,7 @@ const ModalTerminal = ({
/>
General
</Tabs.Tab>
<Tabs.Tab w={"50%"} value="messages">
<Tabs.Tab w={"50%"} value="physical">
<IconPlug
color="green"
size={16}
@ -933,7 +933,7 @@ const ModalTerminal = ({
</Flex>
</Tabs.Panel>
<Tabs.Panel value="messages">
<Tabs.Panel value="physical">
<fieldset
style={{
marginTop: "12px",
@ -943,15 +943,18 @@ const ModalTerminal = ({
<Flex>
<Text>
List ports{" "}
{line?.ports?.length
? `(${line?.listPortsPhysical?.length}/${line?.ports?.length})`
{line?.runningPhysical
? `(${line?.listPortsPhysical?.length || 0}/${
line?.ports?.length || 0
})`
: ""}
</Text>
</Flex>
</legend>
<ScrollArea h={"50vh"} p={"4px"}>
<Flex wrap={"wrap"} gap={"xs"}>
{line?.ports?.map((port, i) => (
{line?.runningPhysical && line?.ports
? line?.ports?.map((port, i) => (
<Text
key={i}
c={
@ -962,7 +965,8 @@ const ModalTerminal = ({
>
{port}
</Text>
))}
))
: ""}
</Flex>
</ScrollArea>
</fieldset>