From 7f8a96f92c76deeddb46726093c687d9f77a09eb Mon Sep 17 00:00:00 2001 From: "Kalkere Ramesh, Sharan" Date: Mon, 6 Jul 2020 09:43:45 -0400 Subject: added in fix to use old volume group name for added in fix to use old volume group name for volume group Issue-ID: SO-3020 Signed-off-by: Benjamin, Max (mb388a) Change-Id: Iaab124e8420d7b0a09b1f709b03b37b8a97425cf --- .../tasks/ConfigBuildingBlocksDataObject.java | 11 ++++- .../tasks/ReplaceInstanceRelatedInformation.java | 16 +++++++ .../workflow/tasks/WorkflowAction.java | 53 +++++++++++++--------- .../workflow/tasks/WorkflowActionTest.java | 2 +- 4 files changed, 59 insertions(+), 23 deletions(-) create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ReplaceInstanceRelatedInformation.java (limited to 'bpmn/so-bpmn-tasks/src') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java index e154375d3d..7f754e3f13 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java @@ -20,7 +20,6 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; -import java.util.List; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlockBase; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; @@ -38,6 +37,7 @@ public class ConfigBuildingBlocksDataObject extends BuildingBlockBase orchFlows; private Resource resourceKey; private ServiceInstancesRequest sIRequest; + private ReplaceInstanceRelatedInformation replaceInformation; public ServiceInstancesRequest getsIRequest() { return sIRequest; @@ -75,6 +75,15 @@ public class ConfigBuildingBlocksDataObject extends BuildingBlockBase configOrchFlows = new ArrayList<>(); @@ -243,12 +244,13 @@ public class WorkflowAction { .setApiVersion(apiVersion).setResourceId(resourceId) .setRequestAction(requestAction).setaLaCarte(true).setVnfType(vnfType) .setWorkflowResourceIds(workflowResourceIds) - .setRequestDetails(requestDetails).setExecution(execution)); + .setRequestDetails(requestDetails).setExecution(execution) + .setReplaceInformation(replaceInfo)); flowsToExecute.addAll(configBuildingBlocks); } else { ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId, requestAction, true, vnfType, workflowResourceIds, - requestDetails, false, null, null, false); + requestDetails, false, null, null, false, replaceInfo); flowsToExecute.add(ebb); } } @@ -271,7 +273,7 @@ public class WorkflowAction { for (OrchestrationFlow orchFlow : orchFlows) { ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId, requestAction, true, vnfType, workflowResourceIds, - requestDetails, false, null, null, false); + requestDetails, false, null, null, false, replaceInfo); flowsToExecute.add(ebb); } } @@ -537,10 +539,11 @@ public class WorkflowAction { + ": VnfcName does not exist or is null while there is a configuration for the vfModule", new Exception("Vnfc and Configuration do not match")); } - ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(), - dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(), - dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(), - dataObj.getWorkflowResourceIds(), dataObj.getRequestDetails(), false, null, vnfcName, true); + ExecuteBuildingBlock ebb = + buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(), dataObj.getResourceKey(), + dataObj.getApiVersion(), dataObj.getResourceId(), dataObj.getRequestAction(), + dataObj.isaLaCarte(), dataObj.getVnfType(), dataObj.getWorkflowResourceIds(), + dataObj.getRequestDetails(), false, null, vnfcName, true, null); flowsToExecuteConfigs.add(ebb); } } @@ -565,14 +568,16 @@ public class WorkflowAction { && dataObj.getRequestDetails().getRequestParameters().getRebuildVolumeGroups() != null) { rebuildVolumeGroups = dataObj.getRequestDetails().getRequestParameters().getRebuildVolumeGroups(); } - + String volumeGroupName = ""; Optional volumeGroupFromVfModule = bbInputSetupUtils.getRelatedVolumeGroupFromVfModule(vnfId, vfModuleId); if (volumeGroupFromVfModule.isPresent()) { String volumeGroupId = volumeGroupFromVfModule.get().getVolumeGroupId(); + volumeGroupName = volumeGroupFromVfModule.get().getVolumeGroupName(); logger.debug("Volume group id of the existing volume group is: " + volumeGroupId); volumeGroupExisted = true; dataObj.getWorkflowResourceIds().setVolumeGroupId(volumeGroupId); + dataObj.getReplaceInformation().setOldVolumeGroupName(volumeGroupName); } List orchFlows = dataObj.getOrchFlows(); @@ -585,6 +590,7 @@ public class WorkflowAction { if (!volumeGroupExisted) { String newVolumeGroupId = UUID.randomUUID().toString(); dataObj.getWorkflowResourceIds().setVolumeGroupId(newVolumeGroupId); + dataObj.getReplaceInformation().setOldVolumeGroupName(volumeGroupName); logger.debug("newVolumeGroupId: " + newVolumeGroupId); } } @@ -1386,7 +1392,7 @@ public class WorkflowAction { resourceList.stream().filter(resource -> resource.getResourceType().equals(workflowType)) .forEach(resource -> flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails, - isVirtualLink, resource.getVirtualLinkKey(), null, isConfiguration))); + isVirtualLink, resource.getVirtualLinkKey(), null, isConfiguration, null))); } protected List buildExecuteBuildingBlockList(List orchFlows, @@ -1433,7 +1439,7 @@ public class WorkflowAction { for (Resource resource : vfModuleResourcesSorted) { flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, null, - false)); + false, null)); } } else if (orchFlow.getFlowName().contains(VOLUMEGROUP)) { if (requestAction.equalsIgnoreCase(REPLACEINSTANCE) @@ -1453,8 +1459,9 @@ public class WorkflowAction { requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, true); } else { - flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId, - requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, null, false)); + flowsToExecute + .add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId, requestAction, + false, vnfType, workflowResourceIds, requestDetails, false, null, null, false, null)); } } return flowsToExecute; @@ -1463,7 +1470,8 @@ public class WorkflowAction { protected ExecuteBuildingBlock buildExecuteBuildingBlock(OrchestrationFlow orchFlow, String requestId, Resource resource, String apiVersion, String resourceId, String requestAction, boolean aLaCarte, String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, - boolean isVirtualLink, String virtualLinkKey, String vnfcName, boolean isConfiguration) { + boolean isVirtualLink, String virtualLinkKey, String vnfcName, boolean isConfiguration, + ReplaceInstanceRelatedInformation replaceInfo) { BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName(orchFlow.getFlowName()).setMsoId(UUID.randomUUID().toString()) @@ -1471,7 +1479,10 @@ public class WorkflowAction { .setKey(Optional.ofNullable(resource).map(Resource::getResourceId).orElse("")); Optional.ofNullable(orchFlow.getBpmnAction()).ifPresent(buildingBlock::setBpmnAction); Optional.ofNullable(orchFlow.getBpmnScope()).ifPresent(buildingBlock::setBpmnScope); - + String oldVolumeGroupName = ""; + if (replaceInfo != null) { + oldVolumeGroupName = replaceInfo.getOldVolumeGroupName(); + } if (resource != null && (orchFlow.getFlowName().contains(VOLUMEGROUP) && (requestAction.equalsIgnoreCase(REPLACEINSTANCE) || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)))) { @@ -1482,7 +1493,7 @@ public class WorkflowAction { ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setApiVersion(apiVersion) .setaLaCarte(aLaCarte).setRequestAction(requestAction).setResourceId(resourceId).setVnfType(vnfType) .setWorkflowResourceIds(workflowResourceIds).setRequestId(requestId).setBuildingBlock(buildingBlock) - .setRequestDetails(requestDetails); + .setRequestDetails(requestDetails).setOldVolumeGroupName(oldVolumeGroupName); if (resource != null && (isConfiguration || resource.getResourceType().equals(WorkflowType.CONFIGURATION))) { ConfigurationResourceKeys configurationResourceKeys = getConfigurationResourceKeys(resource, vnfcName); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index cf8d98e86e..8f104566a4 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -3122,7 +3122,7 @@ public class WorkflowActionTest extends BaseTaskTest { ExecuteBuildingBlock result = null; try { result = workflowAction.buildExecuteBuildingBlock(new OrchestrationFlow(), null, null, null, null, null, - false, null, null, null, false, null, null, true); + false, null, null, null, false, null, null, true, null); } catch (NullPointerException e) { fail("NullPointerException should not be thrown when 'resource' is null"); } -- cgit 1.2.3-korg