aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src
diff options
context:
space:
mode:
authorKuleshov, Elena <evn@att.com>2019-12-18 09:24:33 -0500
committerBenjamin, Max (mb388a) <mb388a@att.com>2019-12-18 09:24:34 -0500
commitc0fbd45596e038ecceb77422c4cae840ad114efa (patch)
treec9b76ff27774b5a87e6539c3995fd5778907f965 /bpmn/so-bpmn-tasks/src
parent145eb372a14a2dd25f75033acd37e269c33caf95 (diff)
Support for volume groups on replace VF Module.
Support for volume groups on replace VF Module. [MSO-8375 R2002} Add full JUnit coverage for replaceVFModule scenarios, add replace changes to general macro data. Fix a JUnit to pass correct parameters to a method. Add back setting volume group id for new volume group on replace action. Issue-ID: SO-2577 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: I73289da21e0c7de7451b63e99e184692e800aaf0
Diffstat (limited to 'bpmn/so-bpmn-tasks/src')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java106
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java366
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleReplaceRebuildVolumeGroups.json66
4 files changed, 533 insertions, 6 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
index bd60fbe38c..b9f73f3f0e 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
@@ -372,6 +372,7 @@ public class AAICreateTasks {
logger.info("VolumeGroup not found. Skipping Connect between VfModule and VolumeGroup");
}
if (volumeGroup != null) {
+ logger.debug("Connecting VfModule to VolumGroup");
aaiVfModuleResources.connectVfModuleToVolumeGroup(vnf, vfModule, volumeGroup,
execution.getGeneralBuildingBlock().getCloudRegion());
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
index 5d36c1c4f5..332ba78277 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
@@ -111,6 +111,8 @@ public class WorkflowAction {
private static final String CONFIGURATION = "Configuration";
private static final String ASSIGNINSTANCE = "assignInstance";
private static final String CREATEINSTANCE = "createInstance";
+ private static final String REPLACEINSTANCE = "replaceInstance";
+ private static final String REPLACEINSTANCERETAINASSIGNMENTS = "replaceInstanceRetainAssignments";
private static final String USERPARAMSERVICE = "service";
private static final String SUPPORTEDTYPES =
"vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances|instanceGroups";
@@ -130,6 +132,8 @@ public class WorkflowAction {
private static final String NAME_EXISTS_WITH_DIFF_PARENT = "(%s) id (%s) and different parent relationship";
private static final String CREATENETWORKBB = "CreateNetworkBB";
private static final String ACTIVATENETWORKBB = "ActivateNetworkBB";
+ private static final String VOLUMEGROUP_DELETE_PATTERN = "(Un|De)(.*)Volume(.*)";
+ private static final String VOLUMEGROUP_CREATE_PATTERN = "(A|C)(.*)Volume(.*)";
@Autowired
protected BBInputSetup bbInputSetup;
@@ -262,6 +266,18 @@ public class WorkflowAction {
}
orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION))
.collect(Collectors.toList());
+
+ if ((requestAction.equalsIgnoreCase(REPLACEINSTANCE)
+ || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS))
+ && resourceType.equals(WorkflowType.VFMODULE)) {
+ logger.debug("Build a BB list for replacing BB modules");
+ orchFlows = getVfModuleReplaceBuildingBlocks(
+ new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows)
+ .setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion)
+ .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte)
+ .setVnfType(vnfType).setWorkflowResourceIds(workflowResourceIds)
+ .setRequestDetails(requestDetails).setExecution(execution));
+ }
for (OrchestrationFlow orchFlow : orchFlows) {
ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey,
apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds,
@@ -272,7 +288,8 @@ public class WorkflowAction {
boolean foundRelated = false;
boolean containsService = false;
if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(ASSIGNINSTANCE)) {
- // SERVICE-MACRO-ASSIGN will always get user params with a
+ // SERVICE-MACRO-ASSIGN will always get user params with
+ // a
// service.
if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
List<Map<String, Object>> userParams =
@@ -290,7 +307,8 @@ public class WorkflowAction {
"Service-Macro-Assign request details must contain user params with a service");
}
} else if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(CREATEINSTANCE)) {
- // SERVICE-MACRO-CREATE will get user params with a service,
+ // SERVICE-MACRO-CREATE will get user params with a
+ // service,
// a service with a network, a service with a
// networkcollection, OR an empty service.
// If user params is just a service or null and macro
@@ -319,7 +337,8 @@ public class WorkflowAction {
|| requestAction.equalsIgnoreCase("activate" + FABRIC_CONFIGURATION))) {
// SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and
// SERVICE-MACRO-DELETE
- // Will never get user params with service, macro will have
+ // Will never get user params with service, macro will
+ // have
// to query the SI in AAI to find related instances.
traverseAAIService(execution, resourceCounter, resourceId, aaiResourceIds);
} else if (resourceType == WorkflowType.SERVICE
@@ -357,7 +376,8 @@ public class WorkflowAction {
logger.info("Sorting for Vlan Tagging");
flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction);
}
- // By default, enable homing at VNF level for CREATEINSTANCE and ASSIGNINSTANCE
+ // By default, enable homing at VNF level for CREATEINSTANCE
+ // and ASSIGNINSTANCE
if (resourceType == WorkflowType.SERVICE
&& (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE))
&& !resourceCounter.stream().filter(x -> WorkflowType.VNF.equals(x.getResourceType()))
@@ -374,7 +394,8 @@ public class WorkflowAction {
}
}
}
- // If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is specified,
+ // If the user set "Homing_Solution" to "none", disable homing, else
+ // if "Homing_Solution" is specified,
// enable it.
if (sIRequest.getRequestDetails().getRequestParameters() != null
&& sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
@@ -545,6 +566,68 @@ public class WorkflowAction {
return flowsToExecuteConfigs;
}
+ protected List<OrchestrationFlow> getVfModuleReplaceBuildingBlocks(ConfigBuildingBlocksDataObject dataObj)
+ throws Exception {
+
+ List<ExecuteBuildingBlock> flowsToExecuteConfigs = new ArrayList<>();
+
+ String vnfId = dataObj.getWorkflowResourceIds().getVnfId();
+ String vfModuleId = dataObj.getWorkflowResourceIds().getVfModuleId();
+
+ logger.debug("BUILDING REPLACE LIST");
+
+ boolean volumeGroupExisted = false;
+ boolean volumeGroupWillExist = false;
+ boolean keepVolumeGroup = false;
+
+ boolean rebuildVolumeGroups = false;
+ if (dataObj.getRequestDetails().getRequestParameters() != null
+ && dataObj.getRequestDetails().getRequestParameters().getRebuildVolumeGroups() != null) {
+ rebuildVolumeGroups =
+ dataObj.getRequestDetails().getRequestParameters().getRebuildVolumeGroups().booleanValue();
+ }
+
+ Optional<VolumeGroup> volumeGroupFromVfModule =
+ bbInputSetupUtils.getRelatedVolumeGroupFromVfModule(vnfId, vfModuleId);
+ if (volumeGroupFromVfModule.isPresent()) {
+ String volumeGroupId = volumeGroupFromVfModule.get().getVolumeGroupId();
+ logger.debug("Volume group id of the existing volume group is: " + volumeGroupId);
+ volumeGroupExisted = true;
+ dataObj.getWorkflowResourceIds().setVolumeGroupId(volumeGroupId);
+ }
+
+ List<OrchestrationFlow> orchFlows = dataObj.getOrchFlows();
+ VfModuleCustomization vfModuleCustomization = catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(
+ dataObj.getRequestDetails().getModelInfo().getModelCustomizationUuid());
+ if (vfModuleCustomization != null && vfModuleCustomization.getVfModule() != null
+ && vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null
+ && vfModuleCustomization.getVolumeHeatEnv() != null) {
+ volumeGroupWillExist = true;
+ if (!volumeGroupExisted) {
+ String newVolumeGroupId = UUID.randomUUID().toString();
+ dataObj.getWorkflowResourceIds().setVolumeGroupId(newVolumeGroupId);
+ logger.debug("newVolumeGroupId: " + newVolumeGroupId);
+ }
+ }
+
+ if (volumeGroupExisted && volumeGroupWillExist && !rebuildVolumeGroups) {
+ keepVolumeGroup = true;
+ }
+
+ if (!volumeGroupExisted || keepVolumeGroup) {
+ logger.debug("Filtering out deletion of volume groups");
+ orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().matches(VOLUMEGROUP_DELETE_PATTERN))
+ .collect(Collectors.toList());
+ }
+ if (!volumeGroupWillExist || keepVolumeGroup) {
+ logger.debug("Filtering out creation of volume groups");
+ orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().matches(VOLUMEGROUP_CREATE_PATTERN))
+ .collect(Collectors.toList());
+ }
+
+ return orchFlows;
+ }
+
protected String getVnfcNameForConfiguration(org.onap.aai.domain.yang.Configuration configuration) {
AAIResultWrapper wrapper = new AAIResultWrapper(configuration);
Optional<Relationships> relationshipsOp = wrapper.getRelationships();
@@ -1366,6 +1449,11 @@ public class WorkflowAction {
requestDetails, false, null, false));
}
} else if (orchFlow.getFlowName().contains(VOLUMEGROUP)) {
+ if (requestAction.equalsIgnoreCase(REPLACEINSTANCE)
+ || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)) {
+ logger.debug("Replacing workflow resource id by volume group id");
+ resourceId = workflowResourceIds.getVolumeGroupId();
+ }
for (int i = 0; i < resourceCounter.stream()
.filter(x -> WorkflowType.VOLUMEGROUP == x.getResourceType()).collect(Collectors.toList())
.size(); i++) {
@@ -1421,6 +1509,13 @@ public class WorkflowAction {
executeBuildingBlock.setApiVersion(apiVersion);
executeBuildingBlock.setaLaCarte(aLaCarte);
executeBuildingBlock.setRequestAction(requestAction);
+
+ if (resource != null
+ && (orchFlow.getFlowName().contains(VOLUMEGROUP) && (requestAction.equalsIgnoreCase(REPLACEINSTANCE)
+ || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)))) {
+ logger.debug("Setting resourceId to volume group id for volume group flow on replace");
+ resourceId = workflowResourceIds.getVolumeGroupId();
+ }
executeBuildingBlock.setResourceId(resourceId);
executeBuildingBlock.setVnfType(vnfType);
executeBuildingBlock.setWorkflowResourceIds(workflowResourceIds);
@@ -1681,4 +1776,3 @@ public class WorkflowAction {
return generatedResourceId;
}
}
-
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 b4b25dcc31..ed3ee0a3a1 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
@@ -125,6 +125,16 @@ public class WorkflowActionTest extends BaseTaskTest {
private String RESOURCE_PATH = "src/test/resources/__files/";
+ private List<OrchestrationFlow> replaceVfModuleOrchFlows =
+ createFlowList("DeactivateVfModuleBB", "DeleteVfModuleATTBB", "DeactivateVolumeGroupBB",
+ "DeleteVolumeGroupBB", "UnassignVFModuleBB", "UnassignVolumeGroupBB", "AssignVolumeGroupBB",
+ "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "CreateVolumeGroupBB",
+ "ActivateVolumeGroupBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
+ private List<OrchestrationFlow> replaceRetainAssignmentsVfModuleOrchFlows = createFlowList("DeactivateVfModuleBB",
+ "DeleteVfModuleATTBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "UnassignVolumeGroupBB",
+ "AssignVolumeGroupBB", "ChangeModelVfModuleBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB",
+ "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
+
@Before
public void before() throws Exception {
execution = new DelegateExecutionFake();
@@ -1093,6 +1103,362 @@ public class WorkflowActionTest extends BaseTaskTest {
}
@Test
+ public void selectExecutionListALaCarteVfModuleNoVolumeGroupReplaceTest() throws Exception {
+ String gAction = "replaceInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ northBoundRequest.setOrchestrationFlowList(replaceVfModuleOrchFlows);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+
+ assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "UnassignVFModuleBB",
+ "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB",
+ "ChangeModelServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleNoVolumeGroupReplaceRetainAssignmentsTest() throws Exception {
+ String gAction = "replaceInstanceRetainAssignments";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ northBoundRequest.setOrchestrationFlowList(replaceRetainAssignmentsVfModuleOrchFlows);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+
+ assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "ChangeModelVfModuleBB",
+ "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleVolumeGroupToNoVolumeGroupReplaceTest() throws Exception {
+ String gAction = "replaceInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234");
+ execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d");
+ execution.setVariable("vfModuleId", "1234");
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ doReturn(Optional.of(volumeGroup)).when(bbSetupUtils)
+ .getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234");
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ northBoundRequest.setOrchestrationFlowList(replaceVfModuleOrchFlows);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+
+ assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "DeactivateVolumeGroupBB",
+ "DeleteVolumeGroupBB", "UnassignVFModuleBB", "UnassignVolumeGroupBB", "AssignVfModuleBB",
+ "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleVolumeGroupToNoVolumeGroupReplaceRetainAssignmentsTest()
+ throws Exception {
+ String gAction = "replaceInstanceRetainAssignments";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234");
+ execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d");
+ execution.setVariable("vfModuleId", "1234");
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ doReturn(Optional.of(volumeGroup)).when(bbSetupUtils)
+ .getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ northBoundRequest.setOrchestrationFlowList(replaceRetainAssignmentsVfModuleOrchFlows);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+
+ assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "DeactivateVolumeGroupBB",
+ "DeleteVolumeGroupBB", "UnassignVolumeGroupBB", "ChangeModelVfModuleBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleKeepVolumeGroupReplaceTest() throws Exception {
+ String gAction = "replaceInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234");
+ execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d");
+ execution.setVariable("vfModuleId", "1234");
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ doReturn(Optional.of(volumeGroup)).when(bbSetupUtils)
+ .getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234");
+
+ VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
+ vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment());
+ org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
+ vfModule.setVolumeHeatTemplate(new HeatTemplate());
+ vfModuleCustomization.setVfModule(vfModule);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b"))
+ .thenReturn(vfModuleCustomization);
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ northBoundRequest.setOrchestrationFlowList(replaceVfModuleOrchFlows);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+
+ assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "UnassignVFModuleBB",
+ "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB",
+ "ChangeModelServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleKeepVolumeGroupReplaceRetainAssignmentsTest() throws Exception {
+ String gAction = "replaceInstanceRetainAssignments";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234");
+ execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d");
+ execution.setVariable("vfModuleId", "1234");
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ doReturn(Optional.of(volumeGroup)).when(bbSetupUtils)
+ .getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234");
+
+ VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
+ vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment());
+ org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
+ vfModule.setVolumeHeatTemplate(new HeatTemplate());
+ vfModuleCustomization.setVfModule(vfModule);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b"))
+ .thenReturn(vfModuleCustomization);
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ northBoundRequest.setOrchestrationFlowList(replaceRetainAssignmentsVfModuleOrchFlows);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+
+ assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "ChangeModelVfModuleBB",
+ "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleNoVolumeGroupToVolumeGroupReplaceTest() throws Exception {
+ String gAction = "replaceInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234");
+ execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d");
+ execution.setVariable("vfModuleId", "1234");
+
+ VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
+ vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment());
+ org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
+ vfModule.setVolumeHeatTemplate(new HeatTemplate());
+ vfModuleCustomization.setVfModule(vfModule);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b"))
+ .thenReturn(vfModuleCustomization);
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ northBoundRequest.setOrchestrationFlowList(replaceVfModuleOrchFlows);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+
+ assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "UnassignVFModuleBB",
+ "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB",
+ "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleNoVolumeGroupToVolumeGroupReplaceRetainAssignmentsTest()
+ throws Exception {
+ String gAction = "replaceInstanceRetainAssignments";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234");
+ execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d");
+ execution.setVariable("vfModuleId", "1234");
+
+ VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
+ vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment());
+ org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
+ vfModule.setVolumeHeatTemplate(new HeatTemplate());
+ vfModuleCustomization.setVfModule(vfModule);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b"))
+ .thenReturn(vfModuleCustomization);
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ northBoundRequest.setOrchestrationFlowList(replaceRetainAssignmentsVfModuleOrchFlows);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+
+ assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "AssignVolumeGroupBB",
+ "ChangeModelVfModuleBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleRebuildVolumeGroupReplaceTest() throws Exception {
+ String gAction = "replaceInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(
+ Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleReplaceRebuildVolumeGroups.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234");
+ execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d");
+ execution.setVariable("vfModuleId", "1234");
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ doReturn(Optional.of(volumeGroup)).when(bbSetupUtils)
+ .getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234");
+
+ VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
+ vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment());
+ org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
+ vfModule.setVolumeHeatTemplate(new HeatTemplate());
+ vfModuleCustomization.setVfModule(vfModule);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b"))
+ .thenReturn(vfModuleCustomization);
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ northBoundRequest.setOrchestrationFlowList(replaceVfModuleOrchFlows);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+
+ assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "DeactivateVolumeGroupBB",
+ "DeleteVolumeGroupBB", "UnassignVFModuleBB", "UnassignVolumeGroupBB", "AssignVolumeGroupBB",
+ "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "CreateVolumeGroupBB",
+ "ActivateVolumeGroupBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleRebuildVolumeGroupReplaceRetainAssignmentsTest() throws Exception {
+ String gAction = "replaceInstanceRetainAssignments";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(
+ Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleReplaceRebuildVolumeGroups.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234");
+ execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d");
+ execution.setVariable("vfModuleId", "1234");
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ doReturn(Optional.of(volumeGroup)).when(bbSetupUtils)
+ .getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234");
+
+ VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
+ vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment());
+ org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
+ vfModule.setVolumeHeatTemplate(new HeatTemplate());
+ vfModuleCustomization.setVfModule(vfModule);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b"))
+ .thenReturn(vfModuleCustomization);
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ northBoundRequest.setOrchestrationFlowList(replaceRetainAssignmentsVfModuleOrchFlows);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+
+ assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "DeactivateVolumeGroupBB",
+ "DeleteVolumeGroupBB", "UnassignVolumeGroupBB", "AssignVolumeGroupBB", "ChangeModelVfModuleBB",
+ "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB", "ActivateVfModuleBB",
+ "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
+ }
+
+
+ @Test
public void selectExecutionListALaCarteVfModuleFabricDeleteTest() throws Exception {
String gAction = "deleteInstance";
String resource = "VfModule";
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleReplaceRebuildVolumeGroups.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleReplaceRebuildVolumeGroups.json
new file mode 100644
index 0000000000..aa2462f371
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleReplaceRebuildVolumeGroups.json
@@ -0,0 +1,66 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelCustomizationName": "model-cust-name",
+ "modelInvariantId": "db86e4a6-c027-452e-a559-3a23b3128367",
+ "modelType": "vfModule",
+ "modelName": "test-model-name",
+ "modelVersion": "1",
+ "modelCustomizationUuid": "9a6d01fd-19a7-490a-9800-460830a12e0b",
+ "modelVersionId": "14c8f313-fb0f-4cf6-8caf-c7cce8137b60",
+ "modelCustomizationId": "9a6d01fd-19a7-490a-9800-460830a12e0b",
+ "modelUuid": "14c8f313-fb0f-4cf6-8caf-c7cce8137b60",
+ "modelInvariantUuid": "db86e4a6-c027-452e-a559-3a23b3128367",
+ "modelInstanceName": "test-model-instance-name"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "instanceName": "instanceName",
+ "suppressRollback": false,
+ "requestorId": "user"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "f647e3ef-6d2e-4cd3-bff4-8df4634208de",
+ "modelInfo": {
+ "modelInvariantId": "86adb376-5303-441a-b50e-96c0cd643b0f",
+ "modelType": "service",
+ "modelName": "model-name",
+ "modelVersion": "1.0",
+ "modelVersionId": "599e21ed-803d-4d1f-83df-20005339b83f",
+ "modelUuid": "599e21ed-803d-4d1f-83df-20005339b83f",
+ "modelInvariantUuid": "86adb376-5303-441a-b50e-96c0cd643b0f"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d",
+ "modelInfo": {
+ "modelCustomizationName": "modle-cust-name",
+ "modelInvariantId": "5cca9285-4ed4-4e11-a609-921ed3344811",
+ "modelType": "vnf",
+ "modelName": "modle-name",
+ "modelVersion": "1.0",
+ "modelCustomizationUuid": "fc25201d-36d6-43a3-8d39-fdae88e526ae",
+ "modelVersionId": "7cae703a-b20d-481a-863a-b862236c00f7",
+ "modelCustomizationId": "fc25201d-36d6-43a3-8d39-fdae88e526ae",
+ "modelUuid": "7cae703a-b20d-481a-863a-b862236c00f7",
+ "modelInvariantUuid": "5cca9285-4ed4-4e11-a609-921ed3344811",
+ "modelInstanceName": "model-inst-name"
+ }
+ }
+ }
+ ],
+ "cloudConfiguration": {
+ "tenantId": "872f331350c54e59991a8de2cbffb40c",
+ "cloudOwner": "my-custom-cloud-owner",
+ "lcpCloudRegionId": "cloud-region"
+ },
+ "requestParameters": {
+ "usePreload": true,
+ "rebuildVolumeGroups": true
+ }
+ }
+} \ No newline at end of file