Merge pull request #1499 from GNS3/feature/aux-console

Auxiliary console support
This commit is contained in:
Jeremy Grossmann 2024-05-14 22:17:16 +07:00 committed by GitHub
commit ac84106dbc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 4 deletions

View File

@ -14,6 +14,7 @@ export class Properties {
headless: boolean;
linked_clone: boolean;
on_close: string;
aux: number;
ram: number;
nvram: number;
usage: string;

View File

@ -2,3 +2,11 @@
<mat-icon>web_asset</mat-icon>
<span>Console</span>
</button>
<button
mat-menu-item
*ngIf="node.node_type === 'docker' || node.node_type === 'dynamips'"
(click)="openConsole(auxiliary=true)"
>
<mat-icon>web_asset</mat-icon>
<span>Auxiliary console</span>
</button>

View File

@ -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,18 @@ 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;
if (console_port === undefined) {
this.toasterService.error('Auxiliary console port is not set.');
return;
}
} 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')) {
@ -54,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);