aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/storeUtil/utils/vnf
diff options
context:
space:
mode:
Diffstat (limited to 'vid-webpack-master/src/app/shared/storeUtil/utils/vnf')
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.actions.ts34
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.spec.ts48
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.ts57
3 files changed, 120 insertions, 19 deletions
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.actions.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.actions.ts
index 25179fe2e..6fb844e52 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.actions.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.actions.ts
@@ -8,7 +8,14 @@ export enum VNFActions {
REMOVE_VNF_INSTANCE = "REMOVE_VNF_INSTANCE",
DELETE_ACTION_VNF_INSTANCE = "DELETE_VNF_INSTANCE",
UNDO_DELETE_ACTION_VNF_INSTANCE = "UNDO_DELETE_VNF_INSTANCE",
- UPDATE_VNF_POSITION = "UPDATE_VNF_POISTION"
+ UPDATE_VNF_POSITION = "UPDATE_VNF_POISTION",
+ UPGRADE_VNF_ACTION = "UPGRADE_VNF_ACTION",
+ UNDO_UPGRADE_VNF_ACTION = "UNDO_UPGRADE_VNF_ACTION"
+}
+
+export enum VNFMethods{
+ UPGRADE = "upgrade",
+ UNDO_UPGRADE = "undoUpgrade"
}
@@ -32,6 +39,16 @@ export interface UpdateVnfInstanceAction extends Action {
vnfStoreKey?:string;
}
+export interface UpgradeVnfAction extends Action {
+ serviceUuid: string;
+ vnfStoreKey:string;
+}
+
+export interface UndoUpgradeVnfAction extends Action {
+ serviceUuid: string;
+ vnfStoreKey:string;
+}
+
export interface RemoveVnfInstanceAction extends Action {
vnfStoreKey: string;
serviceId?: string;
@@ -82,9 +99,14 @@ export const updateVnfPosition: ActionCreator<UpdateVnfPosition> = (node, instan
vnfStoreKey : vnfStoreKey
});
+export const upgradeVnf: ActionCreator<UpgradeVnfAction> = (vnfStoreKey, serviceUuid) => ({
+ type: VNFActions.UPGRADE_VNF_ACTION,
+ serviceUuid,
+ vnfStoreKey
+});
-
-
-
-
-
+export const undoUpgradeVnf: ActionCreator<UndoUpgradeVnfAction> = (vnfStoreKey, serviceUuid) => ({
+ type: VNFActions.UNDO_UPGRADE_VNF_ACTION,
+ serviceUuid,
+ vnfStoreKey
+});
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.spec.ts
index a5e37fcab..502777518 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.spec.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.spec.ts
@@ -2,7 +2,7 @@ import {VnfInstance} from "../../../models/vnfInstance";
import {
CreateVnfInstanceAction,
RemoveVnfInstanceAction,
- UpdateVnfPosition,
+ UpdateVnfPosition, UpgradeVnfAction,
VNFActions
} from "./vnf.actions";
import {vnfReducer} from "./vnf.reducers";
@@ -15,7 +15,7 @@ describe('vnfReducer', () => {
vnfInstance.isMissingData = false;
vnfInstance.instanceName = 'instanceName';
let vnfState = vnfReducer(<any>{
- serviceInstance : {
+ serviceInstance : {
'serviceModelId' : {
vnfs : {
"vnfStoreKey" : {
@@ -129,7 +129,49 @@ describe('vnfReducer', () => {
expect(vnfs['vnfStoreKey']).toBeUndefined();
});
-});
+ test('#UPGRADE_VNF_ACTION', () => {
+ const vnfStoreKey: string = 'vnfStoreKey';
+ const serviceModelId: string = 'serviceModelId';
+ let vnfs = vnfReducer(<any>{serviceInstance : {
+ [serviceModelId] : {
+ vnfs : {
+ [vnfStoreKey] : {
+ isMissingData : true,
+ action : 'None'
+ }
+ }
+ }
+ }},
+ <UpgradeVnfAction>{
+ type: VNFActions.UPGRADE_VNF_ACTION,
+ vnfStoreKey: vnfStoreKey,
+ serviceUuid: serviceModelId
+ }).serviceInstance[serviceModelId].vnfs[vnfStoreKey];
+ expect(vnfs).toBeDefined();
+ expect(vnfs[vnfStoreKey]).toBeUndefined();
+ });
+ test('#UNDO_UPGRADE_VNF_ACTION', () => {
+ const vnfStoreKey: string = 'vnfStoreKey';
+ const serviceModelId: string = 'serviceModelId';
+ let vnfs = vnfReducer(<any>{serviceInstance : {
+ [serviceModelId] : {
+ vnfs : {
+ [vnfStoreKey] : {
+ isMissingData : true,
+ action : 'None_Upgrade'
+ }
+ }
+ }
+ }},
+ <UpgradeVnfAction>{
+ type: VNFActions.UNDO_UPGRADE_VNF_ACTION,
+ vnfStoreKey: vnfStoreKey,
+ serviceUuid: serviceModelId
+ }).serviceInstance[serviceModelId].vnfs[vnfStoreKey];
+ expect(vnfs).toBeDefined();
+ expect(vnfs[vnfStoreKey]).toBeUndefined();
+ });
+});
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.ts
index 072634f2b..c5cd88aa7 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.ts
@@ -3,7 +3,7 @@ import {VnfInstance} from "../../../models/vnfInstance";
import {
CreateVnfInstanceAction,
RemoveVnfInstanceAction,
- UpdateVnfInstanceAction, UpdateVnfPosition,
+ UpdateVnfInstanceAction, UpdateVnfPosition, UpgradeVnfAction,
VNFActions
} from "./vnf.actions";
import * as _ from "lodash";
@@ -55,7 +55,6 @@ export function vnfReducer(state: ServiceState, action: Action): ServiceState {
case VNFActions.DELETE_ACTION_VNF_INSTANCE : {
return deleteFirstLevel(state, <ActionOnFirstLevel>action,true);
-
}
case VNFActions.UNDO_DELETE_ACTION_VNF_INSTANCE : {
@@ -77,13 +76,56 @@ export function vnfReducer(state: ServiceState, action: Action): ServiceState {
case VNFActions.UPDATE_VNF_POSITION : {
let newState = _.cloneDeep(state);
- newState.serviceInstance[(<UpdateVnfPosition>action).instanceId].vnfs[(<UpdateVnfPosition>action).vnfStoreKey].position = (<UpdateVnfPosition>action).node.position;
+ newState.serviceInstance[(<UpdateVnfPosition>action).instanceId]
+ .vnfs[(<UpdateVnfPosition>action).vnfStoreKey]
+ .position = (<UpdateVnfPosition>action).node.position;
return newState;
}
- }
-}
+ case VNFActions.UPGRADE_VNF_ACTION: {
+ let clonedState = _.cloneDeep(state);
+ const castingAction = <UpgradeVnfAction>action;
+ let oldAction = clonedState
+ .serviceInstance[castingAction.serviceUuid]
+ .vnfs[castingAction.vnfStoreKey].action;
+ if(!oldAction.includes("Upgrade")) {
+ clonedState.serviceInstance[castingAction.serviceUuid]
+ .vnfs[castingAction.vnfStoreKey]
+ .action = (`${oldAction}_Upgrade`) as ServiceInstanceActions;
+ }
+
+ if(_.isNil(clonedState.serviceInstance[castingAction.serviceUuid]
+ .vnfs[castingAction.vnfStoreKey].upgradedVFMSonsCounter)) {
+ clonedState.serviceInstance[castingAction.serviceUuid]
+ .vnfs[castingAction.vnfStoreKey].upgradedVFMSonsCounter = 1;
+ return clonedState;
+ }
+ clonedState.serviceInstance[castingAction.serviceUuid]
+ .vnfs[castingAction.vnfStoreKey].upgradedVFMSonsCounter++;
+ return clonedState;
+ }
+ case VNFActions.UNDO_UPGRADE_VNF_ACTION: {
+ let clonedState = _.cloneDeep(state);
+ const castingAction = <UpgradeVnfAction>action;
+ if(clonedState.serviceInstance[castingAction.serviceUuid]
+ .vnfs[castingAction.vnfStoreKey]
+ .action.includes("Upgrade")) {
+ clonedState
+ .serviceInstance[castingAction.serviceUuid]
+ .vnfs[castingAction.vnfStoreKey].upgradedVFMSonsCounter--;
+ if(clonedState.serviceInstance[castingAction.serviceUuid].vnfs[castingAction.vnfStoreKey]
+ .upgradedVFMSonsCounter === 0){
+ clonedState.serviceInstance[castingAction.serviceUuid]
+ .vnfs[castingAction.vnfStoreKey]
+ .action = ServiceInstanceActions.None;
+ }
+ }
+ return clonedState;
+ }
+
+ }
+}
const updateUniqueNames = (oldName: string, newName: string, serviceInstance: ServiceInstance): void => {
@@ -108,8 +150,3 @@ export const calculateNextUniqueModelName = (vnfModelName: string, serviceId: st
}
}
};
-
-
-
-
-