diff options
5 files changed, 163 insertions, 178 deletions
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json index 748b5f267..b1c9d9b9a 100644 --- a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json +++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json @@ -34,7 +34,6 @@ "b0732bed-3ddf-43cc-b193-7f18db84e476": { "action": "None_Upgrade", "retainAssignments" : false, - "retainVolumeGroups" : false, "sdncPreLoad" : true, "instanceName": "PST-VfMod-Replace-5-Vfmod", "instanceId": "b0732bed-3ddf-43cc-b193-7f18db84e476", @@ -60,7 +59,7 @@ "platformName": null, "trackById": "b0732bed-3ddf-43cc-b193-7f18db84e476", "isBase": true, - "volumeGroupName": null, + "volumeGroupName": "xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0_vol", "supplementaryFile": null, "supplementaryFile_hidden": null, "supplementaryFile_hidden_content" : null diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json index 45b89f730..91f80e9f1 100644 --- a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json +++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json @@ -34,7 +34,6 @@ ], "requestParameters": { "retainAssignments": false, - "rebuildVolumeGroups":true, "usePreload" : true, "userParams": [], "testApi": "VNF_API" diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.spec.ts index b62794ff8..8bdab11e3 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.spec.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.spec.ts @@ -19,6 +19,7 @@ import {FeatureFlagsService} from "../../../../../shared/services/featureFlag/fe import {VfModuleUpgradePopupService} from "../../../../../shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service"; import {instance, mock, when} from "ts-mockito"; import each from "jest-each"; +import {VfModule} from "../../../../../shared/models/vfModule"; class MockAppStore<T> { getState() { @@ -30,12 +31,6 @@ class MockAppStore<T> { } } -class MockFeatureFlagsService extends FeatureFlagsService{ - getAllFlags(): { [p: string]: boolean } { - return {}; - } -} - describe('VFModule Model Info', () => { let injector; let _dynamicInputsService : DynamicInputsService; @@ -133,8 +128,16 @@ describe('VFModule Model Info', () => { }); test('getModel should return Module model', () => { - let model = vfModuleModel.getModel('2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1',{}, getServiceHierarchy()); + let model = vfModuleModel.getModel('2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1',null, getServiceHierarchy()); expect(model.uuid).toEqual('25284168-24bb-4698-8cb4-3f509146eca5'); + expect(model.min).toBe(2); + expect(model.max).toBe(3); + expect(model.baseModule).toBeFalsy(); + expect(model.inputs).toEqual( + {"vnf_config_template_version": { + "type": "string" + }}); + expect(model.volumeGroupAllowed).toBeTruthy(); }); test('showNodeIcons should return false false if reachLimit of max', ()=>{ @@ -413,9 +416,35 @@ describe('VFModule Model Info', () => { 'modelInfo' : { modelVersionId : 'vfModuleId' } + }, + 'vnfModuleName_111_1': { + 'action': 'Create', + 'modelInfo' : { + modelVersionId : 'vfModuleId' + } } } } + }, + 'vnfName_1' :{ + 'action': 'Create', + 'originalName' : 'vnfName', + 'vfModules' : { + 'vfModuleName' : { + 'vnfModuleName_111': { + 'action': 'Create', + 'modelInfo' : { + modelVersionId : 'vfModuleId' + } + }, + 'vnfModuleName_111_1': { + 'action': 'Create', + 'modelInfo' : { + modelVersionId : 'vfModuleId' + } + } + } + } } } } @@ -438,6 +467,95 @@ describe('VFModule Model Info', () => { } }; let result = vfModuleModel.getNodeCount(<any>node , serviceId); + expect(result).toEqual(2); + }); + + + test('getNodeCount should return number of nodes : there is selectedVNF', ()=>{ + let serviceId : string = 'servicedId'; + jest.spyOn(MockNgRedux.getInstance(), 'getState').mockReturnValue({ + global : {}, + service : { + serviceHierarchy : { + 'servicedId' : { + 'vnfs' : { + 'vnfName' : { + 'properties' : { + 'max_instances' : 1 + } + } + }, + 'vfModules' : { + 'vfModuleName' : { + 'properties' : { + maxCountInstances : 2 + } + } + } + } + }, + serviceInstance : { + 'servicedId' : { + 'existingVNFCounterMap' : { + 'vnfId' : 1 + }, + 'vnfs' : { + 'vnfName' :{ + 'action': 'Create', + 'originalName' : 'vnfName', + 'vfModules' : { + 'vfModuleName' : { + 'vnfModuleName_111': { + 'action': 'Create', + 'modelInfo' : { + modelVersionId : 'vfModuleId' + } + }, + 'vnfModuleName_111_1': { + 'action': 'Create', + 'modelInfo' : { + modelVersionId : 'vfModuleId' + } + } + } + } + }, + 'vnfName_1' :{ + 'action': 'Create', + 'originalName' : 'vnfName', + 'vfModules' : { + 'vfModuleName' : { + 'vnfModuleName_111': { + 'action': 'Create', + 'modelInfo' : { + modelVersionId : 'vfModuleId' + } + } + } + } + } + } + } + } + } + }); + jest.spyOn(_sharedTreeService, 'getSelectedVNF').mockReturnValue('vnfName_1'); + + let node = { + data : { + id : 'vfModuleId', + name : 'vfModuleName', + 'action': 'Create', + }, + parent : { + data : { + id : 'vnfId', + name : 'vnfName_1', + 'action': 'Create', + } + } + }; + let result = vfModuleModel.getNodeCount(<any>node , serviceId); expect(result).toEqual(1); }); @@ -510,7 +628,7 @@ describe('VFModule Model Info', () => { expect(vfModuleModel.isVFModuleReachedLimit(node, serviceHierarchy, 'servicedId', currentNodeCount)).toEqual(expected); }); - function getVFModule(){ + function getVFModule(): Partial<VfModule>{ return { "uuid":"522159d5-d6e0-4c2a-aa44-5a542a12a830", "invariantUuid":"98a7c88b-b577-476a-90e4-e25a5871e02b", @@ -519,13 +637,10 @@ describe('VFModule Model Info', () => { "name":"VfVgeraldine..vflorence_vlc..module-1", "version":"2", "modelCustomizationName":"VfVgeraldine..vflorence_vlc..module-1", - "properties":{ - "minCountInstances":0, - "maxCountInstances":null, - "initialCount":0, - "vfModuleLabel":"vflorence_vlc", - "baseModule":false - }, + "min":0, + "max":null, + "initial":0, + "baseModule":false, "inputs":{}, "volumeGroupAllowed":false }; @@ -1151,7 +1266,7 @@ describe('VFModule Model Info', () => { "type": "VF", "modelCustomizationName": "2017-488_PASQUALE-vPE 0", "vfModules": { - "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1": { + "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1":{ "uuid": "25284168-24bb-4698-8cb4-3f509146eca5", "invariantUuid": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1", "customizationUuid": "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401", @@ -1160,82 +1275,15 @@ describe('VFModule Model Info', () => { "version": "6", "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1", "properties": { - "minCountInstances": 0, - "maxCountInstances": null, + "minCountInstances": 2, + "maxCountInstances": 3, "initialCount": 0, "vfModuleLabel": "PASQUALE_vRE_BV", "baseModule": false }, "inputs": { "vnf_config_template_version": { - "type": "string", - "description": "VPE Software Version", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "vnf_config_template_version" - }, - "fromInputName": "2017488_pasqualevpe0_vnf_config_template_version", - "constraints": null, - "required": true, - "default": "17.2" - }, - "bandwidth_units": { - "type": "string", - "description": "Units of bandwidth", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "bandwidth_units" - }, - "fromInputName": "pasqualevpe0_bandwidth_units", - "constraints": null, - "required": true, - "default": "Gbps" - }, - "bandwidth": { - "type": "string", - "description": "Requested VPE bandwidth", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "bandwidth" - }, - "fromInputName": "pasqualevpe0_bandwidth", - "constraints": null, - "required": true, - "default": "10" - }, - "AIC_CLLI": { - "type": "string", - "description": "AIC Site CLLI", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "AIC_CLLI" - }, - "fromInputName": "2017488_pasqualevpe0_AIC_CLLI", - "constraints": null, - "required": true, - "default": "ATLMY8GA" - }, - "vnf_instance_name": { - "type": "string", - "description": "The hostname assigned to the vpe.", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "vnf_instance_name" - }, - "fromInputName": "2017488_pasqualevpe0_vnf_instance_name", - "constraints": null, - "required": true, - "default": "mtnj309me6" + "type": "string" } }, "volumeGroupAllowed": true @@ -1402,82 +1450,15 @@ describe('VFModule Model Info', () => { "version": "6", "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1", "properties": { - "minCountInstances": 0, - "maxCountInstances": null, + "minCountInstances": 2, + "maxCountInstances": 3, "initialCount": 0, "vfModuleLabel": "PASQUALE_vRE_BV", "baseModule": false }, "inputs": { "vnf_config_template_version": { - "type": "string", - "description": "VPE Software Version", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "vnf_config_template_version" - }, - "fromInputName": "2017488_pasqualevpe0_vnf_config_template_version", - "constraints": null, - "required": true, - "default": "17.2" - }, - "bandwidth_units": { - "type": "string", - "description": "Units of bandwidth", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "bandwidth_units" - }, - "fromInputName": "pasqualevpe0_bandwidth_units", - "constraints": null, - "required": true, - "default": "Gbps" - }, - "bandwidth": { - "type": "string", - "description": "Requested VPE bandwidth", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "bandwidth" - }, - "fromInputName": "pasqualevpe0_bandwidth", - "constraints": null, - "required": true, - "default": "10" - }, - "AIC_CLLI": { - "type": "string", - "description": "AIC Site CLLI", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "AIC_CLLI" - }, - "fromInputName": "2017488_pasqualevpe0_AIC_CLLI", - "constraints": null, - "required": true, - "default": "ATLMY8GA" - }, - "vnf_instance_name": { - "type": "string", - "description": "The hostname assigned to the vpe.", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "vnf_instance_name" - }, - "fromInputName": "2017488_pasqualevpe0_vnf_instance_name", - "constraints": null, - "required": true, - "default": "mtnj309me6" + "type": "string" } }, "volumeGroupAllowed": true diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts index bb56b14d0..73f35279f 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts @@ -67,10 +67,10 @@ export class VFModuleModelInfo implements ILevelNodeInfo { * @param instance * @param serviceHierarchy - serviceHierarchy ************************************************************/ - getModel = (vfModuleModelId: string, instance, serviceHierarchy): any => { + getModel = (vfModuleModelId: string, instance, serviceHierarchy): Partial<VfModule> => { if (!_.isNil(serviceHierarchy)) { if (!_.isNil(serviceHierarchy[this.name]) && !_.isNil(serviceHierarchy[this.name][vfModuleModelId])) { - return serviceHierarchy[this.name][vfModuleModelId]; + return new VfModule(serviceHierarchy[this.name][vfModuleModelId], this._featureFlagsService.getAllFlags()); } } return {}; @@ -177,12 +177,16 @@ export class VFModuleModelInfo implements ILevelNodeInfo { * @param serviceModelId - current service id ************************************************************/ getNodeCount(node: ITreeNode, serviceModelId: string): number { + const vnfs = this._store.getState().service.serviceInstance[serviceModelId].vnfs; let count: number = 0; if (!_.isNil(this._store.getState().service.serviceInstance) && !_.isNil(this._store.getState().service.serviceInstance[serviceModelId])) { - const vnfs = this._store.getState().service.serviceInstance[serviceModelId].vnfs; - - for (let vnfKey in vnfs) { - count += this.countNumberOfVFModule(vnfs[vnfKey], node); + const selectedVNF: string = this._sharedTreeService.getSelectedVNF(); + if (selectedVNF) { + count += this.countNumberOfVFModule(vnfs[selectedVNF], node); + }else { + for (let vnfKey in vnfs) { + count += this.countNumberOfVFModule(vnfs[vnfKey], node); + } } return count; } @@ -206,11 +210,8 @@ export class VFModuleModelInfo implements ILevelNodeInfo { getCountVFModuleOfSelectedVNF(node: ITreeNode, vnfStoreKey: string, serviceModelId: string): number { let count: number = 0; if (!_.isNil(this._store.getState().service.serviceInstance) && !_.isNil(this._store.getState().service.serviceInstance[serviceModelId])) { - const vnfs = this._store.getState().service.serviceInstance[serviceModelId].vnfs; - - for (let vnfKey in vnfs) { - count += this.countNumberOfVFModule(vnfs[vnfKey], node); - } + const vnf = this._store.getState().service.serviceInstance[serviceModelId].vnfs[vnfStoreKey]; + count += this.countNumberOfVFModule(vnf, node); return count; } return count; @@ -238,7 +239,6 @@ export class VFModuleModelInfo implements ILevelNodeInfo { showVFModuleOnSelectedVNF(node: ITreeNode, selectedVNF: string, serviceModelId: string): AvailableNodeIcons { - if (!_.isNil(this._store.getState().service.serviceInstance[serviceModelId].vnfs[selectedVNF]) && node.parent.data.name === this._store.getState().service.serviceInstance[serviceModelId].vnfs[selectedVNF].originalName) { const existingVFModules = this.getCountVFModuleOfSelectedVNF(node, selectedVNF, serviceModelId); const reachedLimit = this.isVFModuleReachedLimit(node, this._store.getState().service.serviceHierarchy, serviceModelId, existingVFModules); @@ -414,12 +414,12 @@ export class VFModuleModelInfo implements ILevelNodeInfo { return (!_.isNil(instance) && !_.isNil(instance[deepDynamicName])) ? instance[deepDynamicName].position : null; } - getInfo(model, instance): ModelInformationItem[] { - const modelInformation = !_.isEmpty(model) && !_.isEmpty(model.properties) ? [ - ModelInformationItem.createInstance("Base module", model.properties.baseModule), - ModelInformationItem.createInstance("Min instances", !_.isNull(model.properties.minCountInstances) ? String(model.properties.minCountInstances) : null), + getInfo(model:Partial<VfModule>, instance): ModelInformationItem[] { + const modelInformation = !_.isEmpty(model) ? [ + ModelInformationItem.createInstance("Base module", model.baseModule), + ModelInformationItem.createInstance("Min instances", !_.isNull(model.min) ? String(model.min) : null), this._sharedTreeService.createMaximumToInstantiateModelInformationItem(model), - ModelInformationItem.createInstance("Initial instances count", !_.isNull(model.properties.initialCount) ? String(model.properties.initialCount) : null) + ModelInformationItem.createInstance("Initial instances count", !_.isNull(model.initial) ? String(model.initial) : null) ] : []; const instanceInfo = []; diff --git a/vid-webpack-master/src/app/shared/models/vfModule.ts b/vid-webpack-master/src/app/shared/models/vfModule.ts index dd730609f..a942a0d86 100644 --- a/vid-webpack-master/src/app/shared/models/vfModule.ts +++ b/vid-webpack-master/src/app/shared/models/vfModule.ts @@ -6,13 +6,15 @@ export interface Properties{ initialCount: number; maxCountInstances: number; minCountInstances: number; + baseModule: boolean; } export interface VFModuleResponseInterface extends NodeModelResponseInterface { customizationUuid: string; modelCustomizationName: string; volumeGroupAllowed : boolean; - properties: Properties + properties: Properties; + inputs: any; } export class VfModule extends NodeModel { @@ -22,6 +24,8 @@ export class VfModule extends NodeModel { customizationUuid: string; modelCustomizationName: string; volumeGroupAllowed : boolean; + baseModule : boolean; + inputs: any; constructor(vf?: VFModuleResponseInterface, flags?: { [key: string]: boolean }) { super(vf); @@ -29,12 +33,14 @@ export class VfModule extends NodeModel { this.customizationUuid = vf.customizationUuid; this.modelCustomizationName = vf.modelCustomizationName; this.volumeGroupAllowed = vf.volumeGroupAllowed || false; + this.inputs = vf.inputs; } if (vf && vf.properties) { this.min = vf.properties.minCountInstances; this.max = Utils.getMaxVfModule(vf.properties, flags); this.initial = vf.properties.initialCount; - this.rollbackOnFailure = true + this.rollbackOnFailure = true; + this.baseModule = vf.properties.baseModule; } } } |