From 42599dafb5f8f9d74da5d4f122dd2d0b34f7e867 Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 14 May 2024 20:07:30 +0700 Subject: [PATCH 1/2] Auxiliary console support --- src/app/cartography/models/node.ts | 1 + .../console-device-action-browser.component.html | 8 ++++++++ .../console-device-action-browser.component.ts | 15 +++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/app/cartography/models/node.ts b/src/app/cartography/models/node.ts index 8bef9b6a..c422e428 100644 --- a/src/app/cartography/models/node.ts +++ b/src/app/cartography/models/node.ts @@ -14,6 +14,7 @@ export class Properties { headless: boolean; linked_clone: boolean; on_close: string; + aux: number; ram: number; nvram: number; usage: string; diff --git a/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.html b/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.html index 15f3f924..6faeccf9 100644 --- a/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.html +++ b/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.html @@ -2,3 +2,11 @@ web_asset Console + diff --git a/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts b/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts index c521be41..7f517e3e 100644 --- a/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts +++ b/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts @@ -18,14 +18,14 @@ export class ConsoleDeviceActionBrowserComponent { constructor(private toasterService: ToasterService, private nodeService: NodeService, private protocolHandlerService: ProtocolHandlerService) {} - openConsole() { + openConsole(auxiliary: boolean = false) { this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { this.node = node; - this.startConsole(); + this.startConsole(auxiliary); }); } - startConsole() { + startConsole(auxiliary: boolean) { if (this.node.status !== 'started') { this.toasterService.error('This node must be started before a console can be opened'); } else { @@ -44,7 +44,14 @@ export class ConsoleDeviceActionBrowserComponent { host = `[${host}]`; } if (this.node.console_type === 'telnet') { - uri = `gns3+telnet://${host}:${this.node.console}?name=${this.node.name}&project_id=${this.node.project_id}&node_id=${this.node.node_id}`; + + var console_port; + if (auxiliary === true) { + console_port = this.node.properties.aux; + } else { + console_port = this.node.console; + } + uri = `gns3+telnet://${host}:${console_port}?name=${this.node.name}&project_id=${this.node.project_id}&node_id=${this.node.node_id}`; } else if (this.node.console_type === 'vnc') { uri = `gns3+vnc://${host}:${this.node.console}?name=${this.node.name}&project_id=${this.node.project_id}&node_id=${this.node.node_id}`; } else if (this.node.console_type.startsWith('spice')) { From a9781943d509367c4a2dd726a8248efa94d21ef8 Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 14 May 2024 22:11:38 +0700 Subject: [PATCH 2/2] Check auxiliary console port is defined --- .../console-device-action-browser.component.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts b/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts index 7f517e3e..1f01294a 100644 --- a/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts +++ b/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts @@ -48,6 +48,10 @@ export class ConsoleDeviceActionBrowserComponent { var console_port; if (auxiliary === true) { console_port = this.node.properties.aux; + if (console_port === undefined) { + this.toasterService.error('Auxiliary console port is not set.'); + return; + } } else { console_port = this.node.console; } @@ -61,6 +65,7 @@ export class ConsoleDeviceActionBrowserComponent { return window.open(uri); // open an http console directly in a new window/tab } else { this.toasterService.error('Supported console types are: telnet, vnc, spice and spice+agent.'); + return; } this.protocolHandlerService.open(uri);