import { environment } from 'environment';
import { NSUPDATE, TERMINATEVNF } from 'NSInstanceModel';
import { RestService } from 'RestService';
-import { SharedService, isNullOrUndefined } from 'SharedService';
+import { isNullOrUndefined } from 'SharedService';
+import { SharedService } from 'SharedService';
import { VNFD } from 'VNFDModel';
-import { InstanceData, 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 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]]
});
}
*/
public getSelectedVNF(id: string): void {
this.instanceId = id;
+ this.getVdu(this.instanceId);
let memberIndexFilteredData: {}[] = [];
const memberIndex: string = 'MemberIndex';
memberIndexFilteredData = this.nsIdFilteredData.filter((vnfdData: {}[]): boolean =>
}
}
+ /** 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');
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