diff options
Diffstat (limited to 'vid-webpack-master/src/app/shared/storeUtil/utils/vfModule')
3 files changed, 144 insertions, 14 deletions
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts index a3f0f4009..59e5ee1fa 100644 --- a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts +++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts @@ -6,7 +6,9 @@ export enum VfModuleActions { UPDATE_VF_MODULE = 'UPDATE_VF_MODULE', DELETE_ACTION_VF_MODULE_INSTANCE = "DELETE_ACTION_VF_MODULE_INSTANCE", UNDO_DELETE_ACTION_VF_MODULE_INSTANCE = "UNDO_DELETE_ACTION_VF_MODULE_INSTANCE", - UPDATE_VFMODULE_POSITION = "UPDATE_VFMODULE_POSITION" + UPDATE_VFMODULE_POSITION = "UPDATE_VFMODULE_POSITION", + UPGRADE_VFMODULE = "UPGRADE_VFMODULE", + UNDO_UPGRADE_VFMODULE_ACTION = "UNDO_UPGRADE_VFMODULE_ACTION", } @@ -47,6 +49,19 @@ export interface DeleteActionVfModuleInstanceAction extends Action { serviceId?: string; } +export interface UpgradeVfModuleInstanceAction extends Action { + modelName : string; + vnfStoreKey : string; + serviceId?: string; + dynamicModelName: string; +} +export interface UndoUpgradeVfModuleInstanceAction extends Action { + modelName : string; + vnfStoreKey : string; + serviceId?: string; + dynamicModelName: string; +} + export interface UndoDeleteActionVfModuleInstanceAction extends Action { dynamicModelName: string; vnfStoreKey : string; @@ -95,7 +110,6 @@ export const undoDeleteVfModuleInstance: ActionCreator<UndoDeleteActionVfModuleI serviceId: serviceId }); - export const updateVFModulePosition: ActionCreator<UpdateVFModluePosition> = (node, instanceId, vnfStoreKey) => ({ type: VfModuleActions.UPDATE_VFMODULE_POSITION, node: node, @@ -103,3 +117,18 @@ export const updateVFModulePosition: ActionCreator<UpdateVFModluePosition> = (no vnfStoreKey : vnfStoreKey }); +export const upgradeVFModule: ActionCreator<UpgradeVfModuleInstanceAction> = (modelName, vnfStoreKey, serviceId, dynamicModelName) => ({ + type: VfModuleActions.UPGRADE_VFMODULE, + dynamicModelName, + modelName, + vnfStoreKey, + serviceId +}); + +export const undoUgradeVFModule: ActionCreator<UndoUpgradeVfModuleInstanceAction> = (modelName, vnfStoreKey, serviceId, dynamicModelName) => ({ + type: VfModuleActions.UNDO_UPGRADE_VFMODULE_ACTION, + dynamicModelName, + modelName, + vnfStoreKey, + serviceId +}); diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts index de6d2142c..ee0edb0a7 100644 --- a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts +++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts @@ -1,7 +1,10 @@ import { CreateVFModuleInstanceAction, DeleteActionVfModuleInstanceAction, - DeleteVfModuleInstanceAction, UndoDeleteActionVfModuleInstanceAction, UpdateVFModluePosition, + DeleteVfModuleInstanceAction, + UndoDeleteActionVfModuleInstanceAction, + UpdateVFModluePosition, + UpgradeVfModuleInstanceAction, VfModuleActions } from "./vfModule.actions"; import {vfModuleReducer} from "./vfModule.reducers"; @@ -102,10 +105,10 @@ describe('vfModuleReducer', () => { vfModuleInstance.isMissingData = false; vfModuleInstance.volumeGroupName = 'volumeGroupName'; let vfModule = vfModuleReducer(<any>{ - serviceHierarchy : { - 'serviceModelId' : {} - }, - serviceInstance : { + serviceHierarchy : { + 'serviceModelId' : {} + }, + serviceInstance : { 'serviceModelId' : { vnfs : { 'vfName' : { @@ -169,16 +172,16 @@ describe('vfModuleReducer', () => { }).serviceInstance['serviceModelId'].vnfs['vfName'].vfModules["modelName"]["dynamicModelName"]; - expect(vfModule.position).toEqual(1); + expect(vfModule.position).toEqual(1); }); test('#DELETE_ACTION_VF_MODULE_INSTANCE', ()=>{ let vfModule = vfModuleReducer(<any>{ - serviceHierarchy : { - 'serviceModelId' : {} - }, - serviceInstance : { + serviceHierarchy : { + 'serviceModelId' : {} + }, + serviceInstance : { 'serviceModelId' : { vnfs : { 'vnfStoreKey' : { @@ -242,7 +245,70 @@ describe('vfModuleReducer', () => { expect(vfModule.action).toEqual(ServiceInstanceActions.None); }); -}); + test('#UPGRADE_VFMODULE', ()=>{ + let vfModule = vfModuleReducer(<any>{ + serviceHierarchy : { + 'serviceModelId' : {} + }, + serviceInstance : { + 'serviceModelId' : { + vnfs : { + 'vnfStoreKey' : { + vfModules : { + 'modelName' : { + 'dynamicModelName1': { + isMissingData : true, + action : 'None' + }, + 'dynamicModelName2': {}, + } + } + } + } + } + }}, + <UpgradeVfModuleInstanceAction>{ + type: VfModuleActions.UPGRADE_VFMODULE, + dynamicModelName: 'dynamicModelName1', + vnfStoreKey : 'vnfStoreKey', + serviceId: 'serviceModelId', + modelName: 'modelName' + }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + + expect(vfModule.action).toEqual(ServiceInstanceActions.None_Upgrade); + }); + test('#UNDO_UPGRADE_VFMODULE', ()=>{ + let vfModule = vfModuleReducer(<any>{ + serviceHierarchy : { + 'serviceModelId' : {} + }, + serviceInstance : { + 'serviceModelId' : { + vnfs : { + 'vnfStoreKey' : { + vfModules : { + 'modelName' : { + 'dynamicModelName1': { + isMissingData : true, + action : 'None_Upgrade' + }, + 'dynamicModelName2': {}, + } + } + } + } + } + }}, + <UpgradeVfModuleInstanceAction>{ + type: VfModuleActions.UNDO_UPGRADE_VFMODULE_ACTION, + dynamicModelName: 'dynamicModelName1', + vnfStoreKey : 'vnfStoreKey', + serviceId: 'serviceModelId', + modelName: 'modelName' + }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + expect(vfModule.action).toEqual(ServiceInstanceActions.None); + }); +}); diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts index 05319c0fb..a7aadba41 100644 --- a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts +++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts @@ -3,7 +3,7 @@ import * as _ from "lodash"; import { CreateVFModuleInstanceAction, DeleteActionVfModuleInstanceAction, DeleteVfModuleInstanceAction, UndoDeleteActionVfModuleInstanceAction, UpdateVFModluePosition, - UpdateVFModuleInstanceAction, + UpdateVFModuleInstanceAction, UpgradeVfModuleInstanceAction, VfModuleActions } from "./vfModule.actions"; import {ServiceInstance} from "../../../models/serviceInstance"; @@ -26,6 +26,7 @@ export function vfModuleReducer(state: ServiceState , action: Action) : ServiceS let vfModulesMap = newState.serviceInstance[serviceUuid].vnfs[vnfStoreKey].vfModules[vfModuleId] || new VfModuleMap(); let randomId = generateId(); + vfInstance.action = ServiceInstanceActions.Create; vfModulesMap[vfModuleId + randomId] = vfInstance; updateUniqueNames(null, vfInstance.instanceName, newState.serviceInstance[serviceUuid]); updateUniqueNames(null, vfInstance.volumeGroupName, newState.serviceInstance[serviceUuid]); @@ -110,6 +111,40 @@ export function vfModuleReducer(state: ServiceState , action: Action) : ServiceS newState.serviceInstance[serviceUuid].vnfs[updateVFModluePosition.vnfStoreKey].vfModules[modelName][dynamicModelName].position = updateVFModluePosition.node.position; return newState; } + + case VfModuleActions.UPGRADE_VFMODULE : { + let clonedState = _.cloneDeep(state); + const upgradeAction = (<UpgradeVfModuleInstanceAction>action); + let oldAction = clonedState + .serviceInstance[upgradeAction.serviceId] + .vnfs[upgradeAction.vnfStoreKey] + .vfModules[upgradeAction.modelName][upgradeAction.dynamicModelName] + .action; + if(!_.isNil(oldAction) && oldAction.includes("Upgrade")) { + return clonedState; + } + clonedState.serviceInstance[upgradeAction.serviceId] + .vnfs[upgradeAction.vnfStoreKey] + .vfModules[upgradeAction.modelName][upgradeAction.dynamicModelName] + .action = (`${oldAction}_Upgrade`) as ServiceInstanceActions; + return clonedState; + } + case VfModuleActions.UNDO_UPGRADE_VFMODULE_ACTION : { + let clonedState = _.cloneDeep(state); + const upgradeAction = (<UpgradeVfModuleInstanceAction>action); + let oldAction = clonedState + .serviceInstance[upgradeAction.serviceId] + .vnfs[upgradeAction.vnfStoreKey] + .vfModules[upgradeAction.modelName][upgradeAction.dynamicModelName] + .action; + if(!_.isNil(oldAction) && oldAction.includes("Upgrade")) { + clonedState.serviceInstance[upgradeAction.serviceId] + .vnfs[upgradeAction.vnfStoreKey] + .vfModules[upgradeAction.modelName][upgradeAction.dynamicModelName] + .action = ServiceInstanceActions.None; + } + return clonedState; + } } } |