import { environment } from 'environment';
import { NSUPDATE, TERMINATEVNF } from 'NSInstanceModel';
import { RestService } from 'RestService';
+import { isNullOrUndefined } from 'SharedService';
import { SharedService } from 'SharedService';
-import { isNullOrUndefined } from 'util';
import { VNFD } from 'VNFDModel';
-import { VNFInstanceDetails } from 'VNFInstanceModel';
+import { InstanceData, VDUDETAIL, VDUR, VNFInstanceDetails } from 'VNFInstanceModel';
import { WarningComponent } from 'WarningComponent';
/**
public memberIndexValue: string;
/** Form Check vnfdId Section @public */
public vnfdIdShow: boolean = false;
+ /** Form Check vduId Section @public */
+ public vduIdShow: boolean = false;
/** Contains MemberVNFIndex values @public */
public memberVnfIndex: {}[] = [];
+ /** Contains MemberVNFIndex content @public */
+ public selectedVnf: {}[];
/** Array holds VNFR Data filtered with nsr ID @public */
public nsIdFilteredData: {}[] = [];
/** Contains vnfdId value @public */
public instanceId: string;
/** Selected VNFInstanceId @public */
public selectedvnfId: string = '';
+ /** Items for vduId & countIndex @public */
+ public vdu: {}[];
+ /** Contains vduId @public */
+ public vduId: {};
/** Input contains component objects @private */
@Input() private params: URLPARAMS;
/** FormBuilder instance added to the formBuilder @private */
{
title: this.translateService.instant('REMOVEVNF'),
value: 'REMOVE_VNF'
+ },
+ {
+ title: this.translateService.instant('VERTICALSCALE'),
+ value: 'VERTICAL_SCALE'
}
];
}
this.nsUpdateForm = this.formBuilder.group({
updateType: [null, [Validators.required]],
memberVnfIndex: [null, [Validators.required]],
- vnfdId: [null, [Validators.required]]
+ vnfdId: [null, [Validators.required]],
+ vduId: [null, [Validators.required]],
+ countIndex: [null, [Validators.required]]
});
}
/** Getting MemberVnfIndex using NSDescriptor API @public */
public getMemberVnfIndex(): void {
+ this.isLoadingResults = true;
const vnfInstanceData: {}[] = [];
this.restService.getResource(environment.VNFINSTANCES_URL).subscribe((vnfInstancesData: VNFInstanceDetails[]): void => {
vnfInstancesData.forEach((vnfData: VNFInstanceDetails): void => {
+ const vnfdRef: string = 'vnfd-ref';
+ const memberIndex: string = 'member-vnf-index-ref';
+ const nsrId: string = 'nsr-id-ref';
+ const vnfId: string = 'vnfd-id';
const vnfDataObj: {} =
{
- VNFD: vnfData['vnfd-ref'],
+ // eslint-disable-next-line security/detect-object-injection
+ VNFD: vnfData[vnfdRef],
VNFInstanceId: vnfData._id,
- MemberIndex: vnfData['member-vnf-index-ref'],
- NS: vnfData['nsr-id-ref'],
- VNFID: vnfData['vnfd-id']
+ // eslint-disable-next-line security/detect-object-injection
+ MemberIndex: vnfData[memberIndex],
+ // eslint-disable-next-line security/detect-object-injection
+ NS: vnfData[nsrId],
+ // eslint-disable-next-line security/detect-object-injection
+ VNFID: vnfData[vnfId]
};
vnfInstanceData.push(vnfDataObj);
});
const nsId: string = 'NS';
+ // eslint-disable-next-line security/detect-object-injection
this.nsIdFilteredData = vnfInstanceData.filter((vnfdData: {}[]): boolean => vnfdData[nsId] === this.params.id);
- this.nsIdFilteredData.forEach((resVNF: {}[]): void => {
- const memberIndex: string = 'MemberIndex';
- const vnfinstanceID: string = 'VNFInstanceId';
+ this.nsIdFilteredData.forEach((resVNF: InstanceData): void => {
const assignMemberIndex: {} = {
- id: resVNF[memberIndex],
- vnfinstanceId: resVNF[vnfinstanceID]
+ id: resVNF.MemberIndex,
+ vnfinstanceId: resVNF.VNFInstanceId
};
this.memberVnfIndex.push(assignMemberIndex);
});
*/
public getSelectedVNF(id: string): void {
this.instanceId = id;
+ this.getVdu(this.instanceId);
let memberIndexFilteredData: {}[] = [];
const memberIndex: string = 'MemberIndex';
memberIndexFilteredData = this.nsIdFilteredData.filter((vnfdData: {}[]): boolean =>
+ // eslint-disable-next-line security/detect-object-injection
vnfdData[memberIndex] === this.memberIndexValue);
const vnfId: string = 'VNFID';
const selectedvnfId: string = 'VNFD';
+ this.selectedVnf = memberIndexFilteredData;
for (const data of memberIndexFilteredData) {
+ // eslint-disable-next-line security/detect-object-injection
this.vnfID = data[vnfId];
+ // eslint-disable-next-line security/detect-object-injection
this.selectedvnfId = data[selectedvnfId];
}
}
+ /** Getting vdu-id & count-index from API */
+ public getVdu(id: string): void {
+ const vnfInstanceData: {}[] = [];
+ this.getFormControl('vduId').setValue(null);
+ this.getFormControl('countIndex').setValue(null);
+ if (!isNullOrUndefined(id)) {
+ this.restService.getResource(environment.VNFINSTANCES_URL + '/' + id).
+ subscribe((vnfInstanceDetail: VNFInstanceDetails): void => {
+ this.instanceId = id;
+ this.selectedvnfId = vnfInstanceDetail['vnfd-ref'];
+ if (!isNullOrUndefined(vnfInstanceDetail.vdur)) {
+ vnfInstanceDetail.vdur.forEach((vdu: VDUR): void => {
+ const vnfInstanceDataObj: {} =
+ {
+ 'count-index': vdu['count-index'],
+ VDU: vdu['vdu-id-ref']
+
+ };
+ vnfInstanceData.push(vnfInstanceDataObj);
+ });
+ this.vdu = vnfInstanceData;
+ this.vduId = this.vdu.filter((vdu: VDUDETAIL, index: number, self: {}[]): {} =>
+ index === self.findIndex((t: VDUDETAIL): {} => (
+ t.VDU === vdu.VDU
+ ))
+ );
+ }
+ }, (error: ERRORDATA): void => {
+ this.restService.handleError(error, 'get');
+ this.isLoadingResults = false;
+ });
+ }
+ }
+
/** Trigger NsUpdate on submit */
public triggerNsUpdate(): void {
this.submitted = true;
this.sharedService.cleanForm(this.nsUpdateForm);
if (this.nsUpdateForm.invalid) { return; } // Proceed, onces form is valid
this.vnfdId = this.nsUpdateForm.value.vnfdId;
- this.checkUpdateType();
+ if (this.terminateVnf === 'VERTICAL_SCALE') {
+ this.getFormControl('countIndex').enable();
+ this.onSubmit();
+ } else {
+ this.checkUpdateType();
+ }
}
/** Ns Update on submit */
removeVnfInstanceId: this.instanceId
};
this.nsUpdateInitialization(nsUpdateTerminatePayload);
- } else {
+ } else if (this.terminateVnf === 'CHANGE_VNFPKG') {
const nsUpdatePayload: NSUPDATE = {
lcmOperationType: 'update',
updateType: this.nsUpdateForm.value.updateType,
}
};
this.nsUpdateInitialization(nsUpdatePayload);
+ } else if (this.terminateVnf === 'VERTICAL_SCALE') {
+ const nsUpdatePayload: NSUPDATE = {
+ lcmOperationType: 'update',
+ updateType: this.nsUpdateForm.value.updateType,
+ nsInstanceId: this.params.id,
+ verticalScaleVnf: {
+ vnfInstanceId: this.instanceId,
+ vnfdId: this.nsUpdateForm.value.vnfdId,
+ countIndex: 0,
+ vduId: this.nsUpdateForm.value.vduId
+ }
+ };
+ this.nsUpdateInitialization(nsUpdatePayload);
}
}
this.isLoadingResults = true;
if (this.nsUpdateForm.value.updateType === 'CHANGE_VNFPKG') {
this.checkVersion();
- } else {
+ } else if (this.nsUpdateForm.value.updateType === 'REMOVE_VNF') {
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
const modalRef: NgbModalRef = this.modalService.open(WarningComponent, { backdrop: 'static' });
modalRef.componentInstance.heading = this.translateService.instant('TERMINATEVNF');
modalRef.componentInstance.confirmationMessage = this.translateService.instant('TERMINATEVNFCONTENT');
if (result.message === CONFIGCONSTANT.done) {
this.onSubmit();
}
- }).catch();
+ }).catch((): void => {
+ // Catch Navigation Error
+ });
}
this.isLoadingResults = false;
}
let vnfIdFilteredData: {}[] = [];
const vnfID: string = 'VNFID';
const version: string = 'version';
+ // eslint-disable-next-line security/detect-object-injection
vnfIdFilteredData = vnfDetails.filter((vnfdData: {}[]): boolean => vnfdData[vnfID] === this.vnfID);
for (const data of vnfIdFilteredData) {
+ // eslint-disable-next-line security/detect-object-injection
this.vnfversion = data[version];
}
if (this.version === this.vnfversion) {
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
const modalRef: NgbModalRef = this.modalService.open(WarningComponent, { backdrop: 'static' });
- modalRef.componentInstance.heading = this.translateService.instant('UPDATEPOLICIES');
- modalRef.componentInstance.confirmationMessage = this.translateService.instant('UPDATEPOLICIESCONTENT');
- modalRef.componentInstance.submitMessage = this.translateService.instant('UPDATEPOLICIES');
+ modalRef.componentInstance.heading = this.translateService.instant('UPDATENS');
+ modalRef.componentInstance.confirmationMessage = this.translateService.instant('GENERICCONTENT');
+ modalRef.componentInstance.submitMessage = this.translateService.instant('UPDATENS');
modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => {
if (result.message === CONFIGCONSTANT.done) {
this.onSubmit();
}
- }).catch();
+ }).catch((): void => { //empty
+ }
+ );
} else {
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
const modalRef: NgbModalRef = this.modalService.open(WarningComponent, { backdrop: 'static' });
modalRef.componentInstance.heading = this.translateService.instant('REDEPLOY');
modalRef.componentInstance.confirmationMessage = this.translateService.instant('REDEPLOYCONTENT');
if (result.message === CONFIGCONSTANT.done) {
this.onSubmit();
}
- }).catch();
+ }).catch((): void => { //empty
+ });
}
}, (error: ERRORDATA): void => {
this.restService.handleError(error, 'get');
};
this.restService.postResource(apiURLHeader, nsUpdatePayload).subscribe((result: {}): void => {
this.activeModal.close(modalData);
- this.router.navigate(['/instances/ns/history-operations/' + this.params.id]).catch();
+ this.router.navigate(['/instances/ns/history-operations/' + this.params.id]).catch((): void => {
+ // Catch Navigation Error
+ });
}, (error: ERRORDATA): void => {
this.restService.handleError(error, 'post');
this.isLoadingResults = false;
this.terminateVnf = value;
if (this.terminateVnf === 'REMOVE_VNF') {
this.vnfdIdShow = true;
+ this.vduIdShow = false;
this.getFormControl('vnfdId').disable();
- } else {
+ this.getFormControl('vduId').disable();
+ this.getFormControl('countIndex').disable();
+ } else if (this.terminateVnf === 'CHANGE_VNFPKG') {
this.vnfdIdShow = false;
+ this.vduIdShow = false;
this.getFormControl('vnfdId').enable();
+ this.getFormControl('vduId').disable();
+ this.getFormControl('countIndex').disable();
+ } else if (this.terminateVnf === 'VERTICAL_SCALE') {
+ this.vnfdIdShow = false;
+ this.vduIdShow = true;
+ this.getFormControl('vnfdId').enable();
+ this.getFormControl('vduId').enable();
+ this.getFormControl('countIndex').disable();
}
}
+ /** Getting count-index by filtering id */
+ public getCountIndex(): void {
+ this.getFormControl('countIndex').patchValue('0');
+ }
+
/** Used to get the AbstractControl of controlName passed @private */
private getFormControl(controlName: string): AbstractControl {
+ // eslint-disable-next-line security/detect-object-injection
return this.nsUpdateForm.controls[controlName];
}
}