diff --git a/src/app/components/preferences/dynamips/add-ios-template/add-ios-template.component.html b/src/app/components/preferences/dynamips/add-ios-template/add-ios-template.component.html index 10e77a28..59b44551 100644 --- a/src/app/components/preferences/dynamips/add-ios-template/add-ios-template.component.html +++ b/src/app/components/preferences/dynamips/add-ios-template/add-ios-template.component.html @@ -109,32 +109,24 @@ - -
-
+
+
+ {{ "" }} + + {{ option }} @@ -144,33 +136,33 @@
- -
-
- +
+ + + {{ "" }} + + - - {{ option }} - - -
+ {{ option }} + +
- - - +
+ + + +
diff --git a/src/app/components/preferences/dynamips/add-ios-template/add-ios-template.component.ts b/src/app/components/preferences/dynamips/add-ios-template/add-ios-template.component.ts index c43e91eb..7fc7bc80 100644 --- a/src/app/components/preferences/dynamips/add-ios-template/add-ios-template.component.ts +++ b/src/app/components/preferences/dynamips/add-ios-template/add-ios-template.component.ts @@ -32,11 +32,8 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy { iosImageForm: UntypedFormGroup; iosNameForm: UntypedFormGroup; iosMemoryForm: UntypedFormGroup; + iosIdlePCForm: UntypedFormGroup; selectedPlatform: string; - - networkAdaptersForTemplate: string[] = []; - networkModulesForTemplate: string[] = []; - iosImages: IosImage[] = []; platforms: string[] = []; platformsWithEtherSwitchRouterOption = {}; @@ -44,9 +41,10 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy { chassis = {}; defaultRam = {}; defaultNvram = {}; - networkAdapters = {}; - networkAdaptersForPlatform = {}; - networkModules = {}; + networkAdaptersForTemplate: string[] = []; + wicsForTemplate: string[] = []; + adapterMatrix = {}; + wicMatrix = {}; ciscoUrl: string = 'https://cfn.cloudapps.cisco.com/ITDIT/CFN/jsp/SearchBySoftware.jsp'; uploader: FileUploader; @@ -82,6 +80,10 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy { this.iosMemoryForm = this.formBuilder.group({ memory: new UntypedFormControl(null, [Validators.required]), }); + + this.iosIdlePCForm = this.formBuilder.group({ + idlepc: new UntypedFormControl(null, [Validators.pattern(this.iosConfigurationService.getIdlepcRegex())]), + }); } ngOnInit() { @@ -120,19 +122,31 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy { this.templateMocksService.getIosTemplate().subscribe((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.platformsWithEtherSwitchRouterOption = this.iosConfigurationService.getPlatformsWithEtherSwitchRouterOption(); this.platformsWithChassis = this.iosConfigurationService.getPlatformsWithChassis(); this.chassis = this.iosConfigurationService.getChassis(); 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) { if (controllerType === 'local') { this.isLocalComputerChosen = true; @@ -166,6 +180,7 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy { if ( !this.iosImageForm.invalid && !this.iosMemoryForm.invalid && + !this.iosIdlePCForm.invalid && this.iosNameForm.get('templateName').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.networkModulesForTemplate.length > 0) this.completeModulesData(); + if (this.wicsForTemplate.length > 0) this.completeWicsData(); this.iosTemplate.compute_id = 'local'; this.iosService.addTemplate(this.controller, this.iosTemplate).subscribe((template: IosTemplate) => { @@ -196,44 +211,25 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy { } completeAdaptersData() { - if (this.chassis[this.iosTemplate.platform]) { - if (Object.keys(this.networkAdapters[this.iosTemplate.chassis])) { - for (let i = 0; i < Object.keys(this.networkAdapters[this.iosTemplate.chassis]).length; i++) { - if (!this.networkAdaptersForTemplate[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] = ''; - } + for (let i = 0; i <= 6; i++) { + if (this.adapterMatrix[this.iosTemplate.platform][this.iosTemplate.chassis || ''][i]) { + if (this.networkAdaptersForTemplate[i] === undefined) + this.iosTemplate[`slot${i}`] = "" + else + this.iosTemplate[`slot${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() { - if (Object.keys(this.networkModules[this.iosTemplate.platform])) { - for (let i = 0; i < Object.keys(this.networkModules[this.iosTemplate.platform]).length; i++) { - if (!this.networkModulesForTemplate[i]) this.networkModulesForTemplate[i] = ''; + completeWicsData() { + 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]; } } - - 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() { @@ -252,25 +248,31 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy { this.selectedPlatform = name; } - if (name === 'c1700') { - this.iosNameForm.controls['chassis'].setValue('1720'); + if (name === 'c3620' || name === 'c3640' || name === 'c3660') + this.iosNameForm.controls['chassis'].setValue(name.substring(1)); + else if (name === 'c1700') { + this.iosNameForm.controls['chassis'].setValue('1760'); } else if (name === 'c2600') { - this.iosNameForm.controls['chassis'].setValue('2610'); + this.iosNameForm.controls['chassis'].setValue('2651XM'); } else { this.iosNameForm.controls['chassis'].setValue(''); } - - this.iosMemoryForm.controls['memory'].setValue(this.defaultRam[name]); + this.iosMemoryForm.controls['memory'].setValue(this.defaultRam[this.selectedPlatform]); + this.fillDefaultSlots(); } onPlatformChosen() { this.iosTemplate.chassis = ''; this.networkAdaptersForTemplate = []; - this.networkModulesForTemplate = []; + this.wicsForTemplate = []; + if (!this.chassis[this.iosNameForm.get('platform').value]) + this.fillDefaultSlots(); } onChassisChosen() { this.networkAdaptersForTemplate = []; + if (this.chassis[this.iosNameForm.get('platform').value]) + this.fillDefaultSlots(); } cancelUploading() { diff --git a/src/app/components/preferences/dynamips/ios-template-details/ios-template-details.component.html b/src/app/components/preferences/dynamips/ios-template-details/ios-template-details.component.html index aba53f1d..34de0eba 100644 --- a/src/app/components/preferences/dynamips/ios-template-details/ios-template-details.component.html +++ b/src/app/components/preferences/dynamips/ios-template-details/ios-template-details.component.html @@ -169,60 +169,47 @@ Slots
Adapters
-
-
- + + - + {{ "" }} + + + {{ option }} + + +
+
+
+
WICs
+
+ + + {{ "" }} + + {{ option }}
-
-
- - - {{ option }} - - -
-
-

-
WICs
-
- - - {{ option }} - - -
-
- - - {{ option }} - - -
-
- - - {{ option }} - - -
@@ -240,8 +227,8 @@ { this.iosTemplate = iosTemplate; - - this.fillAdaptersData(); + this.fillSlotsData(); }); }); } getConfiguration() { - this.networkModules = this.iosConfigurationService.getNetworkModules(); - this.networkAdaptersForPlatform = this.iosConfigurationService.getNetworkAdaptersForPlatform(); - this.networkAdapters = this.iosConfigurationService.getNetworkAdapters(); this.platforms = this.iosConfigurationService.getAvailablePlatforms(); this.platformsWithEtherSwitchRouterOption = this.iosConfigurationService.getPlatformsWithEtherSwitchRouterOption(); this.platformsWithChassis = this.iosConfigurationService.getPlatformsWithChassis(); @@ -95,35 +91,55 @@ export class IosTemplateDetailsComponent implements OnInit { this.defaultRam = this.iosConfigurationService.getDefaultRamSettings(); this.consoleTypes = this.iosConfigurationService.getConsoleTypes(); this.categories = this.iosConfigurationService.getCategories(); + this.adapterMatrix = this.iosConfigurationService.getAdapterMatrix(); + this.wicMatrix = this.iosConfigurationService.getWicMatrix(); } - fillAdaptersData() { - if (this.iosTemplate.slot0) this.networkAdaptersForTemplate[0] = this.iosTemplate.slot0; - if (this.iosTemplate.slot1) this.networkAdaptersForTemplate[1] = this.iosTemplate.slot1; - if (this.iosTemplate.slot2) this.networkAdaptersForTemplate[2] = this.iosTemplate.slot2; - if (this.iosTemplate.slot3) this.networkAdaptersForTemplate[3] = this.iosTemplate.slot3; - if (this.iosTemplate.slot4) this.networkAdaptersForTemplate[4] = this.iosTemplate.slot4; - 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; + fillSlotsData() { + + // load network adapters + for (let i = 0; i <= 6; i++) { + if (this.iosTemplate[`slot${i}`]) { + this.networkAdaptersForTemplate[i] = this.iosTemplate[`slot${i}`]; + } + } + + // load WICs + for (let i = 0; i <= 3; i++) { + if (this.iosTemplate[`wic${i}`]) { + this.wicsForTemplate[i] = this.iosTemplate[`wic${i}`]; + } + } } - completeAdaptersData() { - 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]; + saveSlotsData() { + + // save network adapters + for (let i = 0; i <= 6; i++) { + if (this.adapterMatrix[this.iosTemplate.platform][this.iosTemplate.chassis || ''][i]) { + if (this.networkAdaptersForTemplate[i] === undefined) + this.iosTemplate[`slot${i}`] = "" + else + 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() { if (this.generalSettingsForm.invalid || this.memoryForm.invalid || this.advancedForm.invalid) { this.toasterService.error(`Fill all required fields`); } else { - this.completeAdaptersData(); + this.saveSlotsData(); this.iosService.saveTemplate(this.controller, this.iosTemplate).subscribe((iosTemplate: IosTemplate) => { this.toasterService.success('Changes saved'); diff --git a/src/app/components/project-map/node-editors/configurator/ios/configurator-ios.component.html b/src/app/components/project-map/node-editors/configurator/ios/configurator-ios.component.html index 296f8acf..2a4fcddd 100644 --- a/src/app/components/project-map/node-editors/configurator/ios/configurator-ios.component.html +++ b/src/app/components/project-map/node-editors/configurator/ios/configurator-ios.component.html @@ -113,45 +113,44 @@
Adapters
-
- + - - {{ "" }} - - - {{ option }} - - -
+ {{ "" }} + + + {{ option }} + +

WICs
-
- - - {{ "" }} - - - {{ option }} - - -
+ + + {{ "" }} + + + {{ option }} + +
diff --git a/src/app/components/project-map/node-editors/configurator/ios/configurator-ios.component.ts b/src/app/components/project-map/node-editors/configurator/ios/configurator-ios.component.ts index 187e666d..9821a486 100644 --- a/src/app/components/project-map/node-editors/configurator/ios/configurator-ios.component.ts +++ b/src/app/components/project-map/node-editors/configurator/ios/configurator-ios.component.ts @@ -44,11 +44,9 @@ export class ConfiguratorDialogIosComponent implements OnInit { 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)), + mac_addr: new UntypedFormControl('', Validators.pattern(this.configurationService.getMacAddrRegex())), + idlepc: new UntypedFormControl('', Validators.pattern(this.configurationService.getIdlepcRegex())), }); } diff --git a/src/app/services/ios-configuration.service.ts b/src/app/services/ios-configuration.service.ts index 3013cea2..a5fd0231 100644 --- a/src/app/services/ios-configuration.service.ts +++ b/src/app/services/ios-configuration.service.ts @@ -46,10 +46,7 @@ export class IosConfigurationService { c1700: 128, c2600: 128, c2691: 256, - c3600: 192, - c3620: 192, - c3640: 192, - c3660: 192, + c3600: 256, c3725: 256, c3745: 256, 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 - adapter_matrix["c7200"][""] = { 0: ["IO_C7200"] }; + adapter_matrix["c7200"][""] = { 0: this.c7200_io }; for (let slot = 1; slot < 7; slot++) { adapter_matrix["c7200"][""][slot] = this.c7200_pas; } @@ -182,170 +179,11 @@ export class IosConfigurationService { return wic_matrix; } - getNetworkModules() { - return { - 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, - }, - }; + getIdlepcRegex() { + return /^(0x[0-9a-fA-F]+)?$|^$/; } - getNetworkAdapters() { - return { - '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, - }, - }; + getMacAddrRegex() { + return /^([0-9a-fA-F]{4}\.){2}[0-9a-fA-F]{4}$|^$/; } }