Edit page for Ios routers

This commit is contained in:
Piotr Pekala 2019-02-05 04:40:26 -08:00
parent 43d08a9044
commit 71f76be839
7 changed files with 397 additions and 229 deletions

View File

@ -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,

View File

@ -1,4 +1,4 @@
<div class="content" [ngClass]="{ shadowed: isSymbolSelectionOpened }">
<div class="content">
<div class="default-header">
<div class="row">
<h1 class="col">New IOS router</h1>
@ -99,7 +99,7 @@
</mat-step>
<mat-step label="WIC modules">
<div *ngIf="iosTemplate.platform && networkModules[iosTemplate.platform]">
<div *ngFor="let index of [0,1,2,3,4,5,6,7]">
<div *ngFor="let index of [0,1,2,3]">
<mat-select
placeholder="WIC {{index}}"
[(ngModel)]="networkModulesForTemplate[index]"

View File

@ -8,6 +8,7 @@ import { IosTemplate } from '../../../../models/templates/ios-template';
import { IosService } from '../../../../services/ios.service';
import { v4 as uuid } from 'uuid';
import { TemplateMocksService } from '../../../../services/template-mocks.service';
import { IosConfigurationService } from '../../../../services/ios-configuration.service';
@Component({
@ -27,224 +28,17 @@ export class AddIosTemplateComponent implements OnInit {
networkAdaptersForTemplate: string[] = [];
networkModulesForTemplate: string[] = [];
platforms: string[] = ["c1700", "c2600", "c2691", "c3725", "c3745", "c3600", "c7200"];
platformsWithEtherSwitchRouterOption = {
"c1700": false,
"c2600": true,
"c2691": true,
"c3725": true,
"c3745": true,
"c3600": true,
"c7200": false
};
platformsWithChassis = {
"c1700": true,
"c2600": true,
"c2691": false,
"c3725": false,
"c3745": false,
"c3600": true,
"c7200": false
};
chassis = {
"c1700": ["1720", "1721", "1750", "1751", "1760"],
"c2600": ["2610", "2611", "2620", "2621", "2610XM", "2611XM", "2620XM", "2621XM", "2650XM", "2651XM"],
"c3600": ["3620", "3640", "3660"]
};
defaultRam = {
"c1700": 160,
"c2600": 160,
"c2691": 192,
"c3600": 192,
"c3725": 128,
"c3745": 256,
"c7200": 512
};
defaultNvram = {
"c1700": 128,
"c2600": 128,
"c2691": 256,
"c3600": 256,
"c3725": 256,
"c3745": 256,
"c7200": 512
};
platforms: string[] = [];
platformsWithEtherSwitchRouterOption = {};
platformsWithChassis = {};
chassis = {};
defaultRam = {};
defaultNvram = {};
networkAdapters = {};
networkAdaptersForPlatform = {};
networkModules = {};
ciscoUrl: string = "https://cfn.cloudapps.cisco.com/ITDIT/CFN/jsp/SearchBySoftware.jsp";
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"
];
networkAdapters = {
"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,
7: this.c3600_nms
}
};
networkAdaptersForPlatform = {
"c2691": {
0: ["GT96100-FE"],
1: this.c3700_nms
},
"c3725": {
0: ["GT96100-FE"],
1: this.c3700_nms,
2: this.c3700_nms,
3: this.c3700_nms
},
"c3745": {
0: ["GT96100-FE"],
1: this.c3700_nms,
2: this.c3700_nms,
3: this.c3700_nms,
4: this.c3700_nms,
5: 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,
7: this.c7200_pas
}
};
networkModules = {
"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
}
};
constructor(
private route: ActivatedRoute,
@ -253,7 +47,8 @@ export class AddIosTemplateComponent implements OnInit {
private toasterService: ToasterService,
private formBuilder: FormBuilder,
private router: Router,
private templateMocksService: TemplateMocksService
private templateMocksService: TemplateMocksService,
private iosConfigurationService: IosConfigurationService
) {
this.iosTemplate = new IosTemplate();
@ -277,6 +72,15 @@ export class AddIosTemplateComponent implements OnInit {
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();
});
});
}
@ -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<Object.keys(this.networkAdapters[this.iosTemplate.platform]).length; i++){
if(!this.networkAdaptersForTemplate[i]) this.networkAdaptersForTemplate[i] = '';
}
}
} else {
if(Object.keys(this.networkAdaptersForPlatform[this.iosTemplate.platform])){
for(let i=0; i<Object.keys(this.networkAdaptersForPlatform[this.iosTemplate.platform]).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];
@ -313,6 +131,12 @@ export class AddIosTemplateComponent implements OnInit {
}
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] = '';
}
}
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];

View File

@ -82,6 +82,64 @@
Slots
</mat-panel-title>
</mat-expansion-panel-header>
<h6>Adapters</h6>
<div *ngIf="iosTemplate.chassis && 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="networkAdapters[iosTemplate.chassis][index]">
<mat-option *ngFor="let option of networkAdapters[iosTemplate.chassis][index]" [value]="option">
{{option}}
</mat-option>
</mat-select>
</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-header>

View File

@ -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");
});

View File

@ -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
}
};
}
}