summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java217
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java470
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java12
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilderTest.java90
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java55
7 files changed, 503 insertions, 345 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java
new file mode 100644
index 0000000000..b8699838e2
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java
@@ -0,0 +1,217 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
+ * Modifications Copyright (c) 2021 Nokia
+ * ================================================================================
+ * Modifications Copyright (c) 2020 Tech Mahindra
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
+import org.onap.so.db.catalog.beans.macro.OrchestrationFlow;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.stream.Collectors;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGNINSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONFIGURATION;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONTROLLER;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.NETWORKCOLLECTION;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCERETAINASSIGNMENTS;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.SERVICE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.VOLUMEGROUP;
+
+@Component
+public class ExecuteBuildingBlockBuilder {
+
+ private static final Logger logger = LoggerFactory.getLogger(ExecuteBuildingBlockBuilder.class);
+
+ private static final String VNF = "Vnf";
+ private static final String PNF = "Pnf";
+ private static final String VFMODULE = "VfModule";
+ private static final String NETWORK = "Network";
+
+ protected List<ExecuteBuildingBlock> buildExecuteBuildingBlockList(List<OrchestrationFlow> orchFlows,
+ List<Resource> resourceList, String requestId, String apiVersion, String resourceId, String requestAction,
+ String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails,
+ boolean replaceVnf) {
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+ for (OrchestrationFlow orchFlow : orchFlows) {
+ if (orchFlow.getFlowName().contains(SERVICE)) {
+ if (!replaceVnf) {
+ workflowResourceIds.setServiceInstanceId(resourceId);
+ }
+ addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.SERVICE, orchFlow, requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
+ false);
+ } else if (orchFlow.getFlowName().contains(VNF) || (orchFlow.getFlowName().contains(CONTROLLER)
+ && (VNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
+ addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VNF, orchFlow, requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
+ false);
+ } else if (orchFlow.getFlowName().contains(PNF) || (orchFlow.getFlowName().contains(CONTROLLER)
+ && (PNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
+ addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.PNF, orchFlow, requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
+ false);
+ } else if (orchFlow.getFlowName().contains(NETWORK)
+ && !orchFlow.getFlowName().contains(NETWORKCOLLECTION)) {
+ addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.NETWORK, orchFlow, requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
+ false);
+ addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VIRTUAL_LINK, orchFlow,
+ requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
+ true, false);
+ } else if (orchFlow.getFlowName().contains(VFMODULE) || (orchFlow.getFlowName().contains(CONTROLLER)
+ && (VFMODULE).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
+ List<Resource> vfModuleResourcesSorted;
+ if (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGNINSTANCE)
+ || requestAction.equals("activateInstance")) {
+ vfModuleResourcesSorted = sortVfModulesByBaseFirst(resourceList.stream()
+ .filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList()));
+ } else {
+ vfModuleResourcesSorted = sortVfModulesByBaseLast(resourceList.stream()
+ .filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList()));
+ }
+ for (Resource resource : vfModuleResourcesSorted) {
+ flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId,
+ requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, null,
+ false, null));
+ }
+ } 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();
+ }
+ addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VOLUMEGROUP, orchFlow,
+ requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
+ false, false);
+ } else if (orchFlow.getFlowName().contains(NETWORKCOLLECTION)) {
+ addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.NETWORKCOLLECTION, orchFlow,
+ requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
+ false, false);
+ } else if (orchFlow.getFlowName().contains(CONFIGURATION)) {
+ addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.CONFIGURATION, orchFlow,
+ 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, null));
+ }
+ }
+ return flowsToExecute;
+ }
+
+ 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,
+ ReplaceInstanceRelatedInformation replaceInfo) {
+
+ BuildingBlock buildingBlock =
+ new BuildingBlock().setBpmnFlowName(orchFlow.getFlowName()).setMsoId(UUID.randomUUID().toString())
+ .setIsVirtualLink(isVirtualLink).setVirtualLinkKey(virtualLinkKey)
+ .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)))) {
+ logger.debug("Setting resourceId to volume group id for volume group flow on replace");
+ resourceId = workflowResourceIds.getVolumeGroupId();
+ }
+
+ ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setApiVersion(apiVersion)
+ .setaLaCarte(aLaCarte).setRequestAction(requestAction).setResourceId(resourceId).setVnfType(vnfType)
+ .setWorkflowResourceIds(workflowResourceIds).setRequestId(requestId).setBuildingBlock(buildingBlock)
+ .setRequestDetails(requestDetails).setOldVolumeGroupName(oldVolumeGroupName);
+
+ if (resource != null && (isConfiguration || resource.getResourceType().equals(WorkflowType.CONFIGURATION))) {
+ ConfigurationResourceKeys configurationResourceKeys = getConfigurationResourceKeys(resource, vnfcName);
+ executeBuildingBlock.setConfigurationResourceKeys(configurationResourceKeys);
+ }
+ return executeBuildingBlock;
+ }
+
+ protected List<Resource> sortVfModulesByBaseFirst(List<Resource> vfModuleResources) {
+ int count = 0;
+ for (Resource resource : vfModuleResources) {
+ if (resource.isBaseVfModule()) {
+ Collections.swap(vfModuleResources, 0, count);
+ break;
+ }
+ count++;
+ }
+ return vfModuleResources;
+ }
+
+ protected List<Resource> sortVfModulesByBaseLast(List<Resource> vfModuleResources) {
+ int count = 0;
+ for (Resource resource : vfModuleResources) {
+ if (resource.isBaseVfModule()) {
+ Collections.swap(vfModuleResources, vfModuleResources.size() - 1, count);
+ break;
+ }
+ count++;
+ }
+ return vfModuleResources;
+ }
+
+ private void addBuildingBlockToExecuteBBList(List<ExecuteBuildingBlock> flowsToExecute, List<Resource> resourceList,
+ WorkflowType workflowType, OrchestrationFlow orchFlow, String requestId, String apiVersion,
+ String resourceId, String requestAction, String vnfType, WorkflowResourceIds workflowResourceIds,
+ RequestDetails requestDetails, boolean isVirtualLink, boolean isConfiguration) {
+
+ 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, null)));
+ }
+
+ private ConfigurationResourceKeys getConfigurationResourceKeys(Resource resource, String vnfcName) {
+ ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
+ Optional.ofNullable(vnfcName).ifPresent(configurationResourceKeys::setVnfcName);
+ configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId());
+ configurationResourceKeys.setVfModuleCustomizationUUID(resource.getVfModuleCustomizationId());
+ configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId());
+ return configurationResourceKeys;
+ }
+
+
+}
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 7821463acd..4be497c469 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
@@ -6,7 +6,7 @@
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
- * Modifications Copyright (c) 2020 Nokia
+ * Modifications Copyright (c) 2021 Nokia
* ================================================================================
* Modifications Copyright (c) 2020 Tech Mahindra
* ================================================================================
@@ -28,6 +28,7 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
import org.apache.commons.lang3.SerializationUtils;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.javatuples.Pair;
@@ -48,7 +49,6 @@ import org.onap.so.bpmn.common.BBConstants;
import org.onap.so.bpmn.infrastructure.workflow.tasks.utils.WorkflowResourceIdsUtils;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
-import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
@@ -80,7 +80,6 @@ import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
@@ -89,40 +88,36 @@ import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGNINSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONTROLLER;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.FABRIC_CONFIGURATION;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.NETWORKCOLLECTION;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCERETAINASSIGNMENTS;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.SERVICE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.USER_PARAM_SERVICE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.WORKFLOW_ACTION_ERROR_MESSAGE;
@Component
public class WorkflowAction {
+ private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class);
+
private static final String SERVICE_INSTANCES = "serviceInstances";
private static final String VF_MODULES = "vfModules";
private static final String VNF_TYPE = "vnfType";
- private static final String SERVICE = "Service";
- private static final String VNF = "Vnf";
- private static final String PNF = "Pnf";
- private static final String VFMODULE = "VfModule";
- private static final String VOLUMEGROUP = "VolumeGroup";
- private static final String NETWORK = "Network";
- private static final String NETWORKCOLLECTION = "NetworkCollection";
private static final String CONFIGURATION = "Configuration";
- private static final String ASSIGNINSTANCE = "assignInstance";
- private static final String REPLACEINSTANCE = "replaceInstance";
- private static final String REPLACEINSTANCERETAINASSIGNMENTS = "replaceInstanceRetainAssignments";
private static final String SUPPORTEDTYPES =
"vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances|instanceGroups";
private static final String HOMINGSOLUTION = "Homing_Solution";
private static final String SERVICE_TYPE_TRANSPORT = "TRANSPORT";
private static final String SERVICE_TYPE_BONDING = "BONDING";
private static final String CLOUD_OWNER = "DEFAULT";
- private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class);
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(.*)";
- private static final String CONTROLLER = "Controller";
private static final String DEFAULT_CLOUD_OWNER = "org.onap.so.cloud-owner";
private static final String HOMING = "homing";
@@ -146,6 +141,8 @@ public class WorkflowAction {
private UserParamsServiceTraversal userParamsServiceTraversal;
@Autowired
private AaiResourceIdValidator aaiResourceIdValidator;
+ @Autowired
+ private ExecuteBuildingBlockBuilder executeBuildingBlockBuilder;
public void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils) {
this.bbInputSetupUtils = bbInputSetupUtils;
@@ -179,8 +176,7 @@ public class WorkflowAction {
String serviceInstanceId = getServiceInstanceId(execution, resourceId, resourceType);
fillExecution(execution, requestDetails.getRequestInfo().getSuppressRollback(), resourceId, resourceType);
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
-
+ List<ExecuteBuildingBlock> flowsToExecute;
if (isRequestMacroServiceResume(isALaCarte, resourceType, requestAction, serviceInstanceId)) {
String errorMessage = "Could not resume Macro flow. Error loading execution path.";
flowsToExecute = loadExecuteBuildingBlocks(execution, requestId, errorMessage);
@@ -197,140 +193,13 @@ public class WorkflowAction {
final String serviceType =
Optional.ofNullable((String) execution.getVariable(BBConstants.G_SERVICE_TYPE)).orElse("");
if (isALaCarte) {
- if (orchFlows == null || orchFlows.isEmpty()) {
- orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, true,
- cloudOwner, serviceType);
- }
- Resource resourceKey = getResourceKey(sIRequest, resourceType);
-
- ReplaceInstanceRelatedInformation replaceInfo = new ReplaceInstanceRelatedInformation();
- if ((requestAction.equalsIgnoreCase(REPLACEINSTANCE)
- || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS))
- && resourceType.equals(WorkflowType.VFMODULE)) {
- logger.debug("Build a BB list for replacing BB modules");
- ConfigBuildingBlocksDataObject cbbdo = createConfigBuildingBlocksDataObject(execution,
- sIRequest, requestId, workflowResourceIds, requestDetails, requestAction, resourceId,
- vnfType, orchFlows, apiVersion, resourceKey, replaceInfo);
- orchFlows = getVfModuleReplaceBuildingBlocks(cbbdo);
-
- createBuildingBlocksForOrchFlows(execution, sIRequest, requestId, workflowResourceIds,
- requestDetails, requestAction, resourceId, flowsToExecute, vnfType, orchFlows,
- apiVersion, resourceKey, replaceInfo);
- } else {
- if (isConfiguration(orchFlows) && !requestAction.equalsIgnoreCase(CREATE_INSTANCE)) {
- addConfigBuildingBlocksToFlowsToExecuteList(execution, sIRequest, requestId,
- workflowResourceIds, requestDetails, requestAction, resourceId, flowsToExecute,
- vnfType, apiVersion, resourceKey, replaceInfo, orchFlows);
- }
- orchFlows =
- orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION))
- .collect(Collectors.toList());
-
- for (OrchestrationFlow orchFlow : orchFlows) {
- ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey,
- apiVersion, resourceId, requestAction, true, vnfType, workflowResourceIds,
- requestDetails, false, null, null, false, replaceInfo);
- flowsToExecute.add(ebb);
- }
- }
+ flowsToExecute = loadExecuteBuildingBlocksForAlaCarte(orchFlows, execution, requestAction,
+ resourceType, cloudOwner, serviceType, sIRequest, requestId, workflowResourceIds,
+ requestDetails, resourceId, vnfType, apiVersion);
} else {
- boolean containsService = false;
- List<Resource> resourceList = new ArrayList<>();
- List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
- List<Map<String, Object>> userParams =
- sIRequest.getRequestDetails().getRequestParameters().getUserParams();
- if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(ASSIGNINSTANCE)) {
- // SERVICE-MACRO-ASSIGN will always get user params with a
- // service.
-
- if (userParams != null) {
- containsService = isContainsService(sIRequest);
- if (containsService) {
- resourceList = userParamsServiceTraversal.getResourceListFromUserParams(execution,
- userParams, serviceInstanceId, requestAction);
- }
- } else {
- buildAndThrowException(execution,
- "Service-Macro-Assign request details must contain user params with a service");
- }
- } else if (resourceType == WorkflowType.SERVICE
- && requestAction.equalsIgnoreCase(CREATE_INSTANCE)) {
- // SERVICE-MACRO-CREATE will get user params with a service,
- // a service with a network, a service with a
- // network collection, OR an empty service.
- // If user params is just a service or null and macro
- // queries the SI and finds a VNF, macro fails.
-
- if (userParams != null) {
- containsService = isContainsService(sIRequest);
- }
- if (containsService) {
- resourceList = userParamsServiceTraversal.getResourceListFromUserParams(execution,
- userParams, serviceInstanceId, requestAction);
- }
- if (!foundRelated(resourceList)) {
- traverseCatalogDbService(execution, sIRequest, resourceList, aaiResourceIds);
- }
- } else if (resourceType == WorkflowType.SERVICE
- && ("activateInstance".equalsIgnoreCase(requestAction)
- || "unassignInstance".equalsIgnoreCase(requestAction)
- || "deleteInstance".equalsIgnoreCase(requestAction)
- || 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
- // to query the SI in AAI to find related instances.
- traverseAAIService(execution, resourceList, resourceId, aaiResourceIds);
- } else if (resourceType == WorkflowType.SERVICE
- && "deactivateInstance".equalsIgnoreCase(requestAction)) {
- resourceList.add(new Resource(WorkflowType.SERVICE, "", false));
- } else if (resourceType == WorkflowType.VNF && (REPLACEINSTANCE.equalsIgnoreCase(requestAction)
- || ("recreateInstance".equalsIgnoreCase(requestAction)))) {
- traverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
- workflowResourceIds.getVnfId(), aaiResourceIds);
- } else if (resourceType == WorkflowType.VNF && "updateInstance".equalsIgnoreCase(requestAction)) {
- customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
- workflowResourceIds.getVnfId(), aaiResourceIds);
- } else {
- buildAndThrowException(execution, "Current Macro Request is not supported");
- }
- StringBuilder foundObjects = new StringBuilder();
- for (WorkflowType type : WorkflowType.values()) {
- foundObjects.append(type).append(" - ").append(
- (int) resourceList.stream().filter(x -> type.equals(x.getResourceType())).count())
- .append(" ");
- }
- logger.info("Found {}", foundObjects);
-
- if (orchFlows == null || orchFlows.isEmpty()) {
- orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, isALaCarte,
- cloudOwner, serviceType);
- }
- boolean vnfReplace = false;
- if (resourceType.equals(WorkflowType.VNF) && (REPLACEINSTANCE.equalsIgnoreCase(requestAction)
- || REPLACEINSTANCERETAINASSIGNMENTS.equalsIgnoreCase(requestAction))) {
- vnfReplace = true;
- }
- flowsToExecute = buildExecuteBuildingBlockList(orchFlows, resourceList, requestId, apiVersion,
- resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, vnfReplace);
- if (isNetworkCollectionInTheResourceList(resourceList)) {
- logger.info("Sorting for Vlan Tagging");
- flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction);
- }
- // By default, enable homing at VNF level for CREATE_INSTANCE and ASSIGNINSTANCE
- if (resourceType == WorkflowType.SERVICE
- && (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGNINSTANCE))
- && resourceList.stream().anyMatch(x -> WorkflowType.VNF.equals(x.getResourceType()))) {
- execution.setVariable(HOMING, true);
- execution.setVariable("calledHoming", false);
- }
- if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase(ASSIGNINSTANCE)
- || requestAction.equalsIgnoreCase(CREATE_INSTANCE))) {
- generateResourceIds(flowsToExecute, resourceList, serviceInstanceId);
- } else {
- updateResourceIdsFromAAITraversal(flowsToExecute, resourceList, aaiResourceIds,
- serviceInstanceId);
- }
+ flowsToExecute = loadExecuteBuildingBlocksForMacro(sIRequest, resourceType, requestAction,
+ execution, serviceInstanceId, resourceId, workflowResourceIds, orchFlows, cloudOwner,
+ serviceType, requestId, apiVersion, vnfType, requestDetails);
}
}
// If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is specified,
@@ -371,6 +240,151 @@ public class WorkflowAction {
}
}
+ private List<ExecuteBuildingBlock> loadExecuteBuildingBlocksForAlaCarte(List<OrchestrationFlow> orchFlows,
+ DelegateExecution execution, String requestAction, WorkflowType resourceType, String cloudOwner,
+ String serviceType, ServiceInstancesRequest sIRequest, String requestId,
+ WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, String resourceId, String vnfType,
+ String apiVersion) throws Exception {
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+ if (orchFlows == null || orchFlows.isEmpty()) {
+ orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, true, cloudOwner,
+ serviceType);
+ }
+ Resource resourceKey = getResourceKey(sIRequest, resourceType);
+
+ ReplaceInstanceRelatedInformation replaceInfo = new ReplaceInstanceRelatedInformation();
+ if ((requestAction.equalsIgnoreCase(REPLACEINSTANCE)
+ || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS))
+ && resourceType.equals(WorkflowType.VFMODULE)) {
+ logger.debug("Build a BB list for replacing BB modules");
+ ConfigBuildingBlocksDataObject cbbdo = createConfigBuildingBlocksDataObject(execution, sIRequest, requestId,
+ workflowResourceIds, requestDetails, requestAction, resourceId, vnfType, orchFlows, apiVersion,
+ resourceKey, replaceInfo);
+ orchFlows = getVfModuleReplaceBuildingBlocks(cbbdo);
+
+ createBuildingBlocksForOrchFlows(execution, sIRequest, requestId, workflowResourceIds, requestDetails,
+ requestAction, resourceId, flowsToExecute, vnfType, orchFlows, apiVersion, resourceKey,
+ replaceInfo);
+ } else {
+ if (isConfiguration(orchFlows) && !requestAction.equalsIgnoreCase(CREATE_INSTANCE)) {
+ addConfigBuildingBlocksToFlowsToExecuteList(execution, sIRequest, requestId, workflowResourceIds,
+ requestDetails, requestAction, resourceId, flowsToExecute, vnfType, apiVersion, resourceKey,
+ replaceInfo, orchFlows);
+ }
+ orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION))
+ .collect(Collectors.toList());
+
+ for (OrchestrationFlow orchFlow : orchFlows) {
+ ExecuteBuildingBlock ebb = executeBuildingBlockBuilder.buildExecuteBuildingBlock(orchFlow, requestId,
+ resourceKey, apiVersion, resourceId, requestAction, true, vnfType, workflowResourceIds,
+ requestDetails, false, null, null, false, replaceInfo);
+ flowsToExecute.add(ebb);
+ }
+ }
+ return flowsToExecute;
+ }
+
+ private List<ExecuteBuildingBlock> loadExecuteBuildingBlocksForMacro(ServiceInstancesRequest sIRequest,
+ WorkflowType resourceType, String requestAction, DelegateExecution execution, String serviceInstanceId,
+ String resourceId, WorkflowResourceIds workflowResourceIds, List<OrchestrationFlow> orchFlows,
+ String cloudOwner, String serviceType, String requestId, String apiVersion, String vnfType,
+ RequestDetails requestDetails) throws IOException, VrfBondingServiceException {
+ List<ExecuteBuildingBlock> flowsToExecute;
+ boolean containsService = false;
+ List<Resource> resourceList = new ArrayList<>();
+ List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
+ List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams();
+ if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(ASSIGNINSTANCE)) {
+ // SERVICE-MACRO-ASSIGN will always get user params with a
+ // service.
+
+ if (userParams != null) {
+ containsService = isContainsService(sIRequest);
+ if (containsService) {
+ resourceList = userParamsServiceTraversal.getResourceListFromUserParams(execution, userParams,
+ serviceInstanceId, requestAction);
+ }
+ } else {
+ buildAndThrowException(execution,
+ "Service-Macro-Assign request details must contain user params with a service");
+ }
+ } else if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(CREATE_INSTANCE)) {
+ // SERVICE-MACRO-CREATE will get user params with a service,
+ // a service with a network, a service with a
+ // network collection, OR an empty service.
+ // If user params is just a service or null and macro
+ // queries the SI and finds a VNF, macro fails.
+
+ if (userParams != null) {
+ containsService = isContainsService(sIRequest);
+ }
+ if (containsService) {
+ resourceList = userParamsServiceTraversal.getResourceListFromUserParams(execution, userParams,
+ serviceInstanceId, requestAction);
+ }
+ if (!foundRelated(resourceList)) {
+ traverseCatalogDbService(execution, sIRequest, resourceList, aaiResourceIds);
+ }
+ } else if (resourceType == WorkflowType.SERVICE && ("activateInstance".equalsIgnoreCase(requestAction)
+ || "unassignInstance".equalsIgnoreCase(requestAction)
+ || "deleteInstance".equalsIgnoreCase(requestAction)
+ || 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
+ // to query the SI in AAI to find related instances.
+ traverseAAIService(execution, resourceList, resourceId, aaiResourceIds);
+ } else if (resourceType == WorkflowType.SERVICE && "deactivateInstance".equalsIgnoreCase(requestAction)) {
+ resourceList.add(new Resource(WorkflowType.SERVICE, "", false));
+ } else if (resourceType == WorkflowType.VNF && (REPLACEINSTANCE.equalsIgnoreCase(requestAction)
+ || ("recreateInstance".equalsIgnoreCase(requestAction)))) {
+ traverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
+ workflowResourceIds.getVnfId(), aaiResourceIds);
+ } else if (resourceType == WorkflowType.VNF && "updateInstance".equalsIgnoreCase(requestAction)) {
+ customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
+ workflowResourceIds.getVnfId(), aaiResourceIds);
+ } else {
+ buildAndThrowException(execution, "Current Macro Request is not supported");
+ }
+ StringBuilder foundObjects = new StringBuilder();
+ for (WorkflowType type : WorkflowType.values()) {
+ foundObjects.append(type).append(" - ")
+ .append((int) resourceList.stream().filter(x -> type.equals(x.getResourceType())).count())
+ .append(" ");
+ }
+ logger.info("Found {}", foundObjects);
+
+ if (orchFlows == null || orchFlows.isEmpty()) {
+ orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, false, cloudOwner,
+ serviceType);
+ }
+ boolean vnfReplace = false;
+ if (resourceType.equals(WorkflowType.VNF) && (REPLACEINSTANCE.equalsIgnoreCase(requestAction)
+ || REPLACEINSTANCERETAINASSIGNMENTS.equalsIgnoreCase(requestAction))) {
+ vnfReplace = true;
+ }
+ flowsToExecute = executeBuildingBlockBuilder.buildExecuteBuildingBlockList(orchFlows, resourceList, requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, vnfReplace);
+ if (isNetworkCollectionInTheResourceList(resourceList)) {
+ logger.info("Sorting for Vlan Tagging");
+ flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction);
+ }
+ // By default, enable homing at VNF level for CREATE_INSTANCE and ASSIGNINSTANCE
+ if (resourceType == WorkflowType.SERVICE
+ && (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGNINSTANCE))
+ && resourceList.stream().anyMatch(x -> WorkflowType.VNF.equals(x.getResourceType()))) {
+ execution.setVariable(HOMING, true);
+ execution.setVariable("calledHoming", false);
+ }
+ if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase(ASSIGNINSTANCE)
+ || requestAction.equalsIgnoreCase(CREATE_INSTANCE))) {
+ generateResourceIds(flowsToExecute, resourceList, serviceInstanceId);
+ } else {
+ updateResourceIdsFromAAITraversal(flowsToExecute, resourceList, aaiResourceIds, serviceInstanceId);
+ }
+ return flowsToExecute;
+ }
+
private void setExecutionVariables(DelegateExecution execution, List<ExecuteBuildingBlock> flowsToExecute,
List<String> flowNames) {
execution.setVariable("flowNames", flowNames);
@@ -427,9 +441,9 @@ public class WorkflowAction {
requestDetails, requestAction, resourceId, flowsToExecute, vnfType, apiVersion, resourceKey,
replaceInfo, configOrchFlows);
} else {
- ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion,
- resourceId, requestAction, true, vnfType, workflowResourceIds, requestDetails, false, null,
- null, false, replaceInfo);
+ ExecuteBuildingBlock ebb = executeBuildingBlockBuilder.buildExecuteBuildingBlock(orchFlow, requestId,
+ resourceKey, apiVersion, resourceId, requestAction, true, vnfType, workflowResourceIds,
+ requestDetails, false, null, null, false, replaceInfo);
flowsToExecute.add(ebb);
}
}
@@ -597,10 +611,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(), workflowIdsCopy,
- dataObj.getRequestDetails(), false, null, vnfcName, true, null);
+ ExecuteBuildingBlock ebb =
+ executeBuildingBlockBuilder.buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(),
+ dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(),
+ dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(),
+ workflowIdsCopy, dataObj.getRequestDetails(), false, null, vnfcName, true, null);
flowsToExecuteConfigs.add(ebb);
}
}
@@ -682,29 +697,7 @@ public class WorkflowAction {
return orchFlows;
}
- protected List<Resource> sortVfModulesByBaseFirst(List<Resource> vfModuleResources) {
- int count = 0;
- for (Resource resource : vfModuleResources) {
- if (resource.isBaseVfModule()) {
- Collections.swap(vfModuleResources, 0, count);
- break;
- }
- count++;
- }
- return vfModuleResources;
- }
- protected List<Resource> sortVfModulesByBaseLast(List<Resource> vfModuleResources) {
- int count = 0;
- for (Resource resource : vfModuleResources) {
- if (resource.isBaseVfModule()) {
- Collections.swap(vfModuleResources, vfModuleResources.size() - 1, count);
- break;
- }
- count++;
- }
- return vfModuleResources;
- }
private void updateResourceIdsFromAAITraversal(List<ExecuteBuildingBlock> flowsToExecute,
List<Resource> resourceList, List<Pair<WorkflowType, String>> aaiResourceIds, String serviceInstanceId) {
@@ -1331,125 +1324,6 @@ public class WorkflowAction {
return sortedOrchFlows;
}
- private void addBuildingBlockToExecuteBBList(List<ExecuteBuildingBlock> flowsToExecute, List<Resource> resourceList,
- WorkflowType workflowType, OrchestrationFlow orchFlow, String requestId, String apiVersion,
- String resourceId, String requestAction, String vnfType, WorkflowResourceIds workflowResourceIds,
- RequestDetails requestDetails, boolean isVirtualLink, boolean isConfiguration) {
-
- 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, null)));
- }
-
- protected List<ExecuteBuildingBlock> buildExecuteBuildingBlockList(List<OrchestrationFlow> orchFlows,
- List<Resource> resourceList, String requestId, String apiVersion, String resourceId, String requestAction,
- String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails,
- boolean replaceVnf) {
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
- for (OrchestrationFlow orchFlow : orchFlows) {
- if (orchFlow.getFlowName().contains(SERVICE)) {
- if (!replaceVnf) {
- workflowResourceIds.setServiceInstanceId(resourceId);
- }
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.SERVICE, orchFlow, requestId,
- apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
- false);
- } else if (orchFlow.getFlowName().contains(VNF) || (orchFlow.getFlowName().contains(CONTROLLER)
- && (VNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VNF, orchFlow, requestId,
- apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
- false);
- } else if (orchFlow.getFlowName().contains(PNF) || (orchFlow.getFlowName().contains(CONTROLLER)
- && (PNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.PNF, orchFlow, requestId,
- apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
- false);
- } else if (orchFlow.getFlowName().contains(NETWORK)
- && !orchFlow.getFlowName().contains(NETWORKCOLLECTION)) {
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.NETWORK, orchFlow, requestId,
- apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
- false);
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VIRTUAL_LINK, orchFlow,
- requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
- true, false);
- } else if (orchFlow.getFlowName().contains(VFMODULE) || (orchFlow.getFlowName().contains(CONTROLLER)
- && (VFMODULE).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
- List<Resource> vfModuleResourcesSorted;
- if (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGNINSTANCE)
- || requestAction.equals("activateInstance")) {
- vfModuleResourcesSorted = sortVfModulesByBaseFirst(resourceList.stream()
- .filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList()));
- } else {
- vfModuleResourcesSorted = sortVfModulesByBaseLast(resourceList.stream()
- .filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList()));
- }
- for (Resource resource : vfModuleResourcesSorted) {
- flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId,
- requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, null,
- false, null));
- }
- } 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();
- }
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VOLUMEGROUP, orchFlow,
- requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
- false, false);
- } else if (orchFlow.getFlowName().contains(NETWORKCOLLECTION)) {
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.NETWORKCOLLECTION, orchFlow,
- requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
- false, false);
- } else if (orchFlow.getFlowName().contains(CONFIGURATION)) {
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.CONFIGURATION, orchFlow,
- 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, null));
- }
- }
- return flowsToExecute;
- }
-
- 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,
- ReplaceInstanceRelatedInformation replaceInfo) {
-
- BuildingBlock buildingBlock =
- new BuildingBlock().setBpmnFlowName(orchFlow.getFlowName()).setMsoId(UUID.randomUUID().toString())
- .setIsVirtualLink(isVirtualLink).setVirtualLinkKey(virtualLinkKey)
- .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)))) {
- logger.debug("Setting resourceId to volume group id for volume group flow on replace");
- resourceId = workflowResourceIds.getVolumeGroupId();
- }
-
- ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setApiVersion(apiVersion)
- .setaLaCarte(aLaCarte).setRequestAction(requestAction).setResourceId(resourceId).setVnfType(vnfType)
- .setWorkflowResourceIds(workflowResourceIds).setRequestId(requestId).setBuildingBlock(buildingBlock)
- .setRequestDetails(requestDetails).setOldVolumeGroupName(oldVolumeGroupName);
-
- if (resource != null && (isConfiguration || resource.getResourceType().equals(WorkflowType.CONFIGURATION))) {
- ConfigurationResourceKeys configurationResourceKeys = getConfigurationResourceKeys(resource, vnfcName);
- executeBuildingBlock.setConfigurationResourceKeys(configurationResourceKeys);
- }
- return executeBuildingBlock;
- }
-
private ConfigurationResourceKeys getConfigurationResourceKeys(Resource resource, String vnfcName) {
ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
Optional.ofNullable(vnfcName).ifPresent(configurationResourceKeys::setVnfcName);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java
index bffa2592c1..5e16097304 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java
@@ -28,8 +28,20 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks;
public final class WorkflowActionConstants {
+ private WorkflowActionConstants() {
+ throw new IllegalStateException("Utility class");
+ }
+
static final String USER_PARAM_SERVICE = "service";
static final String CREATE_INSTANCE = "createInstance";
static final String FABRIC_CONFIGURATION = "FabricConfiguration";
static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage";
+ static final String SERVICE = "Service";
+ static final String CONTROLLER = "Controller";
+ static final String NETWORKCOLLECTION = "NetworkCollection";
+ static final String CONFIGURATION = "Configuration";
+ static final String ASSIGNINSTANCE = "assignInstance";
+ static final String REPLACEINSTANCE = "replaceInstance";
+ static final String VOLUMEGROUP = "VolumeGroup";
+ static final String REPLACEINSTANCERETAINASSIGNMENTS = "replaceInstanceRetainAssignments";
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java
index 2119ced951..564ee91fb2 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java
@@ -84,7 +84,7 @@ public class SkipCDSBuildingBlockListener implements FlowManipulator {
VnfResourceCustomization vrc = catalogDbClient.findVnfResourceCustomizationInList(customizationUUID,
vnfResourceCustomizations);
if (null != vrc) {
- boolean skipConfigVNF = vrc.isSkipPostInstConf();
+ boolean skipConfigVNF = vrc.isSkipPostInstConf().booleanValue();
currentSequenceSkipCheck(execution, skipConfigVNF);
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java
index 6589ae77f5..83f61e3a4f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java
@@ -34,7 +34,7 @@ public class SkipConfigVnfListener implements FlowManipulator {
if (vnfResourceCustomizations != null && !vnfResourceCustomizations.isEmpty()) {
VnfResourceCustomization vrc =
catalogDbClient.findVnfResourceCustomizationInList(vnfCustomizationUUID, vnfResourceCustomizations);
- boolean skipConfigVNF = vrc.isSkipPostInstConf();
+ boolean skipConfigVNF = vrc.isSkipPostInstConf().booleanValue();
if (skipConfigVNF) {
execution.setVariable(BBConstants.G_CURRENT_SEQUENCE,
((int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE)) + 1);
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilderTest.java
new file mode 100644
index 0000000000..c8914f6e02
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilderTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
+ * Modifications Copyright (c) 2021 Nokia
+ * ================================================================================
+ * Modifications Copyright (c) 2020 Tech Mahindra
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import org.junit.Test;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.db.catalog.beans.macro.OrchestrationFlow;
+import java.util.ArrayList;
+import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+public class ExecuteBuildingBlockBuilderTest {
+
+ final private ExecuteBuildingBlockBuilder executeBBBuilder = new ExecuteBuildingBlockBuilder();
+
+ @Test
+ public void sortVfModulesByBaseFirstTest() {
+ List<Resource> resources = new ArrayList<>();
+ Resource resource1 = new Resource(WorkflowType.VFMODULE, "111", false);
+ resource1.setBaseVfModule(false);
+ resources.add(resource1);
+ Resource resource2 = new Resource(WorkflowType.VFMODULE, "222", false);
+ resource2.setBaseVfModule(false);
+ resources.add(resource2);
+ Resource resource3 = new Resource(WorkflowType.VFMODULE, "333", false);
+ resource3.setBaseVfModule(true);
+ resources.add(resource3);
+
+ List<Resource> result = executeBBBuilder.sortVfModulesByBaseFirst(resources);
+ assertEquals("333", result.get(0).getResourceId());
+ assertEquals("222", result.get(1).getResourceId());
+ assertEquals("111", result.get(2).getResourceId());
+ }
+
+ @Test
+ public void sortVfModulesByBaseLastTest() {
+ List<Resource> resources = new ArrayList<>();
+ Resource resource1 = new Resource(WorkflowType.VFMODULE, "111", false);
+ resource1.setBaseVfModule(true);
+ resources.add(resource1);
+ Resource resource2 = new Resource(WorkflowType.VFMODULE, "222", false);
+ resource2.setBaseVfModule(false);
+ resources.add(resource2);
+ Resource resource3 = new Resource(WorkflowType.VFMODULE, "333", false);
+ resource3.setBaseVfModule(false);
+ resources.add(resource3);
+ List<Resource> result = executeBBBuilder.sortVfModulesByBaseLast(resources);
+ assertEquals("333", result.get(0).getResourceId());
+ assertEquals("222", result.get(1).getResourceId());
+ assertEquals("111", result.get(2).getResourceId());
+ }
+
+ @Test
+ public void verifyLackOfNullPointerExceptionForNullResource() {
+ ExecuteBuildingBlock result = null;
+ try {
+ result = executeBBBuilder.buildExecuteBuildingBlock(new OrchestrationFlow(), null, null, null, null, null,
+ false, null, null, null, false, null, null, true, null);
+ } catch (NullPointerException e) {
+ fail("NullPointerException should not be thrown when 'resource' is null");
+ }
+ assertNotNull(result);
+ }
+}
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 c916e09c79..100c32f1c2 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
@@ -120,6 +120,7 @@ public class WorkflowActionTest extends BaseTaskTest {
protected Environment environment;
@Mock
protected UserParamsServiceTraversal userParamsServiceTraversal;
+
@Mock
private AaiResourceIdValidator aaiResourceIdValidator;
@InjectMocks
@@ -131,6 +132,9 @@ public class WorkflowActionTest extends BaseTaskTest {
@Spy
protected WorkflowAction SPY_workflowAction;
+ @Spy
+ protected ExecuteBuildingBlockBuilder executeBuildingBlockBuilder;
+
@Rule
public ExpectedException thrown = ExpectedException.none();
@@ -159,6 +163,7 @@ public class WorkflowActionTest extends BaseTaskTest {
when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), anyObject())).thenReturn(servInstance);
workflowAction.setBbInputSetupUtils(bbSetupUtils);
workflowAction.setBbInputSetup(bbInputSetup);
+
}
/**
@@ -179,6 +184,7 @@ public class WorkflowActionTest extends BaseTaskTest {
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, "AssignNetwork1802BB", "CreateNetworkBB", "ActivateNetworkBB");
@@ -199,6 +205,7 @@ public class WorkflowActionTest extends BaseTaskTest {
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, "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetwork1802BB");
@@ -219,6 +226,7 @@ public class WorkflowActionTest extends BaseTaskTest {
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, "AssignServiceInstanceBB", "ActivateServiceInstanceBB");
@@ -292,6 +300,7 @@ public class WorkflowActionTest extends BaseTaskTest {
.thenReturn(vfModuleCustomization2);
when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969"))
.thenReturn(vfModuleCustomization3);
+
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignVnfBB", "AssignVolumeGroupBB",
@@ -471,6 +480,7 @@ public class WorkflowActionTest extends BaseTaskTest {
doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignNetworkBB", "CreateNetworkBB",
@@ -2063,41 +2073,7 @@ public class WorkflowActionTest extends BaseTaskTest {
workflowAction.traverseCatalogDbService(execution, sIRequest, resourceCounter, aaiResourceIds);
}
- @Test
- public void sortVfModulesByBaseFirstTest() {
- List<Resource> resources = new ArrayList<>();
- Resource resource1 = new Resource(WorkflowType.VFMODULE, "111", false);
- resource1.setBaseVfModule(false);
- resources.add(resource1);
- Resource resource2 = new Resource(WorkflowType.VFMODULE, "222", false);
- resource2.setBaseVfModule(false);
- resources.add(resource2);
- Resource resource3 = new Resource(WorkflowType.VFMODULE, "333", false);
- resource3.setBaseVfModule(true);
- resources.add(resource3);
- List<Resource> result = workflowAction.sortVfModulesByBaseFirst(resources);
- assertEquals("333", result.get(0).getResourceId());
- assertEquals("222", result.get(1).getResourceId());
- assertEquals("111", result.get(2).getResourceId());
- }
- @Test
- public void sortVfModulesByBaseLastTest() {
- List<Resource> resources = new ArrayList<>();
- Resource resource1 = new Resource(WorkflowType.VFMODULE, "111", false);
- resource1.setBaseVfModule(true);
- resources.add(resource1);
- Resource resource2 = new Resource(WorkflowType.VFMODULE, "222", false);
- resource2.setBaseVfModule(false);
- resources.add(resource2);
- Resource resource3 = new Resource(WorkflowType.VFMODULE, "333", false);
- resource3.setBaseVfModule(false);
- resources.add(resource3);
- List<Resource> result = workflowAction.sortVfModulesByBaseLast(resources);
- assertEquals("333", result.get(0).getResourceId());
- assertEquals("222", result.get(1).getResourceId());
- assertEquals("111", result.get(2).getResourceId());
- }
@Test
public void findCatalogNetworkCollectionTest() {
@@ -2136,17 +2112,6 @@ public class WorkflowActionTest extends BaseTaskTest {
execution.getVariable("WorkflowActionErrorMessage"));
}
- @Test
- public void verifyLackOfNullPointerExceptionForNullResource() {
- ExecuteBuildingBlock result = null;
- try {
- result = workflowAction.buildExecuteBuildingBlock(new OrchestrationFlow(), null, null, null, null, null,
- false, null, null, null, false, null, null, true, null);
- } catch (NullPointerException e) {
- fail("NullPointerException should not be thrown when 'resource' is null");
- }
- assertNotNull(result);
- }
@Test
public void traverseAAIServiceTest() {