summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main
diff options
context:
space:
mode:
authorJozsef Csongvai <jozsef.csongvai@bell.ca>2020-11-24 14:44:01 -0500
committerJozsef Csongvai <jozsef.csongvai@bell.ca>2021-06-18 00:00:43 +0000
commit3c9bc7d08acb18d76af794bfe936fed7c917b284 (patch)
tree1a86cc0ba88633f061b2a56bf06766b81a619b18 /bpmn/so-bpmn-tasks/src/main
parentabfaee8128ecc8bfb1fe7562631fb0d765b22d8c (diff)
Add VNF-Macro-Create and VNF-Macro-Delete
These macros enable creation and deletion of a vnf with vfmodules for an existing service instance using building blocks. Also: - No longer force alaCarte=true for these use cases - Fix broken vfModule sorting logic for baseFirst/baseLast - Minor refactoring replacing String literals with constants Issue-ID: SO-3635 Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca> Change-Id: I16975f3561f2d978dede20679927ac3531def900
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java45
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java5
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java22
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java25
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java15
5 files changed, 57 insertions, 55 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
index 2138f489ee..813dc04ecd 100644
--- 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
@@ -26,6 +26,7 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
+import java.util.Comparator;
import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
@@ -36,12 +37,12 @@ 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.ACTIVATE_INSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGN_INSTANCE;
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;
@@ -94,15 +95,17 @@ public class ExecuteBuildingBlockBuilder {
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()));
+ Comparator<Resource> resourceComparator;
+ if (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGN_INSTANCE)
+ || requestAction.equals(ACTIVATE_INSTANCE)) {
+ resourceComparator = Resource.sortBaseFirst;
} else {
- vfModuleResourcesSorted = sortVfModulesByBaseLast(resourceList.stream()
- .filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList()));
+ resourceComparator = Resource.sortBaseLast;
}
+ List<Resource> vfModuleResourcesSorted =
+ resourceList.stream().filter(x -> WorkflowType.VFMODULE == x.getResourceType())
+ .sorted(resourceComparator).collect(Collectors.toList());
+
for (Resource resource : vfModuleResourcesSorted) {
flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId,
requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, null,
@@ -169,30 +172,6 @@ public class ExecuteBuildingBlockBuilder {
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,
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java
index 447f8994db..692d8bccdb 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java
@@ -20,6 +20,8 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
+import java.util.Comparator;
+
public class Resource {
private String resourceId;
@@ -31,6 +33,9 @@ public class Resource {
private String vfModuleCustomizationId;
private String cvnfModuleCustomizationId;
+ public static final Comparator<Resource> sortBaseFirst = Comparator.comparingInt(x -> x.isBaseVfModule() ? 0 : 1);
+ public static final Comparator<Resource> sortBaseLast = Comparator.comparingInt(x -> x.isBaseVfModule() ? 1 : 0);
+
public Resource(WorkflowType resourceType, String resourceId, boolean generated) {
this.resourceId = resourceId;
this.resourceType = resourceType;
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 29206a6aa9..8a9289981d 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
@@ -26,13 +26,16 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGNINSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGN_INSTANCE;
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.DELETE_INSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.FABRIC_CONFIGURATION;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.RECREATE_INSTANCE;
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.UPDATE_INSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.WORKFLOW_ACTION_ERROR_MESSAGE;
import java.io.IOException;
import java.util.ArrayList;
@@ -279,14 +282,14 @@ public class WorkflowAction {
List<Resource> resourceList = new ArrayList<>();
List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
- if (resourceType == WorkflowType.SERVICE) {
+ if (resourceType == WorkflowType.SERVICE || isVNFCreateOrDelete(resourceType, requestAction)) {
resourceList = serviceEBBLoader.getResourceListForService(sIRequest, requestAction, execution,
serviceInstanceId, resourceId, aaiResourceIds);
} else if (resourceType == WorkflowType.VNF && (REPLACEINSTANCE.equalsIgnoreCase(requestAction)
- || ("recreateInstance".equalsIgnoreCase(requestAction)))) {
+ || (RECREATE_INSTANCE.equalsIgnoreCase(requestAction)))) {
vnfEBBLoader.traverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
workflowResourceIds.getVnfId(), aaiResourceIds);
- } else if (resourceType == WorkflowType.VNF && "updateInstance".equalsIgnoreCase(requestAction)) {
+ } else if (resourceType == WorkflowType.VNF && UPDATE_INSTANCE.equalsIgnoreCase(requestAction)) {
vnfEBBLoader.customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
workflowResourceIds.getVnfId(), aaiResourceIds);
} else {
@@ -317,12 +320,12 @@ public class WorkflowAction {
}
// By default, enable homing at VNF level for CREATE_INSTANCE and ASSIGNINSTANCE
if (resourceType == WorkflowType.SERVICE
- && (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGNINSTANCE))
+ && (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGN_INSTANCE))
&& resourceList.stream().anyMatch(x -> WorkflowType.VNF.equals(x.getResourceType()))) {
execution.setVariable(HOMING, true);
execution.setVariable("calledHoming", false);
}
- if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase(ASSIGNINSTANCE)
+ if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase(ASSIGN_INSTANCE)
|| requestAction.equalsIgnoreCase(CREATE_INSTANCE))) {
generateResourceIds(flowsToExecute, resourceList, serviceInstanceId);
} else {
@@ -331,6 +334,11 @@ public class WorkflowAction {
return flowsToExecute;
}
+ private boolean isVNFCreateOrDelete(WorkflowType resourceType, String requestAction) {
+ return resourceType == WorkflowType.VNF
+ && (CREATE_INSTANCE.equalsIgnoreCase(requestAction) || DELETE_INSTANCE.equalsIgnoreCase(requestAction));
+ }
+
private void setExecutionVariables(DelegateExecution execution, List<ExecuteBuildingBlock> flowsToExecute,
List<String> flowNames) {
execution.setVariable("flowNames", flowNames);
@@ -887,7 +895,7 @@ public class WorkflowAction {
protected boolean isRequestMacroServiceResume(boolean aLaCarte, WorkflowType resourceType, String requestAction,
String serviceInstanceId) {
return (!aLaCarte && resourceType == WorkflowType.SERVICE
- && (requestAction.equalsIgnoreCase(ASSIGNINSTANCE) || requestAction.equalsIgnoreCase(CREATE_INSTANCE))
+ && (requestAction.equalsIgnoreCase(ASSIGN_INSTANCE) || requestAction.equalsIgnoreCase(CREATE_INSTANCE))
&& (serviceInstanceId != null && serviceInstanceId.trim().length() > 1)
&& (bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId) != null));
}
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 b2cc89545b..38ba0077e2 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
@@ -32,16 +32,23 @@ public final class WorkflowActionConstants {
throw new IllegalStateException("Utility class");
}
- public static final String USER_PARAM_SERVICE = "service";
+ public static final String ACTIVATE_INSTANCE = "activateInstance";
+ public static final String ASSIGN_INSTANCE = "assignInstance";
+ public static final String CONFIGURATION = "Configuration";
+ public static final String CONTROLLER = "Controller";
public static final String CREATE_INSTANCE = "createInstance";
+ public static final String DEACTIVATE_INSTANCE = "deactivateInstance";
+ public static final String DELETE_INSTANCE = "deleteInstance";
public static final String FABRIC_CONFIGURATION = "FabricConfiguration";
- public static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage";
- static final String SERVICE = "Service";
- static final String CONTROLLER = "Controller";
public static final String NETWORKCOLLECTION = "NetworkCollection";
- static final String CONFIGURATION = "Configuration";
- public static final String ASSIGNINSTANCE = "assignInstance";
- static final String REPLACEINSTANCE = "replaceInstance";
- static final String VOLUMEGROUP = "VolumeGroup";
- static final String REPLACEINSTANCERETAINASSIGNMENTS = "replaceInstanceRetainAssignments";
+ public static final String RECREATE_INSTANCE = "recreateInstance";
+ public static final String REPLACEINSTANCE = "replaceInstance";
+ public static final String REPLACEINSTANCERETAINASSIGNMENTS = "replaceInstanceRetainAssignments";
+ public static final String SERVICE = "Service";
+ public static final String UNASSIGN_INSTANCE = "unassignInstance";
+ public static final String UPDATE_INSTANCE = "updateInstance";
+ public static final String USER_PARAM_SERVICE = "service";
+ public static final String VOLUMEGROUP = "VolumeGroup";
+ public static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage";
+
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java
index 068c287ee7..6d02594c68 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java
@@ -35,12 +35,16 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ACTIVATE_INSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.DEACTIVATE_INSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.DELETE_INSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.UNASSIGN_INSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.WORKFLOW_ACTION_ERROR_MESSAGE;
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.USER_PARAM_SERVICE;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGNINSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGN_INSTANCE;
@Component
@@ -77,7 +81,7 @@ public class ServiceEBBLoader {
boolean containsService = false;
List<Resource> resourceList = new ArrayList<>();
List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams();
- if (requestAction.equalsIgnoreCase(ASSIGNINSTANCE)) {
+ if (requestAction.equalsIgnoreCase(ASSIGN_INSTANCE)) {
// SERVICE-MACRO-ASSIGN will always get user params with a
// service.
@@ -108,16 +112,15 @@ public class ServiceEBBLoader {
if (!foundRelated(resourceList)) {
traverseCatalogDbService(execution, sIRequest, resourceList, aaiResourceIds);
}
- } else if (("activateInstance".equalsIgnoreCase(requestAction)
- || "unassignInstance".equalsIgnoreCase(requestAction)
- || "deleteInstance".equalsIgnoreCase(requestAction)
+ } else if ((ACTIVATE_INSTANCE.equalsIgnoreCase(requestAction)
+ || UNASSIGN_INSTANCE.equalsIgnoreCase(requestAction) || DELETE_INSTANCE.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 ("deactivateInstance".equalsIgnoreCase(requestAction)) {
+ } else if (DEACTIVATE_INSTANCE.equalsIgnoreCase(requestAction)) {
resourceList.add(new Resource(WorkflowType.SERVICE, "", false));
}
return resourceList;