aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2021-01-05 21:02:12 +0000
committerGerrit Code Review <gerrit@onap.org>2021-01-05 21:02:12 +0000
commit0f3e475272176f4f6801767635cd1386abe27bbf (patch)
tree9e1ae35fe876514e7b529a35d57a3768746d4f21
parent1514e6f8fd5aec7f0929b1d4af64fbaeb5738e49 (diff)
parent5b347c5ed320e8df34b0e90a3e7b753fe66cbd43 (diff)
Merge "only add config create after activate is done"
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java40
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java86
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java62
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java4
4 files changed, 109 insertions, 83 deletions
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 662cad542c..7821463acd 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
@@ -577,30 +577,32 @@ public class WorkflowAction {
}
workflowIdsCopy.setConfigurationId(configuration.getConfigurationId());
for (OrchestrationFlow orchFlow : result) {
- if (!isReplace) {
- dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID);
- dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID);
- } else {
- if (orchFlow.getFlowName().contains("Delete")) {
+ if (!isReplace || (isReplace && (orchFlow.getFlowName().contains("Delete")))) {
+ if (!isReplace) {
dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID);
dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID);
} else {
- dataObj.getResourceKey().setVfModuleCustomizationId(replaceVfModuleCustomizationUUID);
- dataObj.getResourceKey().setVnfCustomizationId(replaceVnfModuleCustomizationUUID);
+ if (orchFlow.getFlowName().contains("Delete")) {
+ dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID);
+ dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID);
+ } else {
+ dataObj.getResourceKey().setVfModuleCustomizationId(replaceVfModuleCustomizationUUID);
+ dataObj.getResourceKey().setVnfCustomizationId(replaceVnfModuleCustomizationUUID);
+ }
}
+ dataObj.getResourceKey().setCvnfModuleCustomizationId(vnfc.getModelCustomizationId());
+ String vnfcName = vnfc.getVnfcName();
+ if (vnfcName == null || vnfcName.isEmpty()) {
+ buildAndThrowException(dataObj.getExecution(), "Exception in create execution list "
+ + ": 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);
+ flowsToExecuteConfigs.add(ebb);
}
- dataObj.getResourceKey().setCvnfModuleCustomizationId(vnfc.getModelCustomizationId());
- String vnfcName = vnfc.getVnfcName();
- if (vnfcName == null || vnfcName.isEmpty()) {
- buildAndThrowException(dataObj.getExecution(), "Exception in create execution list "
- + ": 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);
- flowsToExecuteConfigs.add(ebb);
}
}
return flowsToExecuteConfigs;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
index 554385d043..b756772188 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
@@ -52,6 +52,9 @@ import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RelatedInstance;
+import org.onap.so.serviceinstancebeans.RelatedInstanceList;
import org.onap.so.serviceinstancebeans.RequestReferences;
import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
import org.slf4j.Logger;
@@ -437,54 +440,53 @@ public class WorkflowActionBBTasks {
String vnfId = ebb.getWorkflowResourceIds().getVnfId();
String vfModuleId = ebb.getResourceId();
ebb.getWorkflowResourceIds().setVfModuleId(vfModuleId);
- String serviceModelUUID =
- bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId).getModelVersionId();
- String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
- String vfModuleCustomizationUUID =
- bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId).getModelCustomizationId();
+ String serviceModelUUID = "";
+ String vnfCustomizationUUID = "";
+ String vfModuleCustomizationUUID = "";
+ if (requestAction.equalsIgnoreCase("replaceInstance")
+ || requestAction.equalsIgnoreCase("replaceInstanceRetainAssignments")) {
+ for (RelatedInstanceList relatedInstList : ebb.getRequestDetails().getRelatedInstanceList()) {
+ RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
+ if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) {
+ vnfCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId();
+ }
+ if (relatedInstance.getModelInfo().getModelType().equals(ModelType.service)) {
+ serviceModelUUID = relatedInstance.getModelInfo().getModelVersionId();
+ }
+ }
+ vfModuleCustomizationUUID = ebb.getRequestDetails().getModelInfo().getModelCustomizationId();
+ } else {
+ serviceModelUUID = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId).getModelVersionId();
+ vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
+ vfModuleCustomizationUUID =
+ bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId).getModelCustomizationId();
+ }
List<Vnfc> vnfcs = workflowAction.getRelatedResourcesInVfModule(vnfId, vfModuleId, Vnfc.class, Types.VNFC);
logger.debug("Vnfc Size: {}", vnfcs.size());
for (Vnfc vnfc : vnfcs) {
String modelCustomizationId = vnfc.getModelCustomizationId();
logger.debug("Processing Vnfc: {}", modelCustomizationId);
- if (requestAction.equalsIgnoreCase("replaceInstance")
- || requestAction.equalsIgnoreCase("replaceInstanceRetainAssignments")) {
- List<ExecuteBuildingBlock> configBBs = flowsToExecute.stream()
- .filter(item -> item.getBuildingBlock().getBpmnFlowName().matches(CONFIGURATION_PATTERN))
- .collect(Collectors.toList());
- if (configBBs != null && configBBs.size() > 0) {
- for (ExecuteBuildingBlock bb : configBBs) {
- if (bb.getConfigurationResourceKeys() != null) {
- bb.getConfigurationResourceKeys().setCvnfcCustomizationUUID(modelCustomizationId);
- bb.getConfigurationResourceKeys().setVnfcName(vnfc.getVnfcName());
- }
- }
- execution.setVariable("flowsToExecute", flowsToExecute);
- execution.setVariable(COMPLETED, false);
- }
+ CvnfcConfigurationCustomization fabricConfig = catalogDbClient.getCvnfcCustomization(serviceModelUUID,
+ vnfCustomizationUUID, vfModuleCustomizationUUID, modelCustomizationId);
+ if (fabricConfig != null && fabricConfig.getConfigurationResource() != null
+ && fabricConfig.getConfigurationResource().getToscaNodeType() != null
+ && fabricConfig.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) {
+ String configurationId = getConfigurationId(vnfc);
+ ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
+ configurationResourceKeys.setCvnfcCustomizationUUID(modelCustomizationId);
+ configurationResourceKeys.setVfModuleCustomizationUUID(vfModuleCustomizationUUID);
+ configurationResourceKeys.setVnfResourceCustomizationUUID(vnfCustomizationUUID);
+ configurationResourceKeys.setVnfcName(vnfc.getVnfcName());
+ ExecuteBuildingBlock addConfigBB = getExecuteBBForConfig(ADD_FABRIC_CONFIGURATION_BB, ebb,
+ configurationId, configurationResourceKeys);
+ flowsToExecute.add(addConfigBB);
+ flowsToExecute.stream()
+ .forEach(executeBB -> logger.info("Flows to Execute After Post Processing: {}",
+ executeBB.getBuildingBlock().getBpmnFlowName()));
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ execution.setVariable(COMPLETED, false);
} else {
- CvnfcConfigurationCustomization fabricConfig = catalogDbClient.getCvnfcCustomization(
- serviceModelUUID, vnfCustomizationUUID, vfModuleCustomizationUUID, modelCustomizationId);
- if (fabricConfig != null && fabricConfig.getConfigurationResource() != null
- && fabricConfig.getConfigurationResource().getToscaNodeType() != null && fabricConfig
- .getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) {
- String configurationId = getConfigurationId(vnfc);
- ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
- configurationResourceKeys.setCvnfcCustomizationUUID(modelCustomizationId);
- configurationResourceKeys.setVfModuleCustomizationUUID(vfModuleCustomizationUUID);
- configurationResourceKeys.setVnfResourceCustomizationUUID(vnfCustomizationUUID);
- configurationResourceKeys.setVnfcName(vnfc.getVnfcName());
- ExecuteBuildingBlock addConfigBB = getExecuteBBForConfig(ADD_FABRIC_CONFIGURATION_BB, ebb,
- configurationId, configurationResourceKeys);
- flowsToExecute.add(addConfigBB);
- flowsToExecute.stream()
- .forEach(executeBB -> logger.info("Flows to Execute After Post Processing: {}",
- executeBB.getBuildingBlock().getBpmnFlowName()));
- execution.setVariable("flowsToExecute", flowsToExecute);
- execution.setVariable(COMPLETED, false);
- } else {
- logger.debug("No cvnfcCustomization found for customizationId: {}", modelCustomizationId);
- }
+ logger.debug("No cvnfcCustomization found for customizationId: {}", modelCustomizationId);
}
}
} catch (EntityNotFoundException e) {
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
index b7529bdeb8..5cd3055b5f 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
@@ -22,6 +22,22 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
@@ -48,31 +64,16 @@ 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.client.namingservice.NamingRequestObject;
import org.onap.so.db.catalog.beans.ConfigurationResource;
import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RelatedInstance;
+import org.onap.so.serviceinstancebeans.RelatedInstanceList;
import org.onap.so.serviceinstancebeans.RequestDetails;
import org.springframework.core.env.Environment;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyObject;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.isA;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
public class WorkflowActionBBTasksTest extends BaseTaskTest {
@@ -680,7 +681,28 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
@Test
public void postProcessingExecuteBBActivateVfModuleReplaceInstanceHasConfigurationTest()
throws CloneNotSupportedException {
-
+ RequestDetails reqDetails = new RequestDetails();
+ RelatedInstanceList[] list = new RelatedInstanceList[2];
+ RelatedInstanceList vnfList = new RelatedInstanceList();
+ RelatedInstanceList serviceList = new RelatedInstanceList();
+ list[0] = vnfList;
+ list[1] = serviceList;
+ RelatedInstance vnfInstance = new RelatedInstance();
+ RelatedInstance serviceInstance = new RelatedInstance();
+ ModelInfo vnfModelInfo = new ModelInfo();
+ vnfModelInfo.setModelType(ModelType.vnf);
+ vnfModelInfo.setModelCustomizationId("1");
+ ModelInfo serviceModelInfo = new ModelInfo();
+ serviceModelInfo.setModelType(ModelType.service);
+ serviceModelInfo.setModelVersionId("1");
+ vnfInstance.setModelInfo(vnfModelInfo);
+ serviceInstance.setModelInfo(serviceModelInfo);
+ reqDetails.setRelatedInstanceList(list);
+ vnfList.setRelatedInstance(vnfInstance);
+ serviceList.setRelatedInstance(serviceInstance);
+ ModelInfo vfModuleInfo = new ModelInfo();
+ vfModuleInfo.setModelCustomizationId("1");
+ reqDetails.setModelInfo(vfModuleInfo);
BuildingBlock bbAddFabric = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB");
ExecuteBuildingBlock ebbAddFabric = new ExecuteBuildingBlock().setBuildingBlock(bbAddFabric);
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
@@ -695,6 +717,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
ebbActivateVfModule.setResourceId("1");
ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
ebbAddFabric.setConfigurationResourceKeys(configurationResourceKeys);
+ ebbActivateVfModule.setRequestDetails(reqDetails);
ServiceInstance service = new ServiceInstance();
service.setServiceInstanceName("name");
@@ -730,7 +753,6 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
prepareDelegateExecution();
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
flowsToExecute.add(ebbActivateVfModule);
- flowsToExecute.add(ebbAddFabric);
ArgumentCaptor<DelegateExecution> executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class);
ArgumentCaptor<ExecuteBuildingBlock> bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class);
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 5f9356d066..c916e09c79 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
@@ -1258,8 +1258,8 @@ public class WorkflowActionTest extends BaseTaskTest {
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "DeleteFabricConfigurationBB", "DeactivateVfModuleBB", "DeleteVfModuleATTBB",
- "UnassignVFModuleBB", "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB",
- "AddFabricConfigurationBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
+ "UnassignVFModuleBB", "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB",
+ "ChangeModelServiceInstanceBB");
}
@Test