Fix Bug 1988 - Drop down for action does not reflect what the deployed service can... 31/12631/2 release-v13.0-start v13.0.0 v13.0.0rc1 v13.0.0rc2 v13.0.1
authorSANDHYA.JS <sandhya.j@tataelxsi.co.in>
Mon, 31 Oct 2022 14:41:50 +0000 (20:11 +0530)
committerSANDHYA.JS <sandhya.j@tataelxsi.co.in>
Wed, 2 Nov 2022 11:53:54 +0000 (17:23 +0530)
- If VNF is removed within an existing Network service, primitive action will not show the removed
  VNF in dropdown only the available VNF will be shown in UI

Change-Id: I60648093ba63c6b962380898300e75d69bcbf409
Signed-off-by: SANDHYA.JS <sandhya.j@tataelxsi.co.in>
src/app/instances/ns-instances/NSInstancesComponent.ts
src/app/instances/ns-primitive/NSPrimitiveComponent.html
src/app/instances/ns-primitive/NSPrimitiveComponent.ts
src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts
src/models/NSInstanceModel.ts

index 7b81d91..c44fa9b 100644 (file)
@@ -243,7 +243,8 @@ export class NSInstancesComponent implements OnInit {
                     vnfID: nsdInstanceData['vnfd-id'],
                     nsd: nsdInstanceData.nsd,
                     'nsd-id': nsdInstanceData['nsd-id'],
-                    vcaStatus: nsdInstanceData.vcaStatus
+                    vcaStatus: nsdInstanceData.vcaStatus,
+                    constituent: nsdInstanceData['constituent-vnfr-ref']
                 };
                 this.nsInstanceData.push(nsDataObj);
             });
index 2f3c155..34b8a0e 100644 (file)
@@ -33,7 +33,7 @@ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.i
         <div class="form-group row" *ngIf="primitiveType === 'VNF_Primitive' || primitiveType === 'VDU_Primitive' || primitiveType === 'KDU_Primitive'">
             <label class="col-sm-4 col-form-label">VNF Profile ID *</label>
             <div class="col-sm-3">
-                <ng-select (change)="indexChange($event, primitiveType)" [clearable]="false" placeholder="{{'SELECT' | translate}}" [items]="params.memberIndex[0]['vnf-profile']" bindLabel="id" bindValue="id" formControlName="member_vnf_index" id="member_vnf_index"
+                <ng-select (change)="indexChange($event, primitiveType)" [clearable]="false" placeholder="{{'SELECT' | translate}}" [items]="memberTypes" bindLabel="id" bindValue="id" formControlName="member_vnf_index" id="member_vnf_index"
                     [ngClass]="{ 'is-invalid': submitted && f.member_vnf_index.errors }"></ng-select>
             </div>
         </div>
index c8b7fed..bcce057 100644 (file)
@@ -32,6 +32,7 @@ import { RestService } from 'RestService';
 import { SharedService } from 'SharedService';
 import { isNullOrUndefined } from 'util';
 import { CONFIGPRIMITIVE, DF, VDUCONFIG, VDUPROFILE, VNFCONFIG, VNFD } from 'VNFDModel';
+import { VNFInstanceDetails } from 'VNFInstanceModel';
 
 /**
  * Creating component
@@ -88,6 +89,15 @@ export class NSPrimitiveComponent implements OnInit {
     /** Contains list of KDU primitive lists @public */
     public kduList: {}[];
 
+    /** Array holds MemberVNFIndex values @public */
+    public memberVnfIndex: {}[] = [];
+
+    /** Array holds VNFR Data filtered with nsr ID @public */
+    public nsIdFilteredData: {}[] = [];
+
+    /** Items for the memberVNFIndex data @public */
+    public memberTypes: {}[];
+
     /** FormBuilder instance added to the formBuilder @private */
     private formBuilder: FormBuilder;
 
@@ -151,6 +161,7 @@ export class NSPrimitiveComponent implements OnInit {
                 this.nsdId = event.identifier;
             }
         });
+        this.getMemberVnfIndex();
         this.initializeForm();
     }
 
@@ -234,6 +245,36 @@ export class NSPrimitiveComponent implements OnInit {
             this.restService.handleError(error, 'post');
         });
     }
+    /** Getting MemberVnfIndex using VNFDescriptor API @public */
+    public getMemberVnfIndex(): void {
+        const vnfInstanceData: {}[] = [];
+        this.restService.getResource(environment.VNFINSTANCES_URL).subscribe((vnfInstancesData: VNFInstanceDetails[]): void => {
+            vnfInstancesData.forEach((vnfData: VNFInstanceDetails): void => {
+                const vnfDataObj: {} =
+                {
+                    'vnf-ref': vnfData['vnfd-ref'],
+                    'vnf-id': vnfData._id,
+                    'member-index': vnfData['member-vnf-index-ref']
+                };
+                vnfInstanceData.push(vnfDataObj);
+            });
+            for (const id of this.params.id) {
+                this.nsIdFilteredData = vnfInstanceData.filter((vnfdData: {}[]): boolean => vnfdData['vnf-id'] === id);
+                this.nsIdFilteredData.forEach((resVNF: {}[]): void => {
+                    const assignMemberIndex: {} = {
+                        id: resVNF['member-index'],
+                        'vnf-ref': resVNF['vnf-ref']
+                    };
+                    this.memberVnfIndex.push(assignMemberIndex);
+                });
+            }
+            this.memberTypes = this.memberVnfIndex;
+            this.isLoadingResults = false;
+        }, (error: ERRORDATA): void => {
+            this.restService.handleError(error, 'get');
+            this.isLoadingResults = false;
+        });
+    }
     /** Primitive type change event @public */
     public primitiveTypeChange(data: PRIMITIVETYPES): void {
         this.primitiveList = [];
@@ -254,8 +295,8 @@ export class NSPrimitiveComponent implements OnInit {
     public indexChange(data: VNFPROFILE, getType?: string): void {
         this.getFormControl('vdu_id').setValue(null);
         this.getFormControl('kdu_name').setValue(null);
-        if (data['vnfd-id'] !== null) {
-            this.getVnfdInfo(data['vnfd-id'], getType);
+        if (data['vnf-ref'] !== null) {
+            this.getVnfdInfo(data['vnf-ref'], getType);
         } else {
             this.primitiveList = [];
             this.getFormControl('primitive').setValue(null);
@@ -320,60 +361,60 @@ export class NSPrimitiveComponent implements OnInit {
         const apiUrl: string = environment.VNFPACKAGES_URL + '?id=' + vnfdRef;
         this.isLoadingResults = true;
         this.restService.getResource(apiUrl).subscribe((vnfdInfo: VNFD[]): void => {
-                const vnfInstances: VNFD = vnfdInfo[0];
-                if (!isNullOrUndefined(vnfInstances.df)) {
-                    this.getFormControl('vdu_id').setValidators([]);
-                    this.getFormControl('kdu_name').setValidators([]);
-                    vnfInstances.df.forEach((df: DF): void => {
-                        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 => {
+            const vnfInstances: VNFD = vnfdInfo[0];
+            if (!isNullOrUndefined(vnfInstances.df)) {
+                this.getFormControl('vdu_id').setValidators([]);
+                this.getFormControl('kdu_name').setValidators([]);
+                vnfInstances.df.forEach((df: DF): void => {
+                    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 === vduProfile.id){
-                                                    const vduDataObj: VDUPROFILE = this.generateVDUData(element);
-                                                    this.vduList.push(vduDataObj);
+                                                if (element.id === kduData.name) {
+                                                    const kduDataObj: KDUPRIMITIVELEVEL = this.generateKDUData(kduData, element);
+                                                    this.kduList.push(kduDataObj);
                                                 }
                                             });
                                         });
                                     }
-                                    /** 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);
-                                                    }
-                                                });
-                                            });
-                                        }
-                                    }
                                 }
                             }
                         }
-                    });
-                }
-                this.isLoadingResults = false;
-            }, (error: ERRORDATA): void => {
-                this.isLoadingResults = false;
-                this.restService.handleError(error, 'get');
-            });
+                    }
+                });
+            }
+            this.isLoadingResults = false;
+        }, (error: ERRORDATA): void => {
+            this.isLoadingResults = false;
+            this.restService.handleError(error, 'get');
+        });
     }
     /** Get primivitive actions from NSD data */
     private getNSInfo(nsdRef: string): void {
index 751389b..5f9d5e3 100644 (file)
@@ -170,7 +170,8 @@ export class NSInstancesActionComponent {
     this.modalService.open(NSPrimitiveComponent, { backdrop: 'static' }).componentInstance.params = {
       memberIndex: this.value.memberIndex,
       nsConfig: this.value.nsConfig,
-      name: this.value.NsdName
+      name: this.value.NsdName,
+      id: this.value.constituent
     };
   }
 
index c10c5ce..66294cf 100644 (file)
@@ -267,6 +267,7 @@ export interface NSDInstanceData {
     nsd?: NSD;
     operationParams?: OPERATIONPARAMS;
     'nsd-id': string;
+    constituent: string[];
 }
 
 /** Interface for the operationparams */