Fix and improve IOS template configuration

This commit is contained in:
grossmj 2025-02-04 21:00:20 +10:00
parent 80884a7929
commit 86db2e208c
No known key found for this signature in database
GPG Key ID: 1E7DD6DBB53FF3D7
7 changed files with 209 additions and 377 deletions

View File

@ -109,32 +109,24 @@
</mat-step> </mat-step>
<mat-step label="Network adapters"> <mat-step label="Network adapters">
<!-- <div *ngIf="chassis[iosNameForm.get('platform').value]"> <div *ngIf="iosNameForm.get('platform').value">
<div *ngFor="let index of [0,1,2,3,4,5,6,7]"> <div *ngFor="let index of [0, 1, 2, 3, 4, 5, 6]">
<mat-select
placeholder="Slot {{index}}"
[(ngModel)]="networkAdaptersForTemplate[index]"
[ngModelOptions]="{standalone: true}"
*ngIf="networkAdapters[iosNameForm.get('chassis').value] && networkAdapters[iosNameForm.get('chassis').value][index]">
<mat-option *ngFor="let option of networkAdapters[iosNameForm.get('chassis').value][index]" [value]="option">
{{option}}
</mat-option>
</mat-select>
</div>
</div> -->
<div *ngIf="selectedPlatform">
<div *ngFor="let index of [0, 1, 2, 3, 4, 5, 6, 7]">
<mat-select <mat-select
placeholder="Slot {{ index }}" placeholder="Slot {{ index }}"
[(ngModel)]="networkAdaptersForTemplate[index]" [(ngModel)]="networkAdaptersForTemplate[index]"
[ngModelOptions]="{ standalone: true }" [ngModelOptions]="{ standalone: true }"
*ngIf=" *ngIf="adapterMatrix[iosNameForm.get('platform').value][iosNameForm.get('chassis').value || '']
networkAdaptersForPlatform[iosNameForm.get('platform').value] && && adapterMatrix[iosNameForm.get('platform').value][iosNameForm.get('chassis').value || ''][index]"
networkAdaptersForPlatform[iosNameForm.get('platform').value][index]
"
> >
<mat-option <mat-option
*ngFor="let option of networkAdaptersForPlatform[iosNameForm.get('platform').value][index]" *ngIf="adapterMatrix[iosNameForm.get('platform').value][iosNameForm.get('chassis').value|| ''][index].length > 1 &&
!adapterMatrix[iosNameForm.get('platform').value][iosNameForm.get('chassis').value|| ''][index][0].startsWith('C7200')"
[value]=""
>
{{ "" }}
</mat-option>
<mat-option
*ngFor="let option of adapterMatrix[iosNameForm.get('platform').value][iosNameForm.get('chassis').value || ''][index]"
[value]="option" [value]="option"
> >
{{ option }} {{ option }}
@ -144,33 +136,33 @@
</div> </div>
</mat-step> </mat-step>
<mat-step label="WIC modules"> <mat-step label="WIC modules" *ngIf="iosNameForm.get('platform').value && wicMatrix[iosNameForm.get('platform').value]">
<div *ngIf="iosNameForm.get('platform').value"> <div *ngFor="let index of [0, 1, 2]">
<div *ngFor="let index of [0, 1, 2, 3]"> <mat-select
<mat-select placeholder="WIC {{ index }}"
placeholder="WIC {{ index }}" [(ngModel)]="wicsForTemplate[index]"
[(ngModel)]="networkModulesForTemplate[index]" [ngModelOptions]="{ standalone: true }"
[ngModelOptions]="{ standalone: true }" *ngIf="wicMatrix[iosNameForm.get('platform').value] && wicMatrix[iosNameForm.get('platform').value][index]"
*ngIf=" >
networkModules[iosNameForm.get('platform').value] && <mat-option [value]="">
networkModules[iosNameForm.get('platform').value][index] {{ "" }}
" </mat-option>
<mat-option
*ngFor="let option of wicMatrix[iosNameForm.get('platform').value][index]"
[value]="option"
> >
<mat-option {{ option }}
*ngFor="let option of networkModules[iosNameForm.get('platform').value][index]" </mat-option>
[value]="option" </mat-select>
>
{{ option }}
</mat-option>
</mat-select>
</div>
</div> </div>
</mat-step> </mat-step>
<mat-step label="Idle-PC"> <mat-step label="Idle-PC">
<mat-form-field class="form-field"> <form [formGroup]="iosIdlePCForm">
<input matInput type="text" [(ngModel)]="iosTemplate.idlepc" placeholder="Idle-PC" /> <mat-form-field class="form-field">
</mat-form-field> <input matInput type="text" formControlName="idlepc" [(ngModel)]="iosTemplate.idlepc" placeholder="Idle-PC" />
</mat-form-field>
</form>
</mat-step> </mat-step>
</mat-vertical-stepper> </mat-vertical-stepper>
</div> </div>

View File

@ -32,11 +32,8 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy {
iosImageForm: UntypedFormGroup; iosImageForm: UntypedFormGroup;
iosNameForm: UntypedFormGroup; iosNameForm: UntypedFormGroup;
iosMemoryForm: UntypedFormGroup; iosMemoryForm: UntypedFormGroup;
iosIdlePCForm: UntypedFormGroup;
selectedPlatform: string; selectedPlatform: string;
networkAdaptersForTemplate: string[] = [];
networkModulesForTemplate: string[] = [];
iosImages: IosImage[] = []; iosImages: IosImage[] = [];
platforms: string[] = []; platforms: string[] = [];
platformsWithEtherSwitchRouterOption = {}; platformsWithEtherSwitchRouterOption = {};
@ -44,9 +41,10 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy {
chassis = {}; chassis = {};
defaultRam = {}; defaultRam = {};
defaultNvram = {}; defaultNvram = {};
networkAdapters = {}; networkAdaptersForTemplate: string[] = [];
networkAdaptersForPlatform = {}; wicsForTemplate: string[] = [];
networkModules = {}; adapterMatrix = {};
wicMatrix = {};
ciscoUrl: string = 'https://cfn.cloudapps.cisco.com/ITDIT/CFN/jsp/SearchBySoftware.jsp'; ciscoUrl: string = 'https://cfn.cloudapps.cisco.com/ITDIT/CFN/jsp/SearchBySoftware.jsp';
uploader: FileUploader; uploader: FileUploader;
@ -82,6 +80,10 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy {
this.iosMemoryForm = this.formBuilder.group({ this.iosMemoryForm = this.formBuilder.group({
memory: new UntypedFormControl(null, [Validators.required]), memory: new UntypedFormControl(null, [Validators.required]),
}); });
this.iosIdlePCForm = this.formBuilder.group({
idlepc: new UntypedFormControl(null, [Validators.pattern(this.iosConfigurationService.getIdlepcRegex())]),
});
} }
ngOnInit() { ngOnInit() {
@ -120,19 +122,31 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy {
this.templateMocksService.getIosTemplate().subscribe((iosTemplate: IosTemplate) => { this.templateMocksService.getIosTemplate().subscribe((iosTemplate: IosTemplate) => {
this.iosTemplate = iosTemplate; this.iosTemplate = iosTemplate;
this.networkModules = this.iosConfigurationService.getNetworkModules();
this.networkAdaptersForPlatform = this.iosConfigurationService.getNetworkAdaptersForPlatform();
this.networkAdapters = this.iosConfigurationService.getNetworkAdapters();
this.platforms = this.iosConfigurationService.getAvailablePlatforms(); this.platforms = this.iosConfigurationService.getAvailablePlatforms();
this.platformsWithEtherSwitchRouterOption = this.iosConfigurationService.getPlatformsWithEtherSwitchRouterOption(); this.platformsWithEtherSwitchRouterOption = this.iosConfigurationService.getPlatformsWithEtherSwitchRouterOption();
this.platformsWithChassis = this.iosConfigurationService.getPlatformsWithChassis(); this.platformsWithChassis = this.iosConfigurationService.getPlatformsWithChassis();
this.chassis = this.iosConfigurationService.getChassis(); this.chassis = this.iosConfigurationService.getChassis();
this.defaultRam = this.iosConfigurationService.getDefaultRamSettings(); this.defaultRam = this.iosConfigurationService.getDefaultRamSettings();
this.adapterMatrix = this.iosConfigurationService.getAdapterMatrix();
this.wicMatrix = this.iosConfigurationService.getWicMatrix();
}); });
}); });
} }
fillDefaultSlots() {
console.log("Fill default slots");
if (this.iosNameForm.get('platform').value) {
for (let i = 0; i <= 6; i++) {
let adapters = this.adapterMatrix[this.iosNameForm.get('platform').value][this.iosNameForm.get('chassis').value || ''][i];
if (adapters && (adapters.length === 1 || adapters[0].startsWith('C7200'))) {
console.log("Set default adapter for slot" + i + " to " + adapters[0]);
this.networkAdaptersForTemplate[i] = adapters[0];
}
}
}
}
setControllerType(controllerType: string) { setControllerType(controllerType: string) {
if (controllerType === 'local') { if (controllerType === 'local') {
this.isLocalComputerChosen = true; this.isLocalComputerChosen = true;
@ -166,6 +180,7 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy {
if ( if (
!this.iosImageForm.invalid && !this.iosImageForm.invalid &&
!this.iosMemoryForm.invalid && !this.iosMemoryForm.invalid &&
!this.iosIdlePCForm.invalid &&
this.iosNameForm.get('templateName').value && this.iosNameForm.get('templateName').value &&
this.iosNameForm.get('platform').value this.iosNameForm.get('platform').value
) { ) {
@ -184,7 +199,7 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy {
} }
if (this.networkAdaptersForTemplate.length > 0) this.completeAdaptersData(); if (this.networkAdaptersForTemplate.length > 0) this.completeAdaptersData();
if (this.networkModulesForTemplate.length > 0) this.completeModulesData(); if (this.wicsForTemplate.length > 0) this.completeWicsData();
this.iosTemplate.compute_id = 'local'; this.iosTemplate.compute_id = 'local';
this.iosService.addTemplate(this.controller, this.iosTemplate).subscribe((template: IosTemplate) => { this.iosService.addTemplate(this.controller, this.iosTemplate).subscribe((template: IosTemplate) => {
@ -196,44 +211,25 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy {
} }
completeAdaptersData() { completeAdaptersData() {
if (this.chassis[this.iosTemplate.platform]) { for (let i = 0; i <= 6; i++) {
if (Object.keys(this.networkAdapters[this.iosTemplate.chassis])) { if (this.adapterMatrix[this.iosTemplate.platform][this.iosTemplate.chassis || ''][i]) {
for (let i = 0; i < Object.keys(this.networkAdapters[this.iosTemplate.chassis]).length; i++) { if (this.networkAdaptersForTemplate[i] === undefined)
if (!this.networkAdaptersForTemplate[i]) this.networkAdaptersForTemplate[i] = ''; this.iosTemplate[`slot${i}`] = ""
} else
} this.iosTemplate[`slot${i}`] = this.networkAdaptersForTemplate[i];
} else {
if (this.networkAdaptersForPlatform[this.iosNameForm.get('platform').value]) {
for (
let i = 0;
i < Object.keys(this.networkAdaptersForPlatform[this.iosNameForm.get('platform').value]).length;
i++
) {
if (!this.networkAdaptersForTemplate[i]) this.networkAdaptersForTemplate[i] = '';
}
} }
} }
if (this.networkAdaptersForTemplate[0]) this.iosTemplate.slot0 = this.networkAdaptersForTemplate[0];
if (this.networkAdaptersForTemplate[1]) this.iosTemplate.slot1 = this.networkAdaptersForTemplate[1];
if (this.networkAdaptersForTemplate[2]) this.iosTemplate.slot2 = this.networkAdaptersForTemplate[2];
if (this.networkAdaptersForTemplate[3]) this.iosTemplate.slot3 = this.networkAdaptersForTemplate[3];
if (this.networkAdaptersForTemplate[4]) this.iosTemplate.slot4 = this.networkAdaptersForTemplate[4];
if (this.networkAdaptersForTemplate[5]) this.iosTemplate.slot5 = this.networkAdaptersForTemplate[5];
if (this.networkAdaptersForTemplate[6]) this.iosTemplate.slot6 = this.networkAdaptersForTemplate[6];
if (this.networkAdaptersForTemplate[7]) this.iosTemplate.slot7 = this.networkAdaptersForTemplate[7];
} }
completeModulesData() { completeWicsData() {
if (Object.keys(this.networkModules[this.iosTemplate.platform])) { for (let i = 0; i <= 3; i++) {
for (let i = 0; i < Object.keys(this.networkModules[this.iosTemplate.platform]).length; i++) { if (this.wicMatrix[this.iosTemplate.platform][i]) {
if (!this.networkModulesForTemplate[i]) this.networkModulesForTemplate[i] = ''; if (this.wicsForTemplate[i] === undefined)
this.iosTemplate[`wic${i}`] = ""
else
this.iosTemplate[`wic${i}`] = this.wicsForTemplate[i];
} }
} }
if (this.networkModulesForTemplate[0]) this.iosTemplate.wic0 = this.networkModulesForTemplate[0];
if (this.networkModulesForTemplate[1]) this.iosTemplate.wic1 = this.networkModulesForTemplate[1];
if (this.networkModulesForTemplate[2]) this.iosTemplate.wic2 = this.networkModulesForTemplate[2];
} }
goBack() { goBack() {
@ -252,25 +248,31 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy {
this.selectedPlatform = name; this.selectedPlatform = name;
} }
if (name === 'c1700') { if (name === 'c3620' || name === 'c3640' || name === 'c3660')
this.iosNameForm.controls['chassis'].setValue('1720'); this.iosNameForm.controls['chassis'].setValue(name.substring(1));
else if (name === 'c1700') {
this.iosNameForm.controls['chassis'].setValue('1760');
} else if (name === 'c2600') { } else if (name === 'c2600') {
this.iosNameForm.controls['chassis'].setValue('2610'); this.iosNameForm.controls['chassis'].setValue('2651XM');
} else { } else {
this.iosNameForm.controls['chassis'].setValue(''); this.iosNameForm.controls['chassis'].setValue('');
} }
this.iosMemoryForm.controls['memory'].setValue(this.defaultRam[this.selectedPlatform]);
this.iosMemoryForm.controls['memory'].setValue(this.defaultRam[name]); this.fillDefaultSlots();
} }
onPlatformChosen() { onPlatformChosen() {
this.iosTemplate.chassis = ''; this.iosTemplate.chassis = '';
this.networkAdaptersForTemplate = []; this.networkAdaptersForTemplate = [];
this.networkModulesForTemplate = []; this.wicsForTemplate = [];
if (!this.chassis[this.iosNameForm.get('platform').value])
this.fillDefaultSlots();
} }
onChassisChosen() { onChassisChosen() {
this.networkAdaptersForTemplate = []; this.networkAdaptersForTemplate = [];
if (this.chassis[this.iosNameForm.get('platform').value])
this.fillDefaultSlots();
} }
cancelUploading() { cancelUploading() {

View File

@ -169,60 +169,47 @@
<mat-panel-title> Slots </mat-panel-title> <mat-panel-title> Slots </mat-panel-title>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<h6>Adapters</h6> <h6>Adapters</h6>
<div *ngIf="iosTemplate.chassis && chassis[iosTemplate.platform]"> <div *ngFor="let index of [0, 1, 2, 3, 4, 5, 6]">
<div *ngFor="let index of [0, 1, 2, 3, 4, 5, 6, 7]"> <mat-select
<mat-select placeholder="Slot {{ index }}"
placeholder="Slot {{ index }}" [(ngModel)]="networkAdaptersForTemplate[index]"
[(ngModel)]="networkAdaptersForTemplate[index]" [ngModelOptions]="{ standalone: true }"
[ngModelOptions]="{ standalone: true }" *ngIf="adapterMatrix[iosTemplate.platform][iosTemplate.chassis || ''][index]"
*ngIf="networkAdapters[iosTemplate.chassis][index]" >
<mat-option
*ngIf="adapterMatrix[iosTemplate.platform][iosTemplate.chassis || ''][index].length > 1 &&
!adapterMatrix[iosTemplate.platform][iosTemplate.chassis || ''][index][0].startsWith('C7200')"
[value]=""
> >
<mat-option *ngFor="let option of networkAdapters[iosTemplate.chassis][index]" [value]="option"> {{ "" }}
</mat-option>
<mat-option
*ngFor="let option of adapterMatrix[iosTemplate.platform][iosTemplate.chassis || ''][index]"
[value]="option"
>
{{ option }}
</mat-option>
</mat-select>
</div>
<br />
<div *ngIf="wicMatrix[iosTemplate.platform]">
<h6>WICs</h6>
<div *ngFor="let index of [0, 1, 2]">
<mat-select
placeholder="WIC {{ index }}"
[(ngModel)]="wicsForTemplate[index]"
[ngModelOptions]="{ standalone: true }"
*ngIf="wicMatrix[iosTemplate.platform][index]"
>
<mat-option [value]="">
{{ "" }}
</mat-option>
<mat-option *ngFor="let option of wicMatrix[iosTemplate.platform][index]" [value]="option">
{{ option }} {{ option }}
</mat-option> </mat-option>
</mat-select> </mat-select>
</div> </div>
</div> </div>
<div *ngIf="iosTemplate.platform && !chassis[iosTemplate.platform]">
<div *ngFor="let index of [0, 1, 2, 3, 4, 5, 6, 7]">
<mat-select
placeholder="Slot {{ index }}"
[(ngModel)]="networkAdaptersForTemplate[index]"
[ngModelOptions]="{ standalone: true }"
*ngIf="networkAdaptersForPlatform[iosTemplate.platform][index]"
>
<mat-option
*ngFor="let option of networkAdaptersForPlatform[iosTemplate.platform][index]"
[value]="option"
>
{{ option }}
</mat-option>
</mat-select>
</div>
</div>
<br /><br />
<h6>WICs</h6>
<div *ngIf="iosTemplate.wic0 || iosTemplate.wic0 === ''">
<mat-select placeholder="WIC 0" [(ngModel)]="iosTemplate.wic0" [ngModelOptions]="{ standalone: true }">
<mat-option *ngFor="let option of networkModules[iosTemplate.platform][0]" [value]="option">
{{ option }}
</mat-option>
</mat-select>
</div>
<div *ngIf="iosTemplate.wic1 || iosTemplate.wic1 === ''">
<mat-select placeholder="WIC 1" [(ngModel)]="iosTemplate.wic1" [ngModelOptions]="{ standalone: true }">
<mat-option *ngFor="let option of networkModules[iosTemplate.platform][1]" [value]="option">
{{ option }}
</mat-option>
</mat-select>
</div>
<div *ngIf="iosTemplate.wic2 || iosTemplate.wic2 === ''">
<mat-select placeholder="WIC 2" [(ngModel)]="iosTemplate.wic2" [ngModelOptions]="{ standalone: true }">
<mat-option *ngFor="let option of networkModules[iosTemplate.platform][2]" [value]="option">
{{ option }}
</mat-option>
</mat-select>
</div>
</mat-expansion-panel> </mat-expansion-panel>
<mat-expansion-panel> <mat-expansion-panel>
<mat-expansion-panel-header> <mat-expansion-panel-header>
@ -240,8 +227,8 @@
</mat-form-field> </mat-form-field>
<mat-form-field class="form-field"> <mat-form-field class="form-field">
<input <input
[ngModelOptions]="{ standalone: true }"
matInput matInput
formControlName="mac_addr"
type="text" type="text"
[(ngModel)]="iosTemplate.mac_addr" [(ngModel)]="iosTemplate.mac_addr"
placeholder="Base MAC" placeholder="Base MAC"
@ -249,8 +236,8 @@
</mat-form-field> </mat-form-field>
<mat-form-field class="form-field"> <mat-form-field class="form-field">
<input <input
[ngModelOptions]="{ standalone: true }"
matInput matInput
formControlName="idlepc"
type="text" type="text"
[(ngModel)]="iosTemplate.idlepc" [(ngModel)]="iosTemplate.idlepc"
placeholder="Idle-PC" placeholder="Idle-PC"

View File

@ -16,10 +16,7 @@ import { ToasterService } from '../../../../services/toaster.service';
export class IosTemplateDetailsComponent implements OnInit { export class IosTemplateDetailsComponent implements OnInit {
controller:Controller ; controller:Controller ;
iosTemplate: IosTemplate; iosTemplate: IosTemplate;
isSymbolSelectionOpened: boolean = false; isSymbolSelectionOpened: boolean = false;
networkAdaptersForTemplate: string[] = [];
platforms: string[] = []; platforms: string[] = [];
consoleTypes: string[] = []; consoleTypes: string[] = [];
categories = []; categories = [];
@ -28,9 +25,10 @@ export class IosTemplateDetailsComponent implements OnInit {
chassis = {}; chassis = {};
defaultRam = {}; defaultRam = {};
defaultNvram = {}; defaultNvram = {};
networkAdapters = {}; networkAdaptersForTemplate: string[] = [];
networkAdaptersForPlatform = {}; wicsForTemplate: string[] = [];
networkModules = {}; adapterMatrix = {};
wicMatrix = {};
generalSettingsForm: UntypedFormGroup; generalSettingsForm: UntypedFormGroup;
memoryForm: UntypedFormGroup; memoryForm: UntypedFormGroup;
@ -66,6 +64,8 @@ export class IosTemplateDetailsComponent implements OnInit {
idlemax: new UntypedFormControl('', Validators.required), idlemax: new UntypedFormControl('', Validators.required),
idlesleep: new UntypedFormControl('', Validators.required), idlesleep: new UntypedFormControl('', Validators.required),
execarea: new UntypedFormControl('', Validators.required), execarea: new UntypedFormControl('', Validators.required),
idlepc: new UntypedFormControl('', Validators.pattern(this.iosConfigurationService.getIdlepcRegex())),
mac_addr: new UntypedFormControl('', Validators.pattern(this.iosConfigurationService.getMacAddrRegex())),
}); });
} }
@ -78,16 +78,12 @@ export class IosTemplateDetailsComponent implements OnInit {
this.getConfiguration(); this.getConfiguration();
this.iosService.getTemplate(this.controller, template_id).subscribe((iosTemplate: IosTemplate) => { this.iosService.getTemplate(this.controller, template_id).subscribe((iosTemplate: IosTemplate) => {
this.iosTemplate = iosTemplate; this.iosTemplate = iosTemplate;
this.fillSlotsData();
this.fillAdaptersData();
}); });
}); });
} }
getConfiguration() { getConfiguration() {
this.networkModules = this.iosConfigurationService.getNetworkModules();
this.networkAdaptersForPlatform = this.iosConfigurationService.getNetworkAdaptersForPlatform();
this.networkAdapters = this.iosConfigurationService.getNetworkAdapters();
this.platforms = this.iosConfigurationService.getAvailablePlatforms(); this.platforms = this.iosConfigurationService.getAvailablePlatforms();
this.platformsWithEtherSwitchRouterOption = this.iosConfigurationService.getPlatformsWithEtherSwitchRouterOption(); this.platformsWithEtherSwitchRouterOption = this.iosConfigurationService.getPlatformsWithEtherSwitchRouterOption();
this.platformsWithChassis = this.iosConfigurationService.getPlatformsWithChassis(); this.platformsWithChassis = this.iosConfigurationService.getPlatformsWithChassis();
@ -95,35 +91,55 @@ export class IosTemplateDetailsComponent implements OnInit {
this.defaultRam = this.iosConfigurationService.getDefaultRamSettings(); this.defaultRam = this.iosConfigurationService.getDefaultRamSettings();
this.consoleTypes = this.iosConfigurationService.getConsoleTypes(); this.consoleTypes = this.iosConfigurationService.getConsoleTypes();
this.categories = this.iosConfigurationService.getCategories(); this.categories = this.iosConfigurationService.getCategories();
this.adapterMatrix = this.iosConfigurationService.getAdapterMatrix();
this.wicMatrix = this.iosConfigurationService.getWicMatrix();
} }
fillAdaptersData() { fillSlotsData() {
if (this.iosTemplate.slot0) this.networkAdaptersForTemplate[0] = this.iosTemplate.slot0;
if (this.iosTemplate.slot1) this.networkAdaptersForTemplate[1] = this.iosTemplate.slot1; // load network adapters
if (this.iosTemplate.slot2) this.networkAdaptersForTemplate[2] = this.iosTemplate.slot2; for (let i = 0; i <= 6; i++) {
if (this.iosTemplate.slot3) this.networkAdaptersForTemplate[3] = this.iosTemplate.slot3; if (this.iosTemplate[`slot${i}`]) {
if (this.iosTemplate.slot4) this.networkAdaptersForTemplate[4] = this.iosTemplate.slot4; this.networkAdaptersForTemplate[i] = this.iosTemplate[`slot${i}`];
if (this.iosTemplate.slot5) this.networkAdaptersForTemplate[5] = this.iosTemplate.slot5; }
if (this.iosTemplate.slot6) this.networkAdaptersForTemplate[6] = this.iosTemplate.slot6; }
if (this.iosTemplate.slot7) this.networkAdaptersForTemplate[7] = this.iosTemplate.slot7;
// load WICs
for (let i = 0; i <= 3; i++) {
if (this.iosTemplate[`wic${i}`]) {
this.wicsForTemplate[i] = this.iosTemplate[`wic${i}`];
}
}
} }
completeAdaptersData() { saveSlotsData() {
if (this.networkAdaptersForTemplate[0]) this.iosTemplate.slot0 = this.networkAdaptersForTemplate[0];
if (this.networkAdaptersForTemplate[1]) this.iosTemplate.slot1 = this.networkAdaptersForTemplate[1]; // save network adapters
if (this.networkAdaptersForTemplate[2]) this.iosTemplate.slot2 = this.networkAdaptersForTemplate[2]; for (let i = 0; i <= 6; i++) {
if (this.networkAdaptersForTemplate[3]) this.iosTemplate.slot3 = this.networkAdaptersForTemplate[3]; if (this.adapterMatrix[this.iosTemplate.platform][this.iosTemplate.chassis || ''][i]) {
if (this.networkAdaptersForTemplate[4]) this.iosTemplate.slot4 = this.networkAdaptersForTemplate[4]; if (this.networkAdaptersForTemplate[i] === undefined)
if (this.networkAdaptersForTemplate[5]) this.iosTemplate.slot5 = this.networkAdaptersForTemplate[5]; this.iosTemplate[`slot${i}`] = ""
if (this.networkAdaptersForTemplate[6]) this.iosTemplate.slot6 = this.networkAdaptersForTemplate[6]; else
if (this.networkAdaptersForTemplate[7]) this.iosTemplate.slot7 = this.networkAdaptersForTemplate[7]; this.iosTemplate[`slot${i}`] = this.networkAdaptersForTemplate[i];
}
}
// save WICs
for (let i = 0; i <= 3; i++) {
if (this.wicMatrix[this.iosTemplate.platform][i]) {
if (this.wicsForTemplate[i] === undefined)
this.iosTemplate[`wic${i}`] = ""
else
this.iosTemplate[`wic${i}`] = this.wicsForTemplate[i];
}
}
} }
onSave() { onSave() {
if (this.generalSettingsForm.invalid || this.memoryForm.invalid || this.advancedForm.invalid) { if (this.generalSettingsForm.invalid || this.memoryForm.invalid || this.advancedForm.invalid) {
this.toasterService.error(`Fill all required fields`); this.toasterService.error(`Fill all required fields`);
} else { } else {
this.completeAdaptersData(); this.saveSlotsData();
this.iosService.saveTemplate(this.controller, this.iosTemplate).subscribe((iosTemplate: IosTemplate) => { this.iosService.saveTemplate(this.controller, this.iosTemplate).subscribe((iosTemplate: IosTemplate) => {
this.toasterService.success('Changes saved'); this.toasterService.success('Changes saved');

View File

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

View File

@ -44,11 +44,9 @@ export class ConfiguratorDialogIosComponent implements OnInit {
nvram: 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({ this.advancedSettingsForm = this.formBuilder.group({
mac_addr: new UntypedFormControl('', Validators.pattern(mac_regex)), mac_addr: new UntypedFormControl('', Validators.pattern(this.configurationService.getMacAddrRegex())),
idlepc: new UntypedFormControl('', Validators.pattern(idlepc_regex)), idlepc: new UntypedFormControl('', Validators.pattern(this.configurationService.getIdlepcRegex())),
}); });
} }

View File

@ -46,10 +46,7 @@ export class IosConfigurationService {
c1700: 128, c1700: 128,
c2600: 128, c2600: 128,
c2691: 256, c2691: 256,
c3600: 192, c3600: 256,
c3620: 192,
c3640: 192,
c3660: 192,
c3725: 256, c3725: 256,
c3745: 256, c3745: 256,
c7200: 512, c7200: 512,
@ -163,7 +160,7 @@ export class IosConfigurationService {
} }
// 7206s allow an IO controller in slot 0, and a generic PA in slots 1-6 // 7206s allow an IO controller in slot 0, and a generic PA in slots 1-6
adapter_matrix["c7200"][""] = { 0: ["IO_C7200"] }; adapter_matrix["c7200"][""] = { 0: this.c7200_io };
for (let slot = 1; slot < 7; slot++) { for (let slot = 1; slot < 7; slot++) {
adapter_matrix["c7200"][""][slot] = this.c7200_pas; adapter_matrix["c7200"][""][slot] = this.c7200_pas;
} }
@ -182,170 +179,11 @@ export class IosConfigurationService {
return wic_matrix; return wic_matrix;
} }
getNetworkModules() { getIdlepcRegex() {
return { return /^(0x[0-9a-fA-F]+)?$|^$/;
c1700: {
0: this.c1700_wics,
1: this.c1700_wics,
},
c2600: {
0: this.c2600_wics,
1: this.c2600_wics,
2: this.c2600_wics,
},
c2691: {
0: this.c3700_wics,
1: this.c3700_wics,
2: this.c3700_wics,
},
c3725: {
0: this.c3700_wics,
1: this.c3700_wics,
2: this.c3700_wics,
},
c3745: {
0: this.c3700_wics,
1: this.c3700_wics,
2: this.c3700_wics,
},
};
} }
getNetworkAdapters() { getMacAddrRegex() {
return { return /^([0-9a-fA-F]{4}\.){2}[0-9a-fA-F]{4}$|^$/;
'1720': {
0: ['C1700-MB-1FE'],
},
'1721': {
0: ['C1700-MB-1FE'],
},
'1750': {
0: ['C1700-MB-1FE'],
},
'1751': {
0: ['C1700-MB-1FE'],
1: ['C1700-MB-WIC1'],
},
'1760': {
0: ['C1700-MB-1FE'],
1: ['C1700-MB-WIC1'],
},
'2610': {
0: ['C2600-MB-1E'],
1: this.c2600_nms,
},
'2611': {
0: ['C2600-MB-2E'],
1: this.c2600_nms,
},
'2620': {
0: ['C2600-MB-1FE'],
1: this.c2600_nms,
},
'2621': {
0: ['C2600-MB-2FE'],
1: this.c2600_nms,
},
'2610XM': {
0: ['C2600-MB-1FE'],
1: this.c2600_nms,
},
'2611XM': {
0: ['C2600-MB-2FE'],
1: this.c2600_nms,
},
'2620XM': {
0: ['C2600-MB-1FE'],
1: this.c2600_nms,
},
'2621XM': {
0: ['C2600-MB-2FE'],
1: this.c2600_nms,
},
'2650XM': {
0: ['C2600-MB-1FE'],
1: this.c2600_nms,
},
'2651XM': {
0: ['C2600-MB-2FE'],
1: this.c2600_nms,
},
'3620': {
0: this.c3600_nms,
1: this.c3600_nms,
},
'3640': {
0: this.c3600_nms,
1: this.c3600_nms,
2: this.c3600_nms,
3: this.c3600_nms,
},
'3660': {
0: ['Leopard-2FE'],
1: this.c3600_nms,
2: this.c3600_nms,
3: this.c3600_nms,
4: this.c3600_nms,
5: this.c3600_nms,
6: this.c3600_nms,
},
};
}
getNetworkAdaptersForPlatform() {
let networkAdaptersForPlatform = {};
networkAdaptersForPlatform['c2691'] = {
0: ['GT96100-FE'],
1: this.c3700_nms,
};
networkAdaptersForPlatform['c3725'] = {
0: ['GT96100-FE'],
1: this.c3700_nms,
2: this.c3700_nms,
};
networkAdaptersForPlatform['c3745'] = {
0: ['GT96100-FE'],
1: this.c3700_nms,
2: this.c3700_nms,
3: this.c3700_nms,
4: this.c3700_nms,
};
networkAdaptersForPlatform['c7200'] = {
0: this.c7200_io,
1: this.c7200_pas,
2: this.c7200_pas,
3: this.c7200_pas,
4: this.c7200_pas,
5: this.c7200_pas,
6: this.c7200_pas,
};
return {
c2691: {
0: ['GT96100-FE'],
1: this.c3700_nms,
},
c3725: {
0: ['GT96100-FE'],
1: this.c3700_nms,
2: this.c3700_nms,
},
c3745: {
0: ['GT96100-FE'],
1: this.c3700_nms,
2: this.c3700_nms,
3: this.c3700_nms,
4: this.c3700_nms,
},
c7200: {
0: this.c7200_io,
1: this.c7200_pas,
2: this.c7200_pas,
3: this.c7200_pas,
4: this.c7200_pas,
5: this.c7200_pas,
6: this.c7200_pas,
},
};
} }
} }