Skip to content

Commit

Permalink
Add missing IOS router settings in node configurator
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmj committed Feb 4, 2025
1 parent 042eb79 commit 9523cd7
Show file tree
Hide file tree
Showing 4 changed files with 329 additions and 8 deletions.
31 changes: 29 additions & 2 deletions src/app/cartography/models/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ export class Properties {
headless: boolean;
linked_clone: boolean;
on_close: string;
aux_type: boolean;
aux: number;
ram: number;
system_id: string;
npe?: string;
midplane?: string;
nvram: number;
image: string;
usage: string;
use_any_adapter: boolean;
vmname: string;
Expand Down Expand Up @@ -48,8 +50,20 @@ export class Properties {
kernel_image: string;
kernel_image_md5sum?: any;
mac_address: string;
mac_addr: string;
options: string;
platform: string;
chassis?: string;
iomem?: number;
disk0: number;
disk1: number;
idlepc: string;
idlemax: number;
idlesleep: number;
exec_area: number;
mmap: boolean;
sparsemem: boolean;
auto_delete_disks: boolean;
process_priority: string;
qemu_path: string;
environment: string;
Expand All @@ -58,6 +72,17 @@ export class Properties {
memory: number;
tpm: boolean;
uefi: boolean;
slot0?: string;
slot1?: string;
slot2?: string;
slot3?: string;
slot4?: string;
slot5?: string;
slot6?: string;
slot7?: string;
wic0?: string;
wic1?: string;
wic2?: string;
}

export class Node {
Expand All @@ -67,6 +92,8 @@ export class Node {
console_auto_start: boolean;
console_host: string;
console_type: string;
aux: number;
aux_type: boolean;
custom_adapters?: any[];
ethernet_adapters?: any;
serial_adapters?: any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,31 @@ <h1 mat-dialog-title>Configurator for IOS router {{ name }}</h1>
<mat-tab-group *ngIf="name">
<mat-tab label="General settings">
<br />
<mat-label>Platform: {{ node.properties.platform }}</mat-label>
<mat-label *ngIf="node.properties.chassis"> (chassis: {{ node.properties.chassis }})</mat-label>
<br /><br />
<form [formGroup]="generalSettingsForm">
<mat-form-field class="form-field">
<input matInput type="text" formControlName="name" [(ngModel)]="node.name" placeholder="Name" />
</mat-form-field>
<mat-form-field class="form-field">
<input matInput type="text" formControlName="path" [(ngModel)]="node.properties.image" placeholder="IOS image path"/>
</mat-form-field>
</form>
<mat-form-field class="select" *ngIf="node.properties.midplane">
<mat-select placeholder="Midplane" [(ngModel)]="node.properties.midplane">
<mat-option *ngFor="let type of MidplaneTypes" [value]="type">
{{ type }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field class="select" *ngIf="node.properties.npe">
<mat-select placeholder="NPE" [(ngModel)]="node.properties.npe">
<mat-option *ngFor="let type of NPETypes" [value]="type">
{{ type }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field class="select">
<mat-select placeholder="Console type" [(ngModel)]="node.console_type">
<mat-option *ngFor="let type of consoleTypes" [value]="type">
Expand All @@ -36,23 +56,145 @@ <h1 mat-dialog-title>Configurator for IOS router {{ name }}</h1>
<input
matInput
type="number"
min="0"
formControlName="ram"
[(ngModel)]="node.properties.ram"
placeholder="RAM size"
/>
<span matSuffix>MB</span>
<span matSuffix>MiB</span>
</mat-form-field>
<mat-form-field class="form-field">
<input
matInput
type="number"
min="0"
formControlName="nvram"
[(ngModel)]="node.properties.nvram"
placeholder="NVRAM size"
/>
<span matSuffix>MB</span>
<span matSuffix>MiB</span>
</mat-form-field>
</form>
<mat-form-field class="form-field" *ngIf="node.properties.iomem">
<input
matInput
type="number"
min="0"
max="100"
[(ngModel)]="node.properties.iomem"
placeholder="I/O memory"
/>
<span matSuffix>%</span>
</mat-form-field>
<mat-form-field class="form-field">
<input
matInput
type="number"
min="0"
[(ngModel)]="node.properties.disk0"
placeholder="PCMCIA disk0"
/>
<span matSuffix>MiB</span>
</mat-form-field>
<mat-form-field class="form-field">
<input
matInput
type="number"
min="0"
[(ngModel)]="node.properties.disk1"
placeholder="PCMCIA disk1"
/>
<span matSuffix>MiB</span>
</mat-form-field>
<mat-checkbox [(ngModel)]="node.properties.auto_delete_disks"> Automatically delete NVRAM and disk files </mat-checkbox><br />
</mat-tab>

<mat-tab label="Slots">
<br />
<h6>Adapters</h6>
<div *ngFor="let index of [0, 1, 2, 3, 4, 5, 6]">
<div *ngIf="adapterMatrix[node.properties.platform][node.properties.chassis || ''][index]">
<mat-select
placeholder="Slot {{ index }}"
[(ngModel)]="networkAdaptersForNode[index]"
[ngModelOptions]="{ standalone: true }"
>
<mat-option
*ngIf="adapterMatrix[node.properties.platform][node.properties.chassis || ''][index].length > 1"
[value]=""
>
{{ "" }}
</mat-option>
<mat-option
*ngFor="let option of adapterMatrix[node.properties.platform][node.properties.chassis || ''][index]"
[value]="option"
>
{{ option }}
</mat-option>
</mat-select>
</div>
</div>
<br />
<div *ngIf="wicMatrix[node.properties.platform]">
<h6>WICs</h6>
<div *ngFor="let index of [0, 1, 2]">
<div *ngIf="wicMatrix[node.properties.platform][index]">
<mat-select
placeholder="WIC {{ index }}"
[(ngModel)]="wicsForNode[index]"
[ngModelOptions]="{ standalone: true }"
>
<mat-option [value]="">
{{ "" }}
</mat-option>
<mat-option *ngFor="let option of wicMatrix[node.properties.platform][index]" [value]="option">
{{ option }}
</mat-option>
</mat-select>
</div>
</div>
</div>
</mat-tab>

<mat-tab label="Advanced">
<mat-card>
<mat-card-title></mat-card-title>
<mat-card-subtitle> System </mat-card-subtitle>
<mat-card-content>
<mat-form-field class="form-field">
<input matInput type="text" [(ngModel)]="node.properties.system_id" placeholder="System ID" />
</mat-form-field>
<form [formGroup]="advancedSettingsForm">
<mat-form-field class="form-field">
<input matInput formControlName="mac_addr" type="text" [(ngModel)]="node.properties.mac_addr" placeholder="Base MAC" />
</mat-form-field>
</form>
</mat-card-content>
</mat-card>
<mat-card>
<mat-card-title></mat-card-title>
<mat-card-subtitle> Optimizations </mat-card-subtitle>
<mat-card-content>
<form [formGroup]="advancedSettingsForm">
<mat-form-field class="form-field">
<input matInput type="text" formControlName="idlepc" [(ngModel)]="node.properties.idlepc" placeholder="Idle-PC" />
</mat-form-field>
</form>
<mat-form-field class="form-field">
<input matInput type="number" min="0" [(ngModel)]="node.properties.idlemax" placeholder="Idlemax" />
</mat-form-field>
<mat-form-field class="form-field">
<input matInput type="number" min="0" [(ngModel)]="node.properties.idlesleep" placeholder="Idlesleep" />
<span matSuffix>ms</span>
</mat-form-field>
<mat-form-field class="form-field">
<input matInput type="number" min="0" [(ngModel)]="node.properties.exec_area" placeholder="Exec area" />
<span matSuffix>MiB</span>
</mat-form-field>
<mat-checkbox [(ngModel)]="node.properties.mmap"> Enable mmap support </mat-checkbox><br />
<mat-checkbox [(ngModel)]="node.properties.sparsemem"> Enable sparse memory support </mat-checkbox><br />
</mat-card-content>
</mat-card>
</mat-tab>

<mat-tab label="Usage">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ export class ConfiguratorDialogIosComponent implements OnInit {
name: string;
generalSettingsForm: UntypedFormGroup;
memoryForm: UntypedFormGroup;
advancedSettingsForm: UntypedFormGroup;
consoleTypes: string[] = [];
NPETypes: string[] = [];
MidplaneTypes: string[] = [];
networkAdaptersForNode: string[] = [];
wicsForNode: string[] = [];
adapterMatrix = {};
wicMatrix = {};

constructor(
public dialogRef: MatDialogRef<ConfiguratorDialogIosComponent>,
Expand All @@ -29,28 +36,82 @@ export class ConfiguratorDialogIosComponent implements OnInit {
) {
this.generalSettingsForm = this.formBuilder.group({
name: new UntypedFormControl('', Validators.required),
path: new UntypedFormControl('', Validators.required),
});

this.memoryForm = this.formBuilder.group({
ram: new UntypedFormControl('', Validators.required),
nvram: new UntypedFormControl('', Validators.required),
});

const mac_regex = /^([0-9a-fA-F]{4}\.){2}[0-9a-fA-F]{4}$|^$/
const idlepc_regex = /^(0x[0-9a-fA-F]+)?$|^$/;
this.advancedSettingsForm = this.formBuilder.group({
mac_addr: new UntypedFormControl('', Validators.pattern(mac_regex)),
idlepc: new UntypedFormControl('', Validators.pattern(idlepc_regex)),
});
}

ngOnInit() {
this.nodeService.getNode(this.controller, this.node).subscribe((node: Node) => {
this.node = node;
this.name = node.name;
this.getConfiguration();
this.fillSlotsData();
});
}

getConfiguration() {
this.consoleTypes = this.configurationService.getConsoleTypes();
this.NPETypes = this.configurationService.getNPETypes();
this.MidplaneTypes = this.configurationService.getMidplaneTypes();
this.adapterMatrix = this.configurationService.getAdapterMatrix();
this.wicMatrix = this.configurationService.getWicMatrix();
}

fillSlotsData() {

// load network adapters
for (let i = 0; i <= 6; i++) {
if (this.node.properties[`slot${i}`]) {
this.networkAdaptersForNode[i] = this.node.properties[`slot${i}`];
}
}

// load WICs
for (let i = 0; i <= 3; i++) {
if (this.node.properties[`wic${i}`]) {
this.wicsForNode[i] = this.node.properties[`wic${i}`];
}
}
}

saveSlotsData() {

// save network adapters
for (let i = 0; i <= 6; i++) {
if (this.adapterMatrix[this.node.properties.platform][this.node.properties.chassis || ''][i]) {
if (this.networkAdaptersForNode[i] === undefined)
this.node.properties[`slot${i}`] = ""
else
this.node.properties[`slot${i}`] = this.networkAdaptersForNode[i];
}
}

// save WICs
for (let i = 0; i <= 3; i++) {
if (this.wicMatrix[this.node.properties.platform][i]) {
if (this.wicsForNode[i] === undefined)
this.node.properties[`wic${i}`] = ""
else
this.node.properties[`wic${i}`] = this.wicsForNode[i];
}
}
}

onSaveClick() {
if (this.generalSettingsForm.valid && this.memoryForm.valid) {
if (this.generalSettingsForm.valid && this.memoryForm.valid && this.advancedSettingsForm.valid) {
this.saveSlotsData();
this.nodeService.updateNode(this.controller, this.node).subscribe(() => {
this.toasterService.success(`Node ${this.node.name} updated.`);
this.onCancelClick();
Expand Down
Loading

0 comments on commit 9523cd7

Please sign in to comment.