Fix spice+agent and none console types not supported.

This commit is contained in:
grossmj
2022-06-18 18:53:36 +02:00
parent 7e43dc77cb
commit 9efd99dccb
4 changed files with 74 additions and 65 deletions

View File

@ -33,20 +33,24 @@ export class ConsoleDeviceActionBrowserComponent {
this.node.console_host = this.server.host; this.node.console_host = this.server.host;
} }
if ( try {
this.node.console_type === 'telnet' || if (this.node.console_type === 'telnet') {
this.node.console_type === 'vnc' ||
this.node.console_type === 'spice'
) {
try {
location.assign( location.assign(
`gns3+${this.node.console_type}://${this.node.console_host}:${this.node.console}?name=${this.node.name}&project_id=${this.node.project_id}&node_id=${this.node.node_id}` `gns3+telnet://${this.node.console_host}:${this.node.console}?name=${this.node.name}&project_id=${this.node.project_id}&node_id=${this.node.node_id}`
); );
} catch (e) { } else if (this.node.console_type === 'vnc') {
this.toasterService.error(e); location.assign(
`gns3+vnc://${this.node.console_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')) {
location.assign(
`gns3+spice://${this.node.console_host}:${this.node.console}?name=${this.node.name}&project_id=${this.node.project_id}&node_id=${this.node.node_id}`
);
} else {
this.toasterService.error('Supported console types are: telnet, vnc, spice and spice+agent.');
} }
} else { } catch (e) {
this.toasterService.error('Supported console types: telnet, vnc, spice.'); this.toasterService.error(e);
} }
} }
} }

View File

@ -29,7 +29,7 @@ export class ConsoleDeviceActionComponent implements OnInit {
let consoleCommand = this.settingsService.getConsoleSettings() let consoleCommand = this.settingsService.getConsoleSettings()
? this.settingsService.getConsoleSettings() ? this.settingsService.getConsoleSettings()
: this.nodeService.getDefaultCommand(); : this.nodeService.getDefaultCommand();
const startedNodes = this.nodes.filter((node) => node.status === 'started'); const startedNodes = this.nodes.filter((node) => node.status === 'started' && node.console_type !== 'none');
if (startedNodes.length === 0) { if (startedNodes.length === 0) {
this.toasterService.error('Device needs to be started in order to console to it.'); this.toasterService.error('Device needs to be started in order to console to it.');
@ -37,7 +37,7 @@ export class ConsoleDeviceActionComponent implements OnInit {
} }
for (var node of this.nodes) { for (var node of this.nodes) {
if (node.status !== 'started') { if (node.status !== 'started' && node.console_type !== 'none') {
continue; continue;
} }

View File

@ -232,12 +232,12 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy {
location.assign( location.assign(
`gns3+vnc://${node.console_host}:${node.console}?name=${node.name}&project_id=${node.project_id}&node_id=${node.node_id}` `gns3+vnc://${node.console_host}:${node.console}?name=${node.name}&project_id=${node.project_id}&node_id=${node.node_id}`
); );
} else if (node.console_type === 'spice') { } else if (node.console_type.startsWith('spice')) {
location.assign( location.assign(
`gns3+spice://${node.console_host}:${node.console}?name=${node.name}&project_id=${node.project_id}&node_id=${node.node_id}` `gns3+spice://${node.console_host}:${node.console}?name=${node.name}&project_id=${node.project_id}&node_id=${node.node_id}`
); );
} else { } else {
this.showCommand('Supported console types: telnet, vnc, spice.'); this.showCommand('Supported console types are: telnet, vnc, spice and spice+agent');
} }
} else { } else {
this.showCommand(`This node must be started before a console can be opened.`); this.showCommand(`This node must be started before a console can be opened.`);
@ -297,28 +297,28 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy {
printNode(node: Node): string { printNode(node: Node): string {
return ( return (
`command_line: ${node.command_line}, `command_line: ${node.command_line},
compute_id: ${node.compute_id}, compute_id: ${node.compute_id},
console: ${node.console}, console: ${node.console},
console_host: ${node.console_host}, console_host: ${node.console_host},
console_type: ${node.console_type}, console_type: ${node.console_type},
first_port_name: ${node.first_port_name}, first_port_name: ${node.first_port_name},
height: ${node.height}, height: ${node.height},
label: ${node.label.text}, label: ${node.label.text},
name: ${node.name}, name: ${node.name},
node_directory: ${node.node_directory}, node_directory: ${node.node_directory},
node_id: ${node.node_id}, node_id: ${node.node_id},
node_type: ${node.node_type}, node_type: ${node.node_type},
port_name_format: ${node.port_name_format}, port_name_format: ${node.port_name_format},
port_segment_size: ${node.port_segment_size}, ` + port_segment_size: ${node.port_segment_size}, ` +
this.printPorts(node.ports) + this.printPorts(node.ports) +
`project_id: ${node.project_id}, `project_id: ${node.project_id},
status: ${node.status}, status: ${node.status},
symbol: ${node.symbol}, symbol: ${node.symbol},
symbol_url: ${node.symbol_url}, symbol_url: ${node.symbol_url},
width: ${node.width}, width: ${node.width},
x: ${node.x}, x: ${node.x},
y: ${node.y}, y: ${node.y},
z: ${node.z}` z: ${node.z}`
); );
} }
@ -328,31 +328,31 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy {
ports.forEach((port) => { ports.forEach((port) => {
response = response =
response + response +
`adapter_number: ${port.adapter_number}, `adapter_number: ${port.adapter_number},
link_type: ${port.link_type}, link_type: ${port.link_type},
name: ${port.name}, name: ${port.name},
port_number: ${port.port_number}, port_number: ${port.port_number},
short_name: ${port.short_name}, `; short_name: ${port.short_name}, `;
}); });
return response; return response;
} }
printLink(link: Link): string { printLink(link: Link): string {
return `capture_file_name: ${link.capture_file_name}, return `capture_file_name: ${link.capture_file_name},
capture_file_path: ${link.capture_file_path}, capture_file_path: ${link.capture_file_path},
capturing: ${link.capturing}, capturing: ${link.capturing},
link_id: ${link.link_id}, link_id: ${link.link_id},
link_type: ${link.link_type}, link_type: ${link.link_type},
project_id: ${link.project_id}, project_id: ${link.project_id},
suspend: ${link.suspend}, `; suspend: ${link.suspend}, `;
} }
printDrawing(drawing: Drawing): string { printDrawing(drawing: Drawing): string {
return `drawing_id: ${drawing.drawing_id}, return `drawing_id: ${drawing.drawing_id},
project_id: ${drawing.project_id}, project_id: ${drawing.project_id},
rotation: ${drawing.rotation}, rotation: ${drawing.rotation},
x: ${drawing.x}, x: ${drawing.x},
y: ${drawing.y}, y: ${drawing.y},
z: ${drawing.z}`; z: ${drawing.z}`;
} }
} }

View File

@ -78,13 +78,15 @@ export class NodeConsoleService {
let nodesToStart = 'Please start the following nodes if you want to open consoles for them: '; let nodesToStart = 'Please start the following nodes if you want to open consoles for them: ';
let nodesToStartCounter = 0; let nodesToStartCounter = 0;
nodes.forEach((n) => { nodes.forEach((n) => {
if (n.status === 'started') { if (n.console_type !== "none") {
this.mapSettingsService.logConsoleSubject.next(true); if (n.status === 'started') {
// this timeout is required due to xterm.js implementation this.mapSettingsService.logConsoleSubject.next(true);
setTimeout(() => { this.openConsoleForNode(n); }, 500); // this timeout is required due to xterm.js implementation
} else { setTimeout(() => { this.openConsoleForNode(n); }, 500);
nodesToStartCounter++; } else {
nodesToStart += n.name + ' ' nodesToStartCounter++;
nodesToStart += n.name + ' '
}
} }
}); });
if (nodesToStartCounter > 0) { if (nodesToStartCounter > 0) {
@ -93,16 +95,19 @@ export class NodeConsoleService {
} }
openConsolesForAllNodesInNewTabs(nodes: Node[]) { openConsolesForAllNodesInNewTabs(nodes: Node[]) {
let nodesToStart = 'Please start the following nodes if you want to open consoles for them: '; let nodesToStart = 'Please start the following nodes if you want to open consoles in tabs for them: ';
let nodesToStartCounter = 0; let nodesToStartCounter = 0;
nodes.forEach((n) => { nodes.forEach((n) => {
if (n.status === 'started') { // opening a console in tab is only supported for telnet type
let url = this.router.url.split('/'); if (n.console_type === "telnet") {
let urlString = `/static/web-ui/${url[1]}/${url[2]}/${url[3]}/${url[4]}/nodes/${n.node_id}`; if (n.status === 'started') {
window.open(urlString); let url = this.router.url.split('/');
} else { let urlString = `/static/web-ui/${url[1]}/${url[2]}/${url[3]}/${url[4]}/nodes/${n.node_id}`;
nodesToStartCounter++; window.open(urlString);
nodesToStart += n.name + ' ' } else {
nodesToStartCounter++;
nodesToStart += n.name + ' '
}
} }
}); });
if (nodesToStartCounter > 0) { if (nodesToStartCounter > 0) {