NG-UI Bug 1136 - Unable to execute NS level primitive 99/9399/4
authorBarath Kumar R <barath.r@tataelxsi.co.in>
Mon, 13 Jul 2020 15:24:13 +0000 (20:54 +0530)
committerrbara <barath.r@tataelxsi.co.in>
Tue, 14 Jul 2020 14:16:13 +0000 (16:16 +0200)
 * 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 <barath.r@tataelxsi.co.in>
src/app/instances/ns-primitive/NSPrimitiveComponent.html
src/app/instances/ns-primitive/NSPrimitiveComponent.ts
src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts

index 087eac6..3c96d80 100644 (file)
@@ -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 }"></ng-select>
             </div>
         </div>
-        <div class="form-group row">
+        <div class="form-group row" *ngIf="primitiveType">
             <label class="col-sm-4 col-form-label">
                 {{'PAGE.NSPRIMITIVE.PRIMITIVE' | translate}}*</label>
             <div class="col-sm-8">
index 4b9616b..ab026dc 100644 (file)
@@ -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];
index 8bf43ce..6ccfb1e 100644 (file)
@@ -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
     };
   }