aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java1
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java10
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java55
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java92
4 files changed, 136 insertions, 22 deletions
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 3f78152a49..2f6713dcd1 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
@@ -1622,6 +1622,7 @@ public class BBInputSetup implements JavaDelegate {
parameter.setInstanceName(vfModules.getInstanceName());
parameter.setInstanceParams(vfModules.getInstanceParams());
this.populateVfModule(parameter);
+ gBB.getRequestContext().setIsHelm(parameter.getIsHelm());
}
} else if (bbName.contains(NETWORK)) {
networks = findNetworksByKey(key, resources);
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java
index 692d581b0d..f67af20ef1 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java
@@ -22,9 +22,9 @@ package org.onap.so.client.restproperties;
import java.net.MalformedURLException;
import java.net.URL;
-import org.onap.so.bpmn.core.UrnPropertiesReader;
import org.onap.aaiclient.client.aai.AAIProperties;
import org.onap.aaiclient.client.aai.AAIVersion;
+import org.onap.so.bpmn.core.UrnPropertiesReader;
import org.springframework.stereotype.Component;
@Component
@@ -33,6 +33,8 @@ public class AAIPropertiesImpl implements AAIProperties {
public static final String MSO_MSO_KEY = "mso.msoKey";
public static final String AAI_AUTH = "aai.auth";
public static final String AAI_ENDPOINT = "aai.endpoint";
+ public static final String AAI_READ_TIMEOUT = "aai.readTimeout";
+ private UrnPropertiesReader reader;
@Override
public URL getEndpoint() throws MalformedURLException {
@@ -58,4 +60,10 @@ public class AAIPropertiesImpl implements AAIProperties {
public String getKey() {
return UrnPropertiesReader.getVariable(MSO_MSO_KEY);
}
+
+ @Override
+ public Long getReadTimeout() {
+ return Long.valueOf(reader.getVariable(AAI_READ_TIMEOUT, "60000"));
+ }
+
}
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 df82142f39..5e281cff87 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
@@ -78,6 +78,7 @@ public class WorkflowActionBBTasks {
private static final String ROLLBACKTOCREATEDNOCONFIGURATION = "RollbackToCreatedNoConfiguration";
private static final String REPLACEINSTANCE = "replaceInstance";
private static final String VFMODULE = "VfModule";
+ private static final String CONFIGURATION_PATTERN = "(Ad|De)(.*)FabricConfiguration(.*)";
protected String maxRetries = "mso.rainyDay.maxRetries";
private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBTasks.class);
@@ -421,12 +422,9 @@ public class WorkflowActionBBTasks {
String handlingCode = (String) execution.getVariable(HANDLINGCODE);
final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE);
int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
- String requestAction = (String) execution.getVariable(G_ACTION);
ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence - 1);
String bbFlowName = ebb.getBuildingBlock().getBpmnFlowName();
- if ("ActivateVfModuleBB".equalsIgnoreCase(bbFlowName) && aLaCarte && "Success".equalsIgnoreCase(handlingCode)
- && !(requestAction.equalsIgnoreCase("replaceInstance")
- || requestAction.equalsIgnoreCase("replaceInstanceRetainAssignments"))) {
+ if ("ActivateVfModuleBB".equalsIgnoreCase(bbFlowName) && aLaCarte && "Success".equalsIgnoreCase(handlingCode)) {
postProcessingExecuteBBActivateVfModule(execution, ebb, flowsToExecute);
}
}
@@ -434,6 +432,7 @@ public class WorkflowActionBBTasks {
protected void postProcessingExecuteBBActivateVfModule(DelegateExecution execution, ExecuteBuildingBlock ebb,
List<ExecuteBuildingBlock> flowsToExecute) {
try {
+ String requestAction = (String) execution.getVariable(G_ACTION);
String serviceInstanceId = ebb.getWorkflowResourceIds().getServiceInstanceId();
String vnfId = ebb.getWorkflowResourceIds().getVnfId();
String vfModuleId = ebb.getResourceId();
@@ -448,26 +447,40 @@ public class WorkflowActionBBTasks {
for (Vnfc vnfc : vnfcs) {
String modelCustomizationId = vnfc.getModelCustomizationId();
logger.debug("Processing Vnfc: {}", modelCustomizationId);
- 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.forEach(executeBB -> logger.info("Flows to Execute After Post Processing: {}",
- executeBB.getBuildingBlock().getBpmnFlowName()));
+ if (requestAction.equalsIgnoreCase("replaceInstance")
+ || requestAction.equalsIgnoreCase("replaceInstanceRetainAssignments")) {
+ List<ExecuteBuildingBlock> configBBs = flowsToExecute.stream()
+ .filter(item -> !item.getBuildingBlock().getBpmnFlowName().matches(CONFIGURATION_PATTERN))
+ .collect(Collectors.toList());
+ for (ExecuteBuildingBlock bb : configBBs) {
+ bb.getConfigurationResourceKeys().setCvnfcCustomizationUUID(modelCustomizationId);
+ bb.getConfigurationResourceKeys().setVnfcName(vnfc.getVnfcName());
+ }
execution.setVariable("flowsToExecute", flowsToExecute);
execution.setVariable(COMPLETED, false);
} else {
- logger.debug("No cvnfcCustomization found for customizationId: {}", modelCustomizationId);
+ 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);
+ }
}
}
} 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 3290bb3dce..0384a28cdc 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
@@ -29,6 +29,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
@@ -47,23 +48,30 @@ 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.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 {
@@ -96,6 +104,9 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
+ @Mock
+ private DelegateExecution mockExecution;
+
@Before
public void before() throws Exception {
execution = new DelegateExecutionFake();
@@ -603,6 +614,87 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
@Test
public void postProcessingExecuteBBActivateVfModuleTest() throws CloneNotSupportedException {
+
+ BuildingBlock bbAddFabric = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB");
+ ExecuteBuildingBlock ebbAddFabric = new ExecuteBuildingBlock().setBuildingBlock(bbAddFabric);
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ workflowResourceIds.setServiceInstanceId("1");
+ workflowResourceIds.setVnfId("1");
+ ebbAddFabric.setWorkflowResourceIds(workflowResourceIds);
+ ebbAddFabric.setResourceId("1");
+
+ BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
+ ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule);
+ ebbActivateVfModule.setWorkflowResourceIds(workflowResourceIds);
+ ebbActivateVfModule.setResourceId("1");
+ ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
+ ebbActivateVfModule.setConfigurationResourceKeys(configurationResourceKeys);
+
+ ServiceInstance service = new ServiceInstance();
+ service.setServiceInstanceName("name");
+ service.setModelVersionId("1");
+ doReturn(service).when(bbSetupUtils).getAAIServiceInstanceById("1");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfName("name");
+ vnf.setModelCustomizationId("1");
+ doReturn(vnf).when(bbSetupUtils).getAAIGenericVnf("1");
+
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleName("name");
+ vfModule.setModelCustomizationId("1");
+ doReturn(vfModule).when(bbSetupUtils).getAAIVfModule("1", "1");
+
+ List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
+ org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+ vnfc.setModelInvariantId("1");
+ vnfc.setVnfcName("name");
+ vnfc.setModelCustomizationId("2");
+ vnfcs.add(vnfc);
+ doReturn(vnfcs).when(workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any());
+
+ CvnfcConfigurationCustomization vfModuleCustomization = new CvnfcConfigurationCustomization();
+ ConfigurationResource configuration = new ConfigurationResource();
+ configuration.setToscaNodeType("FabricConfiguration");
+ configuration.setModelUUID("1");
+ vfModuleCustomization.setConfigurationResource(configuration);
+
+ doReturn(vfModuleCustomization).when(catalogDbClient).getCvnfcCustomization("1", "1", "1", "2");
+
+ prepareDelegateExecution();
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+ flowsToExecute.add(ebbActivateVfModule);
+
+ ArgumentCaptor<DelegateExecution> executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class);
+ ArgumentCaptor<ExecuteBuildingBlock> bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class);
+ ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
+ workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbAddFabric, flowsToExecute);
+ verify(workflowActionBBTasks, times(1)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(),
+ bbCaptor.capture(), listCaptor.capture());
+ assertEquals(false, executionCaptor.getAllValues().get(0).getVariable("completed"));
+ assertEquals(2, ((ArrayList) executionCaptor.getAllValues().get(0).getVariable("flowsToExecute")).size());
+ assertEquals(null,
+ ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues().get(0)
+ .getVariable("flowsToExecute")).get(0)).getConfigurationResourceKeys()
+ .getCvnfcCustomizationUUID());
+
+
+ execution.setVariable("requestAction", "replaceInstance");
+ flowsToExecute = new ArrayList<>();
+ flowsToExecute.add(ebbActivateVfModule);
+ workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbActivateVfModule, flowsToExecute);
+ verify(workflowActionBBTasks, times(2)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(),
+ bbCaptor.capture(), listCaptor.capture());
+ assertEquals(false, executionCaptor.getAllValues().get(0).getVariable("completed"));
+ assertEquals(1, ((ArrayList) executionCaptor.getAllValues().get(0).getVariable("flowsToExecute")).size());
+ assertEquals("2",
+ ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues().get(0)
+ .getVariable("flowsToExecute")).get(0)).getConfigurationResourceKeys()
+ .getCvnfcCustomizationUUID());
+ }
+
+ @Test
+ public void getExecuteBBForConfigTest() throws CloneNotSupportedException {
BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule);