From 54d693cd96cfc4d212fec2b4ff37f10969bcb74e Mon Sep 17 00:00:00 2001 From: Barath Kumar R Date: Mon, 13 Jul 2020 20:54:13 +0530 Subject: [PATCH] NG-UI Bug 1136 - Unable to execute NS level primitive * The change in the NBI causes the issues. Which the NS level primitive cannot be launched. * To run the NS level primitive Execution. Need to get the ns packages yaml file to check ns-configuration is presented and the primitive to executed. Change-Id: I10acf999de66237d1b8e79213b51b7ff526e8c66 Signed-off-by: Barath Kumar R --- .../ns-primitive/NSPrimitiveComponent.html | 2 +- .../ns-primitive/NSPrimitiveComponent.ts | 30 +++++++++++++++---- .../NSInstancesActionComponent.ts | 3 +- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/app/instances/ns-primitive/NSPrimitiveComponent.html b/src/app/instances/ns-primitive/NSPrimitiveComponent.html index 087eac6..3c96d80 100644 --- a/src/app/instances/ns-primitive/NSPrimitiveComponent.html +++ b/src/app/instances/ns-primitive/NSPrimitiveComponent.html @@ -49,7 +49,7 @@ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.i [ngClass]="{ 'is-invalid': submitted && f.vdu_id.errors }"> -
+
diff --git a/src/app/instances/ns-primitive/NSPrimitiveComponent.ts b/src/app/instances/ns-primitive/NSPrimitiveComponent.ts index 4b9616b..ab026dc 100644 --- a/src/app/instances/ns-primitive/NSPrimitiveComponent.ts +++ b/src/app/instances/ns-primitive/NSPrimitiveComponent.ts @@ -115,6 +115,10 @@ export class NSPrimitiveComponent implements OnInit { this.activeModal = this.injector.get(NgbActiveModal); this.formBuilder = this.injector.get(FormBuilder); this.primitiveTypeList = [ + { + title: this.translateService.instant('NSPRIMITIVE'), + value: 'NS_Primitive' + }, { title: this.translateService.instant('VNFPRIMITIVE'), value: 'VNF_Primitive' @@ -124,7 +128,6 @@ export class NSPrimitiveComponent implements OnInit { value: 'VDU_Primitive' } ]; - this.primitiveType = 'VNF_Primitive'; } /** @@ -137,9 +140,6 @@ export class NSPrimitiveComponent implements OnInit { this.nsdId = event.identifier; } }); - if (!isNullOrUndefined(this.params.nsConfig)) { - this.primitiveTypeList.push({ title: this.translateService.instant('NSPRIMITIVE'), value: 'NS_Primitive' }); - } this.initializeForm(); } @@ -225,10 +225,11 @@ export class NSPrimitiveComponent implements OnInit { this.primitiveParameter = []; this.initializeForm(); if (data.value === 'NS_Primitive') { - this.primitiveList = !isNullOrUndefined(this.params.nsConfig['config-primitive']) ? - this.params.nsConfig['config-primitive'] : []; + this.getNSInfo(this.params.name); this.getFormControl('vnf_member_index').setValidators([]); + this.getFormControl('vnf_member_index').updateValueAndValidity(); this.getFormControl('vdu_id').setValidators([]); + this.getFormControl('vdu_id').updateValueAndValidity(); } } /** Member index change event */ @@ -307,6 +308,23 @@ export class NSPrimitiveComponent implements OnInit { this.restService.handleError(error, 'get'); }); } + /** Get primivitive actions from NSD data */ + private getNSInfo(nsdRef: string): void { + this.primitiveList = []; + this.primitiveParameter = []; + this.getFormControl('primitive').setValue(null); + const apiUrl: string = environment.NSDESCRIPTORS_URL + '?short-name=' + nsdRef; + this.isLoadingResults = true; + this.restService.getResource(apiUrl) + .subscribe((nsdInfo: {}) => { + this.primitiveList = !isNullOrUndefined(nsdInfo[0]['ns-configuration']['config-primitive']) ? + nsdInfo[0]['ns-configuration']['config-primitive'] : []; + this.isLoadingResults = false; + }, (error: ERRORDATA) => { + this.isLoadingResults = false; + this.restService.handleError(error, 'get'); + }); + } /** Used to get the AbstractControl of controlName passed @private */ private getFormControl(controlName: string): AbstractControl { return this.primitiveForm.controls[controlName]; diff --git a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts index 8bf43ce..6ccfb1e 100644 --- a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts +++ b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts @@ -146,7 +146,8 @@ export class NSInstancesActionComponent { public execNSPrimitiveModal(): void { this.modalService.open(NSPrimitiveComponent).componentInstance.params = { memberIndex: this.value.memberIndex, - nsConfig: this.value.nsConfig + nsConfig: this.value.nsConfig, + name: this.value.NsdName }; } -- 2.25.1