summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql35
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java14
-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
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilderTest.java37
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ResourceTest.java55
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java3
10 files changed, 160 insertions, 96 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
index c64ec25492..77b3533158 100644
--- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
@@ -17,10 +17,12 @@ INSERT INTO northbound_request_ref_lookup(MACRO_ACTION, ACTION, REQUEST_SCOPE, I
('Service-Macro-Delete', 'deleteInstance', 'Service', false,true, '7','7', 'DEFAULT', '*'),
('Network-Create', 'createInstance', 'Network', true,true, '7','7', 'DEFAULT', '*'),
('Network-Delete', 'deleteInstance', 'Network', true,true, '7','7', 'DEFAULT', '*'),
+('VNF-Macro-Create', 'createInstance', 'Vnf', false,true, '7','7', 'DEFAULT', '*'),
('VNF-Macro-Recreate', 'recreateInstance', 'Vnf', false,true, '7','7', 'DEFAULT', '*'),
('VNF-Macro-Replace', 'replaceInstance', 'Vnf', false,true, '7','7', 'DEFAULT', '*'),
('VNF-Create', 'createInstance', 'Vnf', true,true, '7', '7', 'DEFAULT', '*'),
('VNF-Delete', 'deleteInstance', 'Vnf', true,true, '7', '7', 'DEFAULT', '*'),
+('VNF-Macro-Delete', 'deleteInstance', 'Vnf', false,true, '7', '7', 'DEFAULT', '*'),
('VolumeGroup-Create', 'createInstance', 'VolumeGroup', true,true, '7','7', 'DEFAULT', '*'),
('VolumeGroup-Delete', 'deleteInstance', 'VolumeGroup', true,true, '7','7', 'DEFAULT', '*'),
('VFModule-Create', 'createInstance', 'VfModule', true,true, '7','7', 'DEFAULT', '*'),
@@ -111,6 +113,37 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FL
('VNF-Create', '2', 'ActivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Create' and CLOUD_OWNER = 'DEFAULT')),
('VNF-Delete', '1', 'DeactivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Delete' and CLOUD_OWNER = 'DEFAULT')),
('VNF-Delete', '2', 'UnassignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Create', '1', 'CreateNetworkCollectionBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Create', '2', 'AssignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Create', '3', 'AssignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Create', '4', 'AssignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Create', '5', 'AssignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Create', '6', 'ConfigAssignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Create', '7', 'AssignPnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Create', '8', 'WaitForPnfReadyBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Create', '9', 'ActivatePnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Create', '10', 'CreateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Create', '11', 'ActivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Create', '12', 'CreateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Create', '13', 'ActivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Create', '14', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Create', '15', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Create', '16', 'ConfigDeployVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Create', '17', 'ActivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Create', '18', 'ActivateNetworkCollectionBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Delete', '1', 'DeactivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Delete', '2', 'DeleteVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Delete', '3', 'DeactivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Delete', '4', 'DeleteVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Delete', '5', 'DeactivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Delete', '6', 'DeactivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Delete', '7', 'DeleteNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Delete', '8', 'DeactivateNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Delete', '9', 'DeleteNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Delete', '10', 'UnassignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Delete', '11', 'UnassignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Delete', '12', 'UnassignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('VNF-Macro-Delete', '13', 'UnassignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
('VNF-Macro-Recreate', '1', 'AAICheckVnfInMaintBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Recreate' and CLOUD_OWNER = 'DEFAULT')),
('VNF-Macro-Recreate', '2', 'AAISetVnfInMaintBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Recreate' and CLOUD_OWNER = 'DEFAULT')),
('VNF-Macro-Recreate', '3', 'DeactivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Recreate' and CLOUD_OWNER = 'DEFAULT')),
@@ -955,5 +988,7 @@ VALUES
UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vnf', ACTION='config-assign' WHERE COMPOSITE_ACTION = 'Service-Macro-Create' and FLOW_NAME = 'ConfigAssignVnfBB';
UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vnf', ACTION='config-deploy' WHERE COMPOSITE_ACTION = 'Service-Macro-Create' and FLOW_NAME = 'ConfigDeployVnfBB';
+UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vnf', ACTION='config-assign' WHERE COMPOSITE_ACTION = 'VNF-Macro-Create' and FLOW_NAME = 'ConfigAssignVnfBB';
+UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vnf', ACTION='config-deploy' WHERE COMPOSITE_ACTION = 'VNF-Macro-Create' and FLOW_NAME = 'ConfigDeployVnfBB';
UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vnf', ACTION='HealthCheck' WHERE COMPOSITE_ACTION = 'VFModule-ScaleOut' and FLOW_NAME = 'GenericVnfHealthCheckBB';
UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vfmodule', ACTION='ScaleOutReconfiguration' WHERE COMPOSITE_ACTION = 'VFModule-ScaleOut' and FLOW_NAME = 'GenericVnfHealthCheckBB';
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
index 5cbadd6b75..83d1f5249f 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
@@ -1054,8 +1054,18 @@ public class BBInputSetup implements JavaDelegate {
if (requestDetails.getOwningEntity() != null)
owningEntity = mapperLayer.mapRequestOwningEntity(requestDetails.getOwningEntity());
- Service service =
- bbInputSetupUtils.getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId());
+ String modelVersionId = requestDetails.getModelInfo().getModelVersionId();
+
+ if (ModelType.vnf == requestDetails.getModelInfo().getModelType()) {
+ for (RelatedInstanceList relatedInstanceList : requestDetails.getRelatedInstanceList()) {
+ if (ModelType.service == relatedInstanceList.getRelatedInstance().getModelInfo().getModelType()) {
+ modelVersionId = relatedInstanceList.getRelatedInstance().getModelInfo().getModelVersionId();
+ break;
+ }
+ }
+ }
+
+ Service service = bbInputSetupUtils.getCatalogServiceByModelUUID(modelVersionId);
if (service == null) {
service = bbInputSetupUtils.getCatalogServiceByModelVersionAndModelInvariantUUID(
requestDetails.getModelInfo().getModelVersion(),
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;
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
index fae2317c8d..cc3da9952a 100644
--- 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
@@ -41,43 +41,6 @@ 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 {
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ResourceTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ResourceTest.java
new file mode 100644
index 0000000000..5e3afa16ac
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ResourceTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Bell Canada. All rights reserved.
+ * ================================================================================
+ * 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 static org.junit.Assert.assertEquals;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.junit.Test;
+
+public class ResourceTest {
+
+ @Test
+ public void testBaseFirstComparator() {
+ Resource r1 = new Resource(null, "1", false);
+ Resource r2 = new Resource(null, "2", false);
+ r2.setBaseVfModule(true);
+
+ List<Resource> sorted =
+ Arrays.asList(r1, r2).stream().sorted(Resource.sortBaseFirst).collect(Collectors.toList());
+
+ assertEquals("2", sorted.get(0).getResourceId());
+ }
+
+ @Test
+ public void testBaseLastComparator() {
+ Resource r1 = new Resource(null, "1", false);
+ Resource r2 = new Resource(null, "2", false);
+ r1.setBaseVfModule(true);
+
+ List<Resource> sorted =
+ Arrays.asList(r1, r2).stream().sorted(Resource.sortBaseLast).collect(Collectors.toList());
+
+ assertEquals("1", sorted.get(1).getResourceId());
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
index 9a4d0a45df..bcbc7c7ca6 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
@@ -935,8 +935,7 @@ public class ServiceInstances extends AbstractRestHandler {
}
if (!requestScope.equalsIgnoreCase(ModelType.service.name()) && action != Action.recreateInstance
- && !(requestScope.equalsIgnoreCase(ModelType.vnf.name())
- && (action == Action.replaceInstance || action == Action.replaceInstanceRetainAssignments))) {
+ && !requestScope.equalsIgnoreCase(ModelType.vnf.name())) {
aLaCarte = true;
} else if (aLaCarte == null) {
aLaCarte = false;