Executive primitive bug for lcm-operations-conf 56/10456/1
authorBarath Kumar R <barath.r@tataelxsi.co.in>
Fri, 5 Mar 2021 06:02:19 +0000 (11:32 +0530)
committerBarath Kumar R <barath.r@tataelxsi.co.in>
Fri, 5 Mar 2021 06:02:19 +0000 (11:32 +0530)
 * As per SOL006 packages key change is implemented.

Change-Id: Ifa68fba8e6d76b113de97e55e539b48745ce70c3
Signed-off-by: Barath Kumar R <barath.r@tataelxsi.co.in>
src/app/instances/ns-primitive/NSPrimitiveComponent.ts
src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts

index bfbbe40..c8b7fed 100644 (file)
@@ -277,21 +277,19 @@ export class NSPrimitiveComponent implements OnInit {
         }
     }
     /** Generate vdu section @public */
-    public generateVDUData(vduData: VDUPROFILE, vduConfig: VDUCONFIG[]): VDUPROFILE {
-        const getVDUConfig: VDUCONFIG = vduConfig.filter((itemData: VDUCONFIG): boolean =>
-            itemData.id === vduData['vdu-configuration-id'])[0];
+    public generateVDUData(vduConfig: VDUCONFIG): VDUPROFILE {
         return {
-            id: vduData.id,
-            name: vduData.id,
-            'vdu-configuration': getVDUConfig
+            id: vduConfig.id,
+            name: vduConfig.id,
+            'vdu-configuration': vduConfig
         };
     }
     /** Generate kdu section @public */
-    public generateKDUData(kduData: KDUPRIMITIVELEVEL): KDUPRIMITIVELEVEL {
+    public generateKDUData(kduData: KDUPRIMITIVELEVEL, kduConfig: VDUCONFIG): KDUPRIMITIVELEVEL {
         return {
             name: kduData.name,
             'juju-bundle': kduData['juju-bundle'],
-            'kdu-configuration': kduData['kdu-configuration']
+            'kdu-configuration': kduConfig
         };
     }
     /** Used to set the validation and value and update the validation and value @public */
@@ -321,48 +319,56 @@ export class NSPrimitiveComponent implements OnInit {
         this.getFormControl('primitive').setValue(null);
         const apiUrl: string = environment.VNFPACKAGES_URL + '?id=' + vnfdRef;
         this.isLoadingResults = true;
-        this.restService.getResource(apiUrl)
-            .subscribe((vnfdInfo: VNFD[]): void => {
+        this.restService.getResource(apiUrl).subscribe((vnfdInfo: VNFD[]): void => {
                 const vnfInstances: VNFD = vnfdInfo[0];
-                if (!isNullOrUndefined(vnfInstances.df) && !isNullOrUndefined(vnfInstances['vnf-configuration'])) {
+                if (!isNullOrUndefined(vnfInstances.df)) {
                     this.getFormControl('vdu_id').setValidators([]);
                     this.getFormControl('kdu_name').setValidators([]);
                     vnfInstances.df.forEach((df: DF): void => {
-                        if (df['vnf-configuration-id'] !== undefined) {
-                            const vnfprimitiveList: VNFCONFIG = vnfInstances['vnf-configuration']
-                                .filter((itemData: VNFCONFIG): boolean => itemData.id === df['vnf-configuration-id'])[0];
-                            this.primitiveList = vnfprimitiveList['config-primitive'];
+                        if (df['lcm-operations-configuration'] !== undefined) {
+                            if (df['lcm-operations-configuration']['operate-vnf-op-config'] !== undefined) {
+                                const day12Operation: VDUCONFIG[] = df['lcm-operations-configuration']['operate-vnf-op-config']['day1-2'];
+                                if (day12Operation !== undefined) {
+                                    const vnfprimitiveList: VNFCONFIG = day12Operation
+                                        .filter((itemData: VNFCONFIG): boolean => itemData.id === vnfInstances.id)[0];
+                                    if (vnfprimitiveList !== undefined) {
+                                        this.primitiveList = vnfprimitiveList['config-primitive'];
+                                    }
+                                    /** VDU Primitive */
+                                    if (getType === 'VDU_Primitive') {
+                                        this.kduList = [];
+                                        this.vduList = [];
+                                        this.primitiveList = [];
+                                        df['vdu-profile'].forEach((vduProfile: VDUPROFILE): void => {
+                                            day12Operation.forEach((element: VDUCONFIG): void => {
+                                                if (element.id === vduProfile.id){
+                                                    const vduDataObj: VDUPROFILE = this.generateVDUData(element);
+                                                    this.vduList.push(vduDataObj);
+                                                }
+                                            });
+                                        });
+                                    }
+                                    /** KDU Primitive */
+                                    if (getType === 'KDU_Primitive') {
+                                        this.kduList = [];
+                                        this.vduList = [];
+                                        this.primitiveList = [];
+                                        if (!isNullOrUndefined(vnfInstances.kdu)) {
+                                            vnfInstances.kdu.forEach((kduData: KDUPRIMITIVELEVEL): void => {
+                                                day12Operation.forEach((element: VDUCONFIG): void => {
+                                                    if (element.id === kduData.name){
+                                                        const kduDataObj: KDUPRIMITIVELEVEL = this.generateKDUData(kduData, element);
+                                                        this.kduList.push(kduDataObj);
+                                                    }
+                                                });
+                                            });
+                                        }
+                                    }
+                                }
+                            }
                         }
                     });
                 }
-                if (getType === 'VDU_Primitive') {
-                    this.kduList = [];
-                    this.vduList = [];
-                    this.primitiveList = [];
-                    if (!isNullOrUndefined(vnfInstances.df) && !isNullOrUndefined(vnfInstances['vdu-configuration'])) {
-                        vnfInstances.df.forEach((df: DF): void => {
-                            if (df['vdu-profile'] !== undefined) {
-                                df['vdu-profile'].forEach((element: VDUPROFILE): void => {
-                                    const vduDataObj: VDUPROFILE = this.generateVDUData(element, vnfInstances['vdu-configuration']);
-                                    this.vduList.push(vduDataObj);
-                                });
-                            }
-                        });
-                    }
-                }
-                if (getType === 'KDU_Primitive') {
-                    this.kduList = [];
-                    this.vduList = [];
-                    this.primitiveList = [];
-                    if (!isNullOrUndefined(vnfInstances.kdu)) {
-                        vnfInstances.kdu.forEach((kduData: KDUPRIMITIVELEVEL): void => {
-                            if (kduData['kdu-configuration']) {
-                                const kduDataObj: KDUPRIMITIVELEVEL = this.generateKDUData(kduData);
-                                this.kduList.push(kduDataObj);
-                            }
-                        });
-                    }
-                }
                 this.isLoadingResults = false;
             }, (error: ERRORDATA): void => {
                 this.isLoadingResults = false;
index e68ce63..c3533ea 100644 (file)
@@ -32,6 +32,7 @@ import { NSPrimitiveComponent } from 'NSPrimitiveComponent';
 import { RestService } from 'RestService';
 import { SharedService } from 'SharedService';
 import { ShowInfoComponent } from 'ShowInfoComponent';
+import { VDU, VNFD } from 'VNFDModel';
 /**
  * Creating component
  * @Component takes NSInstancesActionComponent.html as template url
@@ -121,7 +122,7 @@ export class NSInstancesActionComponent {
   public deleteNSInstance(forceAction: boolean): void {
     const modalRef: NgbModalRef = this.modalService.open(DeleteComponent, { backdrop: 'static' });
     modalRef.componentInstance.params = { forceDeleteType: forceAction };
-    modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
+    modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => {
       if (result) {
         this.sharedService.callData();
       }
@@ -130,14 +131,14 @@ export class NSInstancesActionComponent {
 
   /** History of operations for an Instanace @public */
   public historyOfOperations(): void {
-    this.router.navigate(['/instances/ns/history-operations/', this.instanceID]).catch(() => {
+    this.router.navigate(['/instances/ns/history-operations/', this.instanceID]).catch((): void => {
       // Catch Navigation Error
     });
   }
 
   /** NS Topology */
   public nsTopology(): void {
-    this.router.navigate(['/instances/ns/', this.instanceID]).catch(() => {
+    this.router.navigate(['/instances/ns/', this.instanceID]).catch((): void => {
       // Catch Navigation Error
     });
   }
@@ -154,27 +155,29 @@ export class NSInstancesActionComponent {
   /** Redirect to Grafana Metrics @public */
   public metrics(): void {
     this.isLoadingMetricsResult = true;
-    this.restService.getResource(environment.NSDINSTANCES_URL + '/' + this.instanceID).subscribe((nsData: NSDDetails[]) => {
-      nsData['vnfd-id'].forEach((vnfdID: string[]) => {
+    this.restService.getResource(environment.NSDINSTANCES_URL + '/' + this.instanceID).subscribe((nsData: NSDDetails[]): void => {
+      nsData['vnfd-id'].forEach((vnfdID: string[]): void => {
         this.restService.getResource(environment.VNFPACKAGES_URL + '/' + vnfdID)
-          .subscribe((vnfd: {}[]) => {
-            if (vnfd['monitoring-param'] !== undefined && vnfd['monitoring-param'].length > 0) {
-              this.isLoadingMetricsResult = false;
-              const location: string = environment.GRAFANA_URL + '/' + this.instanceID + '/osm-ns-metrics-metrics';
-              window.open(location);
-            } else {
-              this.isLoadingMetricsResult = false;
-              this.notifierService.notify('error', this.translateService.instant('GRAFANA.METRICSERROR'));
-            }
-            setTimeout(() => {
+          .subscribe((vnfd: VNFD): void => {
+            vnfd.vdu.forEach((vduData: VDU): void => {
+              if (vduData['monitoring-parameter'] !== undefined && vduData['monitoring-parameter'].length > 0) {
+                this.isLoadingMetricsResult = false;
+                const location: string = environment.GRAFANA_URL + '/' + this.instanceID + '/osm-ns-metrics-metrics';
+                window.open(location);
+              } else {
+                this.isLoadingMetricsResult = false;
+                this.notifierService.notify('error', this.translateService.instant('GRAFANA.METRICSERROR'));
+              }
+            });
+            setTimeout((): void => {
               this.cd.detectChanges();
             }, this.timeOut);
-          }, (error: ERRORDATA) => {
+          }, (error: ERRORDATA): void => {
             this.restService.handleError(error, 'get');
             this.isLoadingMetricsResult = false;
           });
       });
-    }, (error: ERRORDATA) => {
+    }, (error: ERRORDATA): void => {
       this.restService.handleError(error, 'get');
       this.isLoadingMetricsResult = false;
     });