diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 1bb18e30..3933d184 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -132,6 +132,7 @@ import { ExternalSoftwareDefinitionService } from './services/external-software- import { PlatformService } from './services/platform.service'; import { IosTemplateDetailsComponent } from './components/preferences/dynamips/ios-template-details/ios-template-details.component'; import { AddIosTemplateComponent } from './components/preferences/dynamips/add-ios-template/add-ios-template.component'; +import { IosConfigurationService } from './services/ios-configuration.service'; if (environment.production) { Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', { @@ -270,7 +271,8 @@ if (environment.production) { IosService, InstalledSoftwareService, ExternalSoftwareDefinitionService, - PlatformService + PlatformService, + IosConfigurationService ], entryComponents: [ AddServerDialogComponent, 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 68cdcbc0..654e6301 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 @@ -1,4 +1,4 @@ -
+

New IOS router

@@ -99,7 +99,7 @@
-
+
{ 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(); }); }); } @@ -302,6 +106,20 @@ export class AddIosTemplateComponent implements OnInit { } completeAdaptersData() { + if (this.chassis[this.iosTemplate.platform]) { + if(Object.keys(this.networkAdapters[this.iosTemplate.platform])){ + for(let i=0; i +
Adapters
+
+
+ + + {{option}} + + +
+
+
+
+ + + {{option}} + + +
+


+
WICs
+
+ + + {{option}} + + +
+
+ + + {{option}} + + +
+
+ + + {{option}} + + +
diff --git a/src/app/components/preferences/dynamips/ios-template-details/ios-template-details.component.ts b/src/app/components/preferences/dynamips/ios-template-details/ios-template-details.component.ts index 6fade9c7..49b8f42f 100644 --- a/src/app/components/preferences/dynamips/ios-template-details/ios-template-details.component.ts +++ b/src/app/components/preferences/dynamips/ios-template-details/ios-template-details.component.ts @@ -6,6 +6,7 @@ import { ToasterService } from '../../../../services/toaster.service'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; import { IosTemplate } from '../../../../models/templates/ios-template'; import { IosService } from '../../../../services/ios.service'; +import { IosConfigurationService } from '../../../../services/ios-configuration.service'; @Component({ @@ -19,20 +20,24 @@ export class IosTemplateDetailsComponent implements OnInit { isSymbolSelectionOpened: boolean = false; - consoleTypes: string[] = ['telnet', 'none']; - categories = [["Default", "guest"], - ["Routers", "router"], - ["Switches", "switch"], - ["End devices", "end_device"], - ["Security devices", "security_device"]]; - isConfiguratorOpened: boolean = false; + networkAdaptersForTemplate: string[] = []; + platforms: string[] = []; + platformsWithEtherSwitchRouterOption = {}; + platformsWithChassis = {}; + chassis = {}; + defaultRam = {}; + defaultNvram = {}; + networkAdapters = {}; + networkAdaptersForPlatform = {}; + networkModules = {}; constructor( private route: ActivatedRoute, private serverService: ServerService, private iosService: IosService, private toasterService: ToasterService, - private formBuilder: FormBuilder + private formBuilder: FormBuilder, + private iosConfigurationService: IosConfigurationService ) {} ngOnInit() { @@ -43,11 +48,47 @@ export class IosTemplateDetailsComponent implements OnInit { this.iosService.getTemplate(this.server, template_id).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.fillAdaptersData(); + + console.log(this.iosTemplate.slot3); }); }); } + 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; + } + + 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]; + } + onSave() { + this.completeAdaptersData(); + this.iosService.saveTemplate(this.server, this.iosTemplate).subscribe((iosTemplate: IosTemplate) => { this.toasterService.success("Changes saved"); }); diff --git a/src/app/services/ios-configuration.service.spec.ts b/src/app/services/ios-configuration.service.spec.ts new file mode 100644 index 00000000..e69de29b diff --git a/src/app/services/ios-configuration.service.ts b/src/app/services/ios-configuration.service.ts new file mode 100644 index 00000000..5eded9dc --- /dev/null +++ b/src/app/services/ios-configuration.service.ts @@ -0,0 +1,243 @@ +import { Injectable } from "@angular/core"; + +@Injectable() +export class IosConfigurationService { + c1700_wics = ["WIC-1T", "WIC-2T", "WIC-1ENET"]; + c2600_wics = ["WIC-1T", "WIC-2T"]; + c3700_wics = ["WIC-1T", "WIC-2T"]; + + c2600_nms = [ + "NM-1FE-TX", + "NM-1E", + "NM-4E", + "NM-16ESW" + ]; + c3600_nms = [ + "NM-1FE-TX", + "NM-1E", + "NM-4E", + "NM-16ESW", + "NM-4T" + ]; + c3700_nms = [ + "NM-1FE-TX", + "NM-4T", + "NM-16ESW", + ]; + c7200_pas = [ + "PA-A1", + "PA-FE-TX", + "PA-2FE-TX", + "PA-GE", + "PA-4T+", + "PA-8T", + "PA-4E", + "PA-8E", + "PA-POS-OC3", + ]; + c7200_io = [ + "C7200-IO-FE", + "C7200-IO-2FE", + "C7200-IO-GE-E" + ]; + + getDefaultRamSettings() { + return { + "c1700": 160, + "c2600": 160, + "c2691": 192, + "c3600": 192, + "c3725": 128, + "c3745": 256, + "c7200": 512 + }; + } + + getDefaultNvRamSettings() { + return { + "c1700": 128, + "c2600": 128, + "c2691": 256, + "c3600": 256, + "c3725": 256, + "c3745": 256, + "c7200": 512 + }; + }; + + getAvailablePlatforms() { + return ["c1700", "c2600", "c2691", "c3725", "c3745", "c3600", "c7200"]; + } + + getPlatformsWithEtherSwitchRouterOption() { + return { + "c1700": false, + "c2600": true, + "c2691": true, + "c3725": true, + "c3745": true, + "c3600": true, + "c7200": false + }; + } + + getPlatformsWithChassis() { + return { + "c1700": true, + "c2600": true, + "c2691": false, + "c3725": false, + "c3745": false, + "c3600": true, + "c7200": false + }; + } + + getChassis() { + return { + "c1700": ["1720", "1721", "1750", "1751", "1760"], + "c2600": ["2610", "2611", "2620", "2621", "2610XM", "2611XM", "2620XM", "2621XM", "2650XM", "2651XM"], + "c3600": ["3620", "3640", "3660"] + }; + } + + 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 + } + }; + } + + 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() { + 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 + } + }; + } +}