aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java118
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java185
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java5
4 files changed, 196 insertions, 114 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 d1da38f2d9..ee4e56bc18 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
@@ -46,6 +46,7 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
import org.onap.so.bpmn.common.BBConstants;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader.VnfEBBLoader;
import org.onap.so.bpmn.infrastructure.workflow.tasks.excpetion.VnfcMultipleRelationshipException;
import org.onap.so.bpmn.infrastructure.workflow.tasks.utils.WorkflowResourceIdsUtils;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
@@ -143,6 +144,8 @@ public class WorkflowAction {
private AaiResourceIdValidator aaiResourceIdValidator;
@Autowired
private ExecuteBuildingBlockBuilder executeBuildingBlockBuilder;
+ @Autowired
+ private VnfEBBLoader vnfEBBLoader;
public void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils) {
this.bbInputSetupUtils = bbInputSetupUtils;
@@ -340,10 +343,10 @@ public class WorkflowAction {
resourceList.add(new Resource(WorkflowType.SERVICE, "", false));
} else if (resourceType == WorkflowType.VNF && (REPLACEINSTANCE.equalsIgnoreCase(requestAction)
|| ("recreateInstance".equalsIgnoreCase(requestAction)))) {
- traverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
+ vnfEBBLoader.traverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
workflowResourceIds.getVnfId(), aaiResourceIds);
} else if (resourceType == WorkflowType.VNF && "updateInstance".equalsIgnoreCase(requestAction)) {
- customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
+ vnfEBBLoader.customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
workflowResourceIds.getVnfId(), aaiResourceIds);
} else {
buildAndThrowException(execution, "Current Macro Request is not supported");
@@ -404,8 +407,6 @@ public class WorkflowAction {
return containsService;
}
-
-
private List<ExecuteBuildingBlock> loadExecuteBuildingBlocks(DelegateExecution execution, String requestId,
String errorMessage) {
List<ExecuteBuildingBlock> flowsToExecute;
@@ -1092,116 +1093,7 @@ public class WorkflowAction {
}
}
- private void traverseAAIVnf(DelegateExecution execution, List<Resource> resourceList, String serviceId,
- String vnfId, List<Pair<WorkflowType, String>> aaiResourceIds) {
- try {
- ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceId);
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
- bbInputSetup.getExistingServiceInstance(serviceInstanceAAI);
- resourceList.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false));
- if (serviceInstanceMSO.getVnfs() != null) {
- for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) {
- if (vnf.getVnfId().equals(vnfId)) {
- aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId()));
- resourceList.add(new Resource(WorkflowType.VNF, vnf.getVnfId(), false));
- if (vnf.getVfModules() != null) {
- for (VfModule vfModule : vnf.getVfModules()) {
- aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId()));
- resourceList.add(new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false));
- findConfigurationsInsideVfModule(execution, vnf.getVnfId(), vfModule.getVfModuleId(),
- resourceList, aaiResourceIds);
- }
- }
- if (vnf.getVolumeGroups() != null) {
- for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf
- .getVolumeGroups()) {
- aaiResourceIds
- .add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId()));
- resourceList.add(
- new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false));
- }
- }
- break;
- }
- }
- }
- } catch (Exception ex) {
- logger.error("Exception in traverseAAIVnf", ex);
- buildAndThrowException(execution,
- "Could not find existing Vnf or related Instances to execute the request on.");
- }
- }
-
- private void customTraverseAAIVnf(DelegateExecution execution, List<Resource> resourceList, String serviceId,
- String vnfId, List<Pair<WorkflowType, String>> aaiResourceIds) {
- try {
- ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceId);
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
- bbInputSetup.getExistingServiceInstance(serviceInstanceAAI);
- resourceList.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false));
- if (serviceInstanceMSO.getVnfs() != null) {
- for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) {
- if (vnf.getVnfId().equals(vnfId)) {
- aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId()));
-
- String vnfCustomizationUUID =
- bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
- resourceList.add(new Resource(WorkflowType.VNF, vnfCustomizationUUID, false));
-
- if (vnf.getVfModules() != null) {
- for (VfModule vfModule : vnf.getVfModules()) {
- aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId()));
- resourceList.add(new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false));
- findConfigurationsInsideVfModule(execution, vnf.getVnfId(), vfModule.getVfModuleId(),
- resourceList, aaiResourceIds);
- }
- }
- if (vnf.getVolumeGroups() != null) {
- for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf
- .getVolumeGroups()) {
- aaiResourceIds
- .add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId()));
- resourceList.add(
- new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false));
- }
- }
- break;
- }
- }
- }
- } catch (Exception ex) {
- logger.error("Exception in customTraverseAAIVnf", ex);
- buildAndThrowException(execution,
- "Could not find existing Vnf or related Instances to execute the request on.");
- }
-
- }
- private void findConfigurationsInsideVfModule(DelegateExecution execution, String vnfId, String vfModuleId,
- List<Resource> resourceList, List<Pair<WorkflowType, String>> aaiResourceIds) {
- try {
- org.onap.aai.domain.yang.VfModule aaiVfModule = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId);
- AAIResultWrapper vfModuleWrapper = new AAIResultWrapper(
- new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiVfModule));
- Optional<Relationships> relationshipsOp;
- relationshipsOp = vfModuleWrapper.getRelationships();
- if (relationshipsOp.isPresent()) {
- relationshipsOp = workflowActionUtils.extractRelationshipsVnfc(relationshipsOp.get());
- if (relationshipsOp.isPresent()) {
- Optional<Configuration> config =
- workflowActionUtils.extractRelationshipsConfiguration(relationshipsOp.get());
- if (config.isPresent()) {
- aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, config.get().getConfigurationId()));
- resourceList.add(
- new Resource(WorkflowType.CONFIGURATION, config.get().getConfigurationId(), false));
- }
- }
- }
- } catch (Exception ex) {
- logger.error("Exception in findConfigurationsInsideVfModule", ex);
- buildAndThrowException(execution, "Failed to find Configuration object from the vfModule.");
- }
- }
protected WorkflowResourceIds populateResourceIdsFromApiHandler(DelegateExecution execution) {
return WorkflowResourceIdsUtils.getWorkflowResourceIdsFromExecution(execution);
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 5e16097304..9128e9e3e1 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
@@ -35,7 +35,7 @@ public final class WorkflowActionConstants {
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";
+ public static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage";
static final String SERVICE = "Service";
static final String CONTROLLER = "Controller";
static final String NETWORKCOLLECTION = "NetworkCollection";
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java
new file mode 100644
index 0000000000..7db93e7979
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java
@@ -0,0 +1,185 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Nokia
+ * ================================================================================
+ * 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.ebb.loader;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.javatuples.Pair;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider;
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
+import org.onap.aaiclient.client.aai.entities.Relationships;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionExtractResourcesAAI;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
+import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
+import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import java.util.List;
+import java.util.Optional;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.WORKFLOW_ACTION_ERROR_MESSAGE;
+
+@Component
+public class VnfEBBLoader {
+
+ private static final Logger logger = LoggerFactory.getLogger(VnfEBBLoader.class);
+
+ private final BBInputSetupUtils bbInputSetupUtils;
+ private final BBInputSetup bbInputSetup;
+ private final WorkflowActionExtractResourcesAAI workflowActionUtils;
+ private final ExceptionBuilder exceptionBuilder;
+
+ VnfEBBLoader(BBInputSetupUtils bbInputSetupUtils, BBInputSetup bbInputSetup,
+ WorkflowActionExtractResourcesAAI workflowActionUtils, ExceptionBuilder exceptionBuilder) {
+ this.bbInputSetupUtils = bbInputSetupUtils;
+ this.bbInputSetup = bbInputSetup;
+ this.workflowActionUtils = workflowActionUtils;
+ this.exceptionBuilder = exceptionBuilder;
+ }
+
+
+ public void traverseAAIVnf(DelegateExecution execution, List<Resource> resourceList, String serviceId, String vnfId,
+ List<Pair<WorkflowType, String>> aaiResourceIds) {
+ try {
+ ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceId);
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
+ bbInputSetup.getExistingServiceInstance(serviceInstanceAAI);
+ resourceList.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false));
+ if (serviceInstanceMSO.getVnfs() != null) {
+ for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) {
+ if (vnf.getVnfId().equals(vnfId)) {
+ aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId()));
+ resourceList.add(new Resource(WorkflowType.VNF, vnf.getVnfId(), false));
+ if (vnf.getVfModules() != null) {
+ for (VfModule vfModule : vnf.getVfModules()) {
+ aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId()));
+ resourceList.add(new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false));
+ findConfigurationsInsideVfModule(execution, vnf.getVnfId(), vfModule.getVfModuleId(),
+ resourceList, aaiResourceIds);
+ }
+ }
+ if (vnf.getVolumeGroups() != null) {
+ for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf
+ .getVolumeGroups()) {
+ aaiResourceIds
+ .add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId()));
+ resourceList.add(
+ new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false));
+ }
+ }
+ break;
+ }
+ }
+ }
+ } catch (Exception ex) {
+ logger.error("Exception in traverseAAIVnf", ex);
+ buildAndThrowException(execution,
+ "Could not find existing Vnf or related Instances to execute the request on.");
+ }
+ }
+
+ public void customTraverseAAIVnf(DelegateExecution execution, List<Resource> resourceList, String serviceId,
+ String vnfId, List<Pair<WorkflowType, String>> aaiResourceIds) {
+ try {
+ ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceId);
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
+ bbInputSetup.getExistingServiceInstance(serviceInstanceAAI);
+ resourceList.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false));
+ if (serviceInstanceMSO.getVnfs() != null) {
+ for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) {
+ if (vnf.getVnfId().equals(vnfId)) {
+ aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId()));
+
+ String vnfCustomizationUUID =
+ bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
+ resourceList.add(new Resource(WorkflowType.VNF, vnfCustomizationUUID, false));
+
+ if (vnf.getVfModules() != null) {
+ for (VfModule vfModule : vnf.getVfModules()) {
+ aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId()));
+ resourceList.add(new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false));
+ findConfigurationsInsideVfModule(execution, vnf.getVnfId(), vfModule.getVfModuleId(),
+ resourceList, aaiResourceIds);
+ }
+ }
+ if (vnf.getVolumeGroups() != null) {
+ for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf
+ .getVolumeGroups()) {
+ aaiResourceIds
+ .add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId()));
+ resourceList.add(
+ new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false));
+ }
+ }
+ break;
+ }
+ }
+ }
+ } catch (Exception ex) {
+ logger.error("Exception in customTraverseAAIVnf", ex);
+ buildAndThrowException(execution,
+ "Could not find existing Vnf or related Instances to execute the request on.");
+ }
+
+ }
+
+ private void findConfigurationsInsideVfModule(DelegateExecution execution, String vnfId, String vfModuleId,
+ List<Resource> resourceList, List<Pair<WorkflowType, String>> aaiResourceIds) {
+ try {
+ org.onap.aai.domain.yang.VfModule aaiVfModule = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId);
+ AAIResultWrapper vfModuleWrapper = new AAIResultWrapper(
+ new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiVfModule));
+ Optional<Relationships> relationshipsOp;
+ relationshipsOp = vfModuleWrapper.getRelationships();
+ if (relationshipsOp.isPresent()) {
+ relationshipsOp = workflowActionUtils.extractRelationshipsVnfc(relationshipsOp.get());
+ if (relationshipsOp.isPresent()) {
+ Optional<Configuration> config =
+ workflowActionUtils.extractRelationshipsConfiguration(relationshipsOp.get());
+ if (config.isPresent()) {
+ aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, config.get().getConfigurationId()));
+ resourceList.add(
+ new Resource(WorkflowType.CONFIGURATION, config.get().getConfigurationId(), false));
+ }
+ }
+ }
+ } catch (Exception ex) {
+ logger.error("Exception in findConfigurationsInsideVfModule", ex);
+ buildAndThrowException(execution, "Failed to find Configuration object from the vfModule.");
+ }
+ }
+
+ private void buildAndThrowException(DelegateExecution execution, String msg) {
+ logger.error(msg);
+ execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg);
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg);
+ }
+}
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 d0cd4b0b46..26e0d2f8c9 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
@@ -78,6 +78,7 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader.VnfEBBLoader;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
@@ -136,6 +137,10 @@ public class WorkflowActionTest extends BaseTaskTest {
@Spy
protected ExecuteBuildingBlockBuilder executeBuildingBlockBuilder;
+ @InjectMocks
+ @Spy
+ protected VnfEBBLoader vnfEBBLoaderSpy;
+
@Rule
public ExpectedException thrown = ExpectedException.none();