Fix import/export Dynamips configs

This commit is contained in:
grossmj 2025-02-16 12:57:01 +10:00
parent 097efdcbcd
commit 8ec03968df
No known key found for this signature in database
GPG Key ID: 1E7DD6DBB53FF3D7
6 changed files with 10 additions and 5 deletions

View File

@ -27,6 +27,7 @@ export class MapNodeToNodeConverter implements Converter<MapNode, Node> {
node.port_name_format = mapNode.portNameFormat;
node.port_segment_size = mapNode.portSegmentSize;
node.ports = mapNode.ports ? mapNode.ports.map((mapPort) => this.mapPortToPort.convert(mapPort)) : [];
node.properties = mapNode.properties;
node.project_id = mapNode.projectId;
node.status = mapNode.status;
node.symbol = mapNode.symbol;

View File

@ -38,6 +38,7 @@ export class NodeToMapNodeConverter implements Converter<Node, MapNode> {
mapNode.portNameFormat = node.port_name_format;
mapNode.portSegmentSize = node.port_segment_size;
mapNode.ports = node.ports ? node.ports.map((port) => this.portToMapPort.convert(port)) : [];
mapNode.properties = node.properties;
mapNode.projectId = node.project_id;
mapNode.status = node.status;
mapNode.symbol = node.symbol;

View File

@ -1,6 +1,7 @@
import { Indexed } from '../../datasources/map-datasource';
import { MapLabel } from './map-label';
import { MapPort } from './map-port';
import { Properties } from '../node';
export class MapNode implements Indexed {
id: string;
@ -19,6 +20,7 @@ export class MapNode implements Indexed {
portNameFormat: string;
portSegmentSize: number;
ports: MapPort[];
properties: Properties;
projectId: string;
status: string;
symbol: string;

View File

@ -18,6 +18,7 @@ export class Properties {
aux_type: boolean;
ram: number;
system_id: string;
dynamips_id?: number;
npe?: string;
midplane?: string;
nvram: number;

View File

@ -1,4 +1,4 @@
<input type="file" accept=".txt, .vpc" class="non-visible" #fileInput (change)="importConfig($event)" />
<input type="file" accept=".txt, .vpc, .cfg" class="non-visible" #fileInput (change)="importConfig($event)" />
<button mat-menu-item (click)="triggerClick()">
<mat-icon>call_received</mat-icon>
<span>Import config</span>

View File

@ -189,7 +189,7 @@ export class NodeService {
} else if (node.node_type === 'iou') {
urlPath += '/files/startup-config.cfg';
} else if (node.node_type === 'dynamips') {
urlPath += `/files/configs/i${node.node_id}_startup-config.cfg`;
urlPath += `/files/configs/i${node.properties.dynamips_id}_startup-config.cfg`;
}
return this.httpController.get(controller, urlPath, { responseType: 'text' as 'json' });
@ -201,7 +201,7 @@ export class NodeService {
if (node.node_type === 'iou') {
urlPath += '/files/private-config.cfg';
} else if (node.node_type === 'dynamips') {
urlPath += `/files/configs/i${node.node_id}_private-config.cfg`;
urlPath += `/files/configs/i${node.properties.dynamips_id}_private-config.cfg`;
}
return this.httpController.get(controller, urlPath, { responseType: 'text' as 'json' });
@ -215,7 +215,7 @@ export class NodeService {
} else if (node.node_type === 'iou') {
urlPath += '/files/startup-config.cfg';
} else if (node.node_type === 'dynamips') {
urlPath += `/files/configs/i${node.node_id}_startup-config.cfg`;
urlPath += `/files/configs/i${node.properties.dynamips_id}_startup-config.cfg`;
}
return this.httpController.post(controller, urlPath, configuration);
@ -227,7 +227,7 @@ export class NodeService {
if (node.node_type === 'iou') {
urlPath += '/files/private-config.cfg';
} else if (node.node_type === 'dynamips') {
urlPath += `/files/configs/i${node.node_id}_private-config.cfg`;
urlPath += `/files/configs/i${node.properties.dynamips_id}_private-config.cfg`;
}
return this.httpController.post(controller, urlPath, configuration);