Fix Bug 2292: Invalid Member VNF index in Manual Scaling after NS Update remove operation 54/13954/1
authorSANDHYA.JS <sandhya.j@tataelxsi.co.in>
Thu, 12 Oct 2023 05:35:48 +0000 (11:05 +0530)
committerSANDHYA.JS <sandhya.j@tataelxsi.co.in>
Thu, 12 Oct 2023 05:35:48 +0000 (11:05 +0530)
- Will get member vnf index value from vnfinstances api instead
  of nsinstances api in manual scaling.
- Also made code refactoring in other components to avoid linting issue

Change-Id: I30de65c6fe23ddbf560ab45a8505759c4adb5978
Signed-off-by: SANDHYA.JS <sandhya.j@tataelxsi.co.in>
src/app/utilities/ns-update/NsUpdateComponent.ts
src/app/utilities/scaling/ScalingComponent.html
src/app/utilities/scaling/ScalingComponent.ts
src/app/utilities/start-stop-rebuild/StartStopRebuildComponent.ts
src/app/utilities/vertical-scaling/VerticalScalingComponent.ts
src/app/utilities/vm-migration/VmMigrationComponent.ts
src/models/VNFInstanceModel.ts

index b33bfc4..7efba70 100644 (file)
@@ -31,7 +31,7 @@ import { NSUPDATE, TERMINATEVNF } from 'NSInstanceModel';
 import { RestService } from 'RestService';
 import { SharedService } from 'SharedService';
 import { VNFD } from 'VNFDModel';
-import { VNFInstanceDetails } from 'VNFInstanceModel';
+import { InstanceData, VNFInstanceDetails } from 'VNFInstanceModel';
 import { WarningComponent } from 'WarningComponent';
 
 /**
@@ -146,30 +146,35 @@ export class NsUpdateComponent implements OnInit {
 
     /** Getting MemberVnfIndex using NSDescriptor API @public */
     public getMemberVnfIndex(): void {
+        this.isLoadingResults = true;
         const vnfInstanceData: {}[] = [];
         this.restService.getResource(environment.VNFINSTANCES_URL).subscribe((vnfInstancesData: VNFInstanceDetails[]): void => {
             vnfInstancesData.forEach((vnfData: VNFInstanceDetails): void => {
+                const vnfdRef: string = 'vnfd-ref';
+                const memberIndex: string = 'member-vnf-index-ref';
+                const nsrId: string = 'nsr-id-ref';
+                const vnfId: string = 'vnfd-id';
                 const vnfDataObj: {} =
                 {
-                    VNFD: vnfData['vnfd-ref'],
+                    // eslint-disable-next-line security/detect-object-injection
+                    VNFD: vnfData[vnfdRef],
                     VNFInstanceId: vnfData._id,
-                    MemberIndex: vnfData['member-vnf-index-ref'],
-                    NS: vnfData['nsr-id-ref'],
-                    VNFID: vnfData['vnfd-id']
+                    // eslint-disable-next-line security/detect-object-injection
+                    MemberIndex: vnfData[memberIndex],
+                    // eslint-disable-next-line security/detect-object-injection
+                    NS: vnfData[nsrId],
+                    // eslint-disable-next-line security/detect-object-injection
+                    VNFID: vnfData[vnfId]
                 };
                 vnfInstanceData.push(vnfDataObj);
             });
             const nsId: string = 'NS';
             // eslint-disable-next-line security/detect-object-injection
             this.nsIdFilteredData = vnfInstanceData.filter((vnfdData: {}[]): boolean => vnfdData[nsId] === this.params.id);
-            this.nsIdFilteredData.forEach((resVNF: {}[]): void => {
-                const memberIndex: string = 'MemberIndex';
-                const vnfinstanceID: string = 'VNFInstanceId';
+            this.nsIdFilteredData.forEach((resVNF: InstanceData): void => {
                 const assignMemberIndex: {} = {
-                    // eslint-disable-next-line security/detect-object-injection
-                    id: resVNF[memberIndex],
-                    // eslint-disable-next-line security/detect-object-injection
-                    vnfinstanceId: resVNF[vnfinstanceID]
+                    id: resVNF.MemberIndex,
+                    vnfinstanceId: resVNF.VNFInstanceId
                 };
                 this.memberVnfIndex.push(assignMemberIndex);
             });
@@ -190,7 +195,7 @@ export class NsUpdateComponent implements OnInit {
         let memberIndexFilteredData: {}[] = [];
         const memberIndex: string = 'MemberIndex';
         memberIndexFilteredData = this.nsIdFilteredData.filter((vnfdData: {}[]): boolean =>
-        // eslint-disable-next-line security/detect-object-injection
+            // eslint-disable-next-line security/detect-object-injection
             vnfdData[memberIndex] === this.memberIndexValue);
         const vnfId: string = 'VNFID';
         const selectedvnfId: string = 'VNFD';
@@ -297,7 +302,7 @@ export class NsUpdateComponent implements OnInit {
                             this.onSubmit();
                         }
                     }).catch((): void => { //empty
-                     }
+                    }
                     );
                 } else {
                     // eslint-disable-next-line security/detect-non-literal-fs-filename
@@ -310,7 +315,7 @@ export class NsUpdateComponent implements OnInit {
                             this.onSubmit();
                         }
                     }).catch((): void => { //empty
-                     });
+                    });
                 }
             }, (error: ERRORDATA): void => {
                 this.restService.handleError(error, 'get');
index 4bcb084..803a320 100644 (file)
@@ -30,8 +30,8 @@ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.i
             </label>
             <div class="col-sm-12">
                 <ng-select formControlName="memberIndex" [clearable]="false"
-                    (change)="getScalingGroupDescriptorName($event.name)" placeholder="Select Member VNF Index *"
-                    [items]="memberVNFIndex" bindLabel="id" bindValue="id"
+                    (change)="getScalingGroupDescriptorName($event.vnfdRef)" placeholder="Select Member VNF Index *"
+                    [items]="memberTypes" bindLabel="id" bindValue="id"
                     [ngClass]="{ 'is-invalid': submitted && f.memberIndex.errors }">
                 </ng-select>
                 <small class="form-text text-muted" *ngIf="selectedVNFID !== ''">vnfd-id : {{ selectedVNFID }}</small>
index ff5ec06..be15660 100644 (file)
@@ -27,11 +27,10 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
 import { TranslateService } from '@ngx-translate/core';
 import { APIURLHEADER, ERRORDATA, MODALCLOSERESPONSEDATA, URLPARAMS } from 'CommonModel';
 import { environment } from 'environment';
-import { DF as NSDF, VNFPROFILE } from 'NSDModel';
 import { RestService } from 'RestService';
 import { SharedService } from 'SharedService';
 import { DF, SCALING, VNFD } from 'VNFDModel';
-
+import { InstanceData, VNFInstanceDetails } from 'VNFInstanceModel';
 /**
  * Creating component
  * @Component takes ScalingComponent.html as template url
@@ -53,7 +52,9 @@ export class ScalingComponent implements OnInit {
     /** Contains the scaling group descriptor names @public */
     public scalingGroup: {}[];
     /** Member index of the NS @public */
-    public memberVNFIndex: {}[];
+    public memberVNFIndex: {}[] = [];
+    /** Items for the memberVNFIndex @public */
+    public memberTypes: {}[];
     /** handles the selected VNFID @public */
     public selectedVNFID: string = '';
     /** Items for the Scale Types @public */
@@ -62,6 +63,8 @@ export class ScalingComponent implements OnInit {
     public scalingForm: FormGroup;
     /** Form valid on submit trigger @public */
     public submitted: boolean = false;
+    /** Array holds VNFR Data filtered with nsr ID @private */
+    private nsIdFilteredData: {}[] = [];
     /** FormBuilder instance added to the formBuilder @private */
     private formBuilder: FormBuilder;
     /** Instance of the rest service @private */
@@ -118,19 +121,45 @@ export class ScalingComponent implements OnInit {
 
     /** Get the member-vnf-index from NS Package -> vnf-profile @public */
     public getmemberIndex(): void {
-        if (this.params.nsd.df.length > 0) {
-            const getconstituentVNFD: {}[] = [];
-            this.params.nsd.df.forEach((data: NSDF): void => {
-                data['vnf-profile'].forEach((vnfProfile: VNFPROFILE): void => {
-                    const assignMemberIndex: {} = {
-                        id: vnfProfile.id,
-                        name: vnfProfile['vnfd-id']
-                    };
-                    getconstituentVNFD.push(assignMemberIndex);
-                });
+        this.isLoadingResults = true;
+        const vnfInstanceData: {}[] = [];
+        this.restService.getResource(environment.VNFINSTANCES_URL).subscribe((vnfInstancesData: VNFInstanceDetails[]): void => {
+            vnfInstancesData.forEach((vnfData: VNFInstanceDetails): void => {
+                const vnfdRef: string = 'vnfd-ref';
+                const memberIndex: string = 'member-vnf-index-ref';
+                const nsrId: string = 'nsr-id-ref';
+                const vnfId: string = 'vnfd-id';
+                const vnfDataObj: {} =
+                {
+                    // eslint-disable-next-line security/detect-object-injection
+                    VNFD: vnfData[vnfdRef],
+                    VNFInstanceId: vnfData._id,
+                    // eslint-disable-next-line security/detect-object-injection
+                    MemberIndex: vnfData[memberIndex],
+                    // eslint-disable-next-line security/detect-object-injection
+                    NS: vnfData[nsrId],
+                    // eslint-disable-next-line security/detect-object-injection
+                    VNFID: vnfData[vnfId]
+                };
+                vnfInstanceData.push(vnfDataObj);
             });
-            this.memberVNFIndex = getconstituentVNFD;
-        }
+            const nsId: string = 'NS';
+            // eslint-disable-next-line security/detect-object-injection
+            this.nsIdFilteredData = vnfInstanceData.filter((vnfdData: {}[]): boolean => vnfdData[nsId] === this.params.id);
+            this.nsIdFilteredData.forEach((resVNF: InstanceData): void => {
+                const assignMemberIndex: {} = {
+                    id: resVNF.MemberIndex,
+                    vnfinstanceId: resVNF.VNFInstanceId,
+                    vnfdRef: resVNF.VNFD
+                };
+                this.memberVNFIndex.push(assignMemberIndex);
+            });
+            this.memberTypes = this.memberVNFIndex;
+            this.isLoadingResults = false;
+        }, (error: ERRORDATA): void => {
+            this.restService.handleError(error, 'get');
+            this.isLoadingResults = false;
+        });
     }
 
     /** Get the scaling-group-descriptor name @public */
index bde04ba..9940129 100644 (file)
@@ -30,7 +30,7 @@ import { StartStopRebuild } from 'NSInstanceModel';
 import { RestService } from 'RestService';
 import { SharedService } from 'SharedService';
 import { DF, VNFD } from 'VNFDModel';
-import { VDUR, VNFInstanceDetails } from 'VNFInstanceModel';
+import { InstanceData, VDUR, VNFInstanceDetails } from 'VNFInstanceModel';
 
 /**
  * Creating component
@@ -121,30 +121,35 @@ export class StartStopRebuildComponent implements OnInit {
 
     /** Getting MemberVnfIndex using VNFInstances API @public */
     public getMemberVnfIndex(): void {
+        this.isLoadingResults = true;
         const vnfInstanceData: {}[] = [];
         this.restService.getResource(environment.VNFINSTANCES_URL).subscribe((vnfInstancesData: VNFInstanceDetails[]): void => {
             vnfInstancesData.forEach((vnfData: VNFInstanceDetails): void => {
+                const vnfdRef: string = 'vnfd-ref';
+                const memberIndex: string = 'member-vnf-index-ref';
+                const nsrId: string = 'nsr-id-ref';
+                const vnfId: string = 'vnfd-id';
                 const vnfDataObj: {} =
                 {
-                    VNFD: vnfData['vnfd-ref'],
+                    // eslint-disable-next-line security/detect-object-injection
+                    VNFD: vnfData[vnfdRef],
                     VNFInstanceId: vnfData._id,
-                    MemberIndex: vnfData['member-vnf-index-ref'],
-                    NS: vnfData['nsr-id-ref'],
-                    VNFID: vnfData['vnfd-id']
+                    // eslint-disable-next-line security/detect-object-injection
+                    MemberIndex: vnfData[memberIndex],
+                    // eslint-disable-next-line security/detect-object-injection
+                    NS: vnfData[nsrId],
+                    // eslint-disable-next-line security/detect-object-injection
+                    VNFID: vnfData[vnfId]
                 };
                 vnfInstanceData.push(vnfDataObj);
             });
             const nsId: string = 'NS';
             // eslint-disable-next-line security/detect-object-injection
             this.nsIdFilteredData = vnfInstanceData.filter((vnfdData: {}[]): boolean => vnfdData[nsId] === this.params.id);
-            this.nsIdFilteredData.forEach((resVNF: {}[]): void => {
-                const memberIndex: string = 'MemberIndex';
-                const vnfinstanceID: string = 'VNFInstanceId';
+            this.nsIdFilteredData.forEach((resVNF: InstanceData): void => {
                 const assignMemberIndex: {} = {
-                    // eslint-disable-next-line security/detect-object-injection
-                    id: resVNF[memberIndex],
-                    // eslint-disable-next-line security/detect-object-injection
-                    vnfinstanceId: resVNF[vnfinstanceID]
+                    id: resVNF.MemberIndex,
+                    vnfinstanceId: resVNF.VNFInstanceId
                 };
                 this.memberVnfIndex.push(assignMemberIndex);
             });
@@ -175,7 +180,6 @@ export class StartStopRebuildComponent implements OnInit {
                             {
                                 'count-index': vdu['count-index'],
                                 VDU: vdu['vdu-id-ref']
-
                             };
                             vnfInstanceData.push(vnfInstanceDataObj);
                         });
index 4d96f8a..7b4c087 100644 (file)
@@ -31,7 +31,7 @@ import { environment } from 'environment';
 import { VerticalScaling } from 'NSInstanceModel';
 import { RestService } from 'RestService';
 import { SharedService } from 'SharedService';
-import { VDUR, VNFInstanceDetails } from 'VNFInstanceModel';
+import { InstanceData, VDUR, VNFInstanceDetails } from 'VNFInstanceModel';
 
 /**
  * Creating component
@@ -125,30 +125,35 @@ export class VerticalScalingComponent implements OnInit {
 
     /** Getting MemberVnfIndex using VNFInstances API @public */
     public getMemberVnfIndex(): void {
+        this.isLoadingResults = true;
         const vnfInstanceData: {}[] = [];
         this.restService.getResource(environment.VNFINSTANCES_URL).subscribe((vnfInstancesData: VNFInstanceDetails[]): void => {
             vnfInstancesData.forEach((vnfData: VNFInstanceDetails): void => {
+                const vnfdRef: string = 'vnfd-ref';
+                const memberIndex: string = 'member-vnf-index-ref';
+                const nsrId: string = 'nsr-id-ref';
+                const vnfId: string = 'vnfd-id';
                 const vnfDataObj: {} =
                 {
-                    VNFD: vnfData['vnfd-ref'],
+                    // eslint-disable-next-line security/detect-object-injection
+                    VNFD: vnfData[vnfdRef],
                     VNFInstanceId: vnfData._id,
-                    MemberIndex: vnfData['member-vnf-index-ref'],
-                    NS: vnfData['nsr-id-ref'],
-                    VNFID: vnfData['vnfd-id']
+                    // eslint-disable-next-line security/detect-object-injection
+                    MemberIndex: vnfData[memberIndex],
+                    // eslint-disable-next-line security/detect-object-injection
+                    NS: vnfData[nsrId],
+                    // eslint-disable-next-line security/detect-object-injection
+                    VNFID: vnfData[vnfId]
                 };
                 vnfInstanceData.push(vnfDataObj);
             });
             const nsId: string = 'NS';
             // eslint-disable-next-line security/detect-object-injection
             this.nsIdFilteredData = vnfInstanceData.filter((vnfdData: {}[]): boolean => vnfdData[nsId] === this.params.id);
-            this.nsIdFilteredData.forEach((resVNF: {}[]): void => {
-                const memberIndex: string = 'MemberIndex';
-                const vnfinstanceID: string = 'VNFInstanceId';
+            this.nsIdFilteredData.forEach((resVNF: InstanceData): void => {
                 const assignMemberIndex: {} = {
-                    // eslint-disable-next-line security/detect-object-injection
-                    id: resVNF[memberIndex],
-                    // eslint-disable-next-line security/detect-object-injection
-                    vnfinstanceId: resVNF[vnfinstanceID]
+                    id: resVNF.MemberIndex,
+                    vnfinstanceId: resVNF.VNFInstanceId
                 };
                 this.memberVnfIndex.push(assignMemberIndex);
             });
@@ -179,7 +184,6 @@ export class VerticalScalingComponent implements OnInit {
                             {
                                 'count-index': vdu['count-index'],
                                 VDU: vdu['vdu-id-ref']
-
                             };
                             vnfInstanceData.push(vnfInstanceDataObj);
                         });
index e53ea11..b629497 100644 (file)
@@ -29,7 +29,7 @@ import { environment } from 'environment';
 import { VMMIGRATION } from 'NSInstanceModel';
 import { RestService } from 'RestService';
 import { SharedService } from 'SharedService';
-import { VDUR, VNFInstanceDetails } from 'VNFInstanceModel';
+import { InstanceData, VDUR, VNFInstanceDetails } from 'VNFInstanceModel';
 
 /**
  * Creating component
@@ -115,30 +115,32 @@ export class VmMigrationComponent implements OnInit {
 
     /** Getting MemberVnfIndex using NSDescriptor API @public */
     public getMemberVnfIndex(): void {
-        const vnfInstanceData: {}[] = [];
         this.isLoadingResults = true;
+        const vnfInstanceData: {}[] = [];
         this.restService.getResource(environment.VNFINSTANCES_URL).subscribe((vnfInstancesData: VNFInstanceDetails[]): void => {
             vnfInstancesData.forEach((vnfData: VNFInstanceDetails): void => {
+                const vnfdRef: string = 'vnfd-ref';
+                const memberIndex: string = 'member-vnf-index-ref';
+                const nsrId: string = 'nsr-id-ref';
                 const vnfDataObj: {} =
                 {
-                    VNFD: vnfData['vnfd-ref'],
+                    // eslint-disable-next-line security/detect-object-injection
+                    VNFD: vnfData[vnfdRef],
                     VNFInstanceId: vnfData._id,
-                    MemberIndex: vnfData['member-vnf-index-ref'],
-                    NS: vnfData['nsr-id-ref']
+                    // eslint-disable-next-line security/detect-object-injection
+                    MemberIndex: vnfData[memberIndex],
+                    // eslint-disable-next-line security/detect-object-injection
+                    NS: vnfData[nsrId]
                 };
                 vnfInstanceData.push(vnfDataObj);
             });
             const nsId: string = 'NS';
             // eslint-disable-next-line security/detect-object-injection
             this.nsIdFilteredData = vnfInstanceData.filter((vnfdData: {}[]): boolean => vnfdData[nsId] === this.params.id);
-            this.nsIdFilteredData.forEach((resVNF: {}[]): void => {
-                const memberIndex: string = 'MemberIndex';
-                const vnfinstanceID: string = 'VNFInstanceId';
+            this.nsIdFilteredData.forEach((resVNF: InstanceData): void => {
                 const assignMemberIndex: {} = {
-                    // eslint-disable-next-line security/detect-object-injection
-                    id: resVNF[memberIndex],
-                    // eslint-disable-next-line security/detect-object-injection
-                    vnfinstanceId: resVNF[vnfinstanceID]
+                    id: resVNF.MemberIndex,
+                    vnfinstanceId: resVNF.VNFInstanceId
                 };
                 this.memberVnfIndex.push(assignMemberIndex);
             });
@@ -170,7 +172,6 @@ export class VmMigrationComponent implements OnInit {
                             {
                                 'count-index': vdu['count-index'],
                                 VDU: vdu['vdu-id-ref']
-
                             };
                             vnfInstanceData.push(vnfInstanceDataObj);
                         });
index de69c1e..4fd63db 100644 (file)
@@ -79,3 +79,9 @@ export interface VNFInstanceData {
     VNFD?: string;
     VNFID?: string;
 }
+/** interface for the nsdInstanceData */
+export interface InstanceData {
+    MemberIndex?: string;
+    VNFInstanceId?: string;
+    VNFD?: string;
+}