From 89050ec38eb9b61cd3ce4283f0bc910c5e414624 Mon Sep 17 00:00:00 2001 From: Alexey Sandler Date: Thu, 30 Apr 2020 13:31:30 +0300 Subject: Add action and reducer for vfModule pause instantiation. Issue-ID: VID-821 Signed-off-by: Alexey Sandler Change-Id: Ia7735aa147752dd8bcd5cca820585324f14988ed Signed-off-by: Alexey Sandler --- .../app/shared/models/serviceInstanceActions.ts | 5 +- .../src/app/shared/models/vfModuleInstance.ts | 2 + .../storeUtil/utils/vfModule/vfModule.actions.ts | 16 +++++++ .../utils/vfModule/vfModule.reducers.spec.ts | 55 +++++++++++++++++++++- .../storeUtil/utils/vfModule/vfModule.reducers.ts | 25 ++++++++-- 5 files changed, 97 insertions(+), 6 deletions(-) (limited to 'vid-webpack-master/src/app/shared') diff --git a/vid-webpack-master/src/app/shared/models/serviceInstanceActions.ts b/vid-webpack-master/src/app/shared/models/serviceInstanceActions.ts index 0c8756d50..808c3df7a 100644 --- a/vid-webpack-master/src/app/shared/models/serviceInstanceActions.ts +++ b/vid-webpack-master/src/app/shared/models/serviceInstanceActions.ts @@ -8,7 +8,7 @@ export enum ServiceInstanceActions{ Resume = "Resume", Update_Delete = 'Update_Delete', None_Delete = 'None_Delete', - None_Upgrade = 'None_Upgrade' + None_Upgrade = 'None_Upgrade', } export enum ServiceAction { INSTANTIATE = 'INSTANTIATE', @@ -26,3 +26,6 @@ export enum JobStatus { COMPLETED_WITH_ERRORS = 'COMPLETED_WITH_ERRORS', CREATING = 'CREATING' } +export enum PauseStatus { + AFTER_COMPLETION = 'afterCompletion', +} diff --git a/vid-webpack-master/src/app/shared/models/vfModuleInstance.ts b/vid-webpack-master/src/app/shared/models/vfModuleInstance.ts index ed5a07212..7aedab42a 100644 --- a/vid-webpack-master/src/app/shared/models/vfModuleInstance.ts +++ b/vid-webpack-master/src/app/shared/models/vfModuleInstance.ts @@ -1,4 +1,5 @@ import {ChildNodeInstance} from "./nodeInstance"; +import {PauseStatus} from "./serviceInstanceActions"; export class VfModuleInstance extends ChildNodeInstance{ volumeGroupName: string; @@ -7,6 +8,7 @@ export class VfModuleInstance extends ChildNodeInstance{ statusMessage?: string; tenantId? :string; lcpCloudRegionId?: string; + pauseInstantiation?: PauseStatus; constructor() { super(); 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 40c1ea9e4..82e24091b 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 @@ -11,6 +11,7 @@ export enum VfModuleActions { UNDO_UPGRADE_VFMODULE_ACTION = "UNDO_UPGRADE_VFMODULE_ACTION", UPDATE_VFMODULE_FEILD = "UPDATE_VFMODULE_FEILD", DELETE_VFMODULE_FIELD = "DELETE_VFMODULE_FEILD", + PAUSE_ACTION_VFMODULE_INSTANCE = "PAUSE_ACTION_VFMODULE_INSTANCE", } @@ -89,6 +90,13 @@ export interface UndoDeleteActionVfModuleInstanceAction extends Action { vfModuleModelName: string; } +export interface PauseVFModuleInstanciationAction extends Action { + dynamicModelName: string; + vnfStoreKey : string; + serviceId: string; + vfModuleModelName : string; +} + export const removeVfModuleInstance: ActionCreator = (modelName, serviceModelId, vfName, vnfStoreKey, dynamicModelName) => ({ type: VfModuleActions.REMOVE_VNF_MODULE_INSTANCE, modelName: modelName, @@ -174,3 +182,11 @@ export const deleteVFModuleField: ActionCreator = (modelNam serviceId, deleteFieldName }); + +export const pauseActionVFModuleInstance: ActionCreator = (dynamicModelName, vnfStoreKey, serviceId, vfModuleModelName) => ({ + type: VfModuleActions.PAUSE_ACTION_VFMODULE_INSTANCE, + dynamicModelName, + vnfStoreKey, + serviceId, + vfModuleModelName +}); 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 7ec221a02..e73fe0c48 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 @@ -2,7 +2,7 @@ import { CreateVFModuleInstanceAction, DeleteActionVfModuleInstanceAction, DeleteVFModuleField, - DeleteVfModuleInstanceAction, + DeleteVfModuleInstanceAction, PauseVFModuleInstanciationAction, UndoDeleteActionVfModuleInstanceAction, UpdateVFModluePosition, UpdateVFModuleField, @@ -238,6 +238,19 @@ test('#UNDO_DELETE_ACTION_VF_MODULE_INSTANCE %s', (description, dynamicModelName expect(vfModule.action).toEqual(ServiceInstanceActions.None); }); + each([ + ['for the first vfModule', 'dynamicModelName1', 'afterCompletion'], + ['for the third vfModule', 'dynamicModelName3', 'afterCompletion'], + ['for the last vfModule', 'dynamicModelName5', 'afterCompletion'], + ]). +test('#PAUSE_ACTION_VF_MODULE_INSTANTIATION %s', (description: string, dynamicModelName:string, pauseInstantiation: string) => { + let vfModule = vfModuleReducer(getPausedRedux(), getPausedActionVfModule(dynamicModelName)) + .serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['vfModuleModelName'][dynamicModelName]; + + expect(vfModule).toBeDefined(); + expect(vfModule.pauseInstantiation).toEqual(pauseInstantiation); +}); + test('#UPGRADE_VFMODULE', () => { let vfModule = vfModuleReducer(getReduxState(), { @@ -362,4 +375,44 @@ function getDeleteRedux() { } } } + +function getPausedRedux() { + return { + serviceHierarchy: { + 'serviceModelId': {} + }, + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vnfStoreKey': { + vfModules: { + 'vfModuleModelName': { + 'dynamicModelName1': { + }, + 'dynamicModelName2': { + }, + 'dynamicModelName3': { + }, + 'dynamicModelName4': { + }, + 'dynamicModelName5': { + } + } + } + } + } + } + } + } +} + +function getPausedActionVfModule(dynamicModelName: string) { + return { + type: VfModuleActions.PAUSE_ACTION_VFMODULE_INSTANCE, + dynamicModelName: dynamicModelName, + vnfStoreKey: 'vnfStoreKey', + serviceId: 'serviceModelId', + vfModuleModelName: 'vfModuleModelName' + } +} }); 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 8efecf2ca..294536de6 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 @@ -1,15 +1,22 @@ import {Action} from "redux"; import * as _ from "lodash"; import { - CreateVFModuleInstanceAction, DeleteActionVfModuleInstanceAction, DeleteVFModuleField, - DeleteVfModuleInstanceAction, UndoDeleteActionVfModuleInstanceAction, UpdateVFModluePosition, UpdateVFModuleField, - UpdateVFModuleInstanceAction, UpgradeVfModuleInstanceAction, + CreateVFModuleInstanceAction, + DeleteActionVfModuleInstanceAction, + DeleteVFModuleField, + DeleteVfModuleInstanceAction, + PauseVFModuleInstanciationAction, + UndoDeleteActionVfModuleInstanceAction, + UpdateVFModluePosition, + UpdateVFModuleField, + UpdateVFModuleInstanceAction, + UpgradeVfModuleInstanceAction, VfModuleActions, } from "./vfModule.actions"; import {ServiceInstance} from "../../../models/serviceInstance"; import {VfModuleMap} from "../../../models/vfModulesMap"; import {ServiceState} from "../main.reducer"; -import {ServiceInstanceActions} from "../../../models/serviceInstanceActions"; +import {PauseStatus, ServiceInstanceActions} from "../../../models/serviceInstanceActions"; import {updateServiceValidationCounter} from "../reducersHelper"; @@ -69,6 +76,16 @@ export function vfModuleReducer(state: ServiceState , action: Action) : ServiceS } return Object.assign({}, state); } + case VfModuleActions.PAUSE_ACTION_VFMODULE_INSTANCE : { + const pauseVfModuleAction = (action); + let newState = _.cloneDeep(state); + + newState.serviceInstance[pauseVfModuleAction.serviceId].vnfs[pauseVfModuleAction.vnfStoreKey] + .vfModules[pauseVfModuleAction.vfModuleModelName][pauseVfModuleAction.dynamicModelName] + .pauseInstantiation = PauseStatus.AFTER_COMPLETION; + return newState; + } + case VfModuleActions.DELETE_ACTION_VF_MODULE_INSTANCE : { const deleteAction = (action); let newState = _.cloneDeep(state); -- cgit 1.2.3-korg