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 <barath.r@tataelxsi.co.in>
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 @@
                     [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">
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
@@ -116,6 +116,10 @@
         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 @@
                 value: 'VDU_Primitive'
             }
         ];
-        this.primitiveType = 'VNF_Primitive';
     }
 
     /**
@@ -137,9 +140,6 @@
                 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 @@
         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 @@
                 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];