aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/UserParamsServiceTraversal.java82
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java142
2 files changed, 113 insertions, 111 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/UserParamsServiceTraversal.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/UserParamsServiceTraversal.java
index aa1108cbb9..3a7dd5772f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/UserParamsServiceTraversal.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/UserParamsServiceTraversal.java
@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE;
@@ -59,6 +60,8 @@ public class UserParamsServiceTraversal {
private final CatalogDbClient catalogDbClient;
private final ExceptionBuilder exceptionBuilder;
private boolean foundVfModuleOrVG;
+ private String vnfCustomizationUUID;
+ private String vfModuleCustomizationUUID;
UserParamsServiceTraversal(CatalogDbClient catalogDbClient, ExceptionBuilder exceptionBuilder) {
this.catalogDbClient = catalogDbClient;
@@ -68,23 +71,22 @@ public class UserParamsServiceTraversal {
protected List<Resource> getResourceListFromUserParams(DelegateExecution execution,
List<Map<String, Object>> userParams, String serviceModelVersionId, String requestAction)
throws IOException {
- List<Resource> resourceList = new ArrayList<>();
if (userParams != null) {
for (Map<String, Object> params : userParams) {
if (params.containsKey(USER_PARAM_SERVICE)) {
ObjectMapper obj = new ObjectMapper();
String input = obj.writeValueAsString(params.get(USER_PARAM_SERVICE));
Service validate = obj.readValue(input, Service.class);
- setResourceList(execution, serviceModelVersionId, requestAction, resourceList, validate);
- break;
+ return getResourceList(execution, serviceModelVersionId, requestAction, validate);
}
}
}
- return resourceList;
+ return Collections.emptyList();
}
- private void setResourceList(DelegateExecution execution, String serviceModelVersionId, String requestAction,
- List<Resource> resourceList, Service validate) {
+ private List<Resource> getResourceList(DelegateExecution execution, String serviceModelVersionId,
+ String requestAction, Service validate) {
+ List<Resource> resourceList = new ArrayList<>();
resourceList.add(new Resource(WorkflowType.SERVICE, validate.getModelInfo().getModelVersionId(), false));
if (validate.getResources().getVnfs() != null) {
setResourceListForVnfs(execution, resourceList, validate);
@@ -95,11 +97,12 @@ public class UserParamsServiceTraversal {
if (validate.getResources().getNetworks() != null) {
setResourceListForNetworks(execution, serviceModelVersionId, requestAction, resourceList, validate);
}
+ return resourceList;
}
private void setResourceListForVnfs(DelegateExecution execution, List<Resource> resourceList, Service validate) {
- foundVfModuleOrVG = false;
for (Vnfs vnf : validate.getResources().getVnfs()) {
+ setVnfCustomizationUUID(vnf);
resourceList.add(new Resource(WorkflowType.VNF, vnf.getModelInfo().getModelCustomizationId(), false));
setResourceListForVfModules(execution, resourceList, validate, vnf);
}
@@ -109,10 +112,10 @@ public class UserParamsServiceTraversal {
Vnfs vnf) {
if (vnf.getVfModules() != null) {
for (VfModules vfModule : vnf.getVfModules()) {
+ setVfModuleCustomizationUUID(vfModule);
VfModuleCustomization vfModuleCustomization =
- catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(
- vfModule.getModelInfo().getModelCustomizationUuid());
- if (vfModuleCustomization != null) {
+ catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(vfModuleCustomizationUUID);
+ if (vfModuleCustomization != null && vfModuleCustomization.getVfModule() != null) {
setVolumeGroupWorkFlowTypeToResourceList(resourceList, vfModuleCustomization);
setVfModuleAndConfigurationWorkFlowTypeToResourceList(resourceList, validate, vnf, vfModule,
vfModuleCustomization);
@@ -127,8 +130,7 @@ public class UserParamsServiceTraversal {
private void setVolumeGroupWorkFlowTypeToResourceList(List<Resource> resourceList,
VfModuleCustomization vfModuleCustomization) {
- if (vfModuleCustomization.getVfModule() != null
- && vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null
+ if (vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null
&& vfModuleCustomization.getVolumeHeatEnv() != null) {
foundVfModuleOrVG = true;
resourceList.add(
@@ -138,11 +140,9 @@ public class UserParamsServiceTraversal {
private void setVfModuleAndConfigurationWorkFlowTypeToResourceList(List<Resource> resourceList, Service validate,
Vnfs vnf, VfModules vfModule, VfModuleCustomization vfModuleCustomization) {
- if ((vfModuleCustomization.getVfModule() != null)
- && ((vfModuleCustomization.getVfModule().getModuleHeatTemplate() != null
- && vfModuleCustomization.getHeatEnvironment() != null))
- || (vfModuleCustomization.getVfModule() != null
- && vfModuleCustomization.getVfModule().getModelName() != null
+ if ((vfModuleCustomization.getVfModule().getModuleHeatTemplate() != null
+ && vfModuleCustomization.getHeatEnvironment() != null)
+ || (vfModuleCustomization.getVfModule().getModelName() != null
&& vfModuleCustomization.getVfModule().getModelName().contains("helm"))) {
foundVfModuleOrVG = true;
Resource resource = setVfModuleWorkFlowTypeToResourceList(resourceList, vfModuleCustomization);
@@ -162,11 +162,9 @@ public class UserParamsServiceTraversal {
private void setConfigurationWorkFlowTypeToResourceList(List<Resource> resourceList, Service validate, Vnfs vnf,
VfModules vfModule, Resource resource) {
- String vfModuleCustomizationUUID = getVfModuleCustomizationUUID(vfModule);
- String vnfCustomizationUUID = getVnfCustomizationUUID(vnf);
if (!vnfCustomizationUUID.isEmpty() && !vfModuleCustomizationUUID.isEmpty()) {
- List<CvnfcConfigurationCustomization> configs = traverseCatalogDbForConfiguration(
- validate.getModelInfo().getModelVersionId(), vnfCustomizationUUID, vfModuleCustomizationUUID);
+ List<CvnfcConfigurationCustomization> configs =
+ traverseCatalogDbForConfiguration(validate.getModelInfo().getModelVersionId());
for (CvnfcConfigurationCustomization config : configs) {
Resource configResource = new Resource(WorkflowType.CONFIGURATION,
config.getConfigurationResource().getModelUUID(), false);
@@ -177,24 +175,20 @@ public class UserParamsServiceTraversal {
}
}
- private String getVfModuleCustomizationUUID(VfModules vfModule) {
- String vfModuleCustomizationUUID;
+ private void setVfModuleCustomizationUUID(VfModules vfModule) {
if (vfModule.getModelInfo() != null && vfModule.getModelInfo().getModelCustomizationUuid() != null) {
vfModuleCustomizationUUID = vfModule.getModelInfo().getModelCustomizationUuid();
} else {
vfModuleCustomizationUUID = "";
}
- return vfModuleCustomizationUUID;
}
- private String getVnfCustomizationUUID(Vnfs vnf) {
- String vnfCustomizationUUID;
+ private void setVnfCustomizationUUID(Vnfs vnf) {
if (vnf.getModelInfo() != null && vnf.getModelInfo().getModelCustomizationUuid() != null) {
vnfCustomizationUUID = vnf.getModelInfo().getModelCustomizationUuid();
} else {
vnfCustomizationUUID = "";
}
- return vnfCustomizationUUID;
}
private void setResourceListForPnfs(List<Resource> resourceList, Service validate) {
@@ -218,25 +212,29 @@ public class UserParamsServiceTraversal {
}
- private List<CvnfcConfigurationCustomization> traverseCatalogDbForConfiguration(String serviceModelUUID,
- String vnfCustomizationUUID, String vfModuleCustomizationUUID) {
- List<CvnfcConfigurationCustomization> configurations = new ArrayList<>();
+ private List<CvnfcConfigurationCustomization> traverseCatalogDbForConfiguration(String serviceModelUUID) {
try {
List<CvnfcCustomization> cvnfcCustomizations = catalogDbClient.getCvnfcCustomization(serviceModelUUID,
vnfCustomizationUUID, vfModuleCustomizationUUID);
- for (CvnfcCustomization cvnfc : cvnfcCustomizations) {
- for (CvnfcConfigurationCustomization customization : cvnfc.getCvnfcConfigurationCustomization()) {
- if (customization.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) {
- configurations.add(customization);
- }
- }
- }
- logger.debug("found {} fabric configuration(s)", configurations.size());
- return configurations;
+ return getCvnfcConfigurationCustomizations(cvnfcCustomizations);
} catch (Exception ex) {
logger.error("Error in finding configurations", ex);
- return configurations;
+ return Collections.emptyList();
+ }
+ }
+
+ private List<CvnfcConfigurationCustomization> getCvnfcConfigurationCustomizations(
+ List<CvnfcCustomization> cvnfcCustomizations) {
+ List<CvnfcConfigurationCustomization> configurations = new ArrayList<>();
+ for (CvnfcCustomization cvnfc : cvnfcCustomizations) {
+ for (CvnfcConfigurationCustomization customization : cvnfc.getCvnfcConfigurationCustomization()) {
+ if (customization.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) {
+ configurations.add(customization);
+ }
+ }
}
+ logger.debug("found {} fabric configuration(s)", configurations.size());
+ return configurations;
}
private String queryCatalogDbForNetworkCollection(DelegateExecution execution, String serviceModelVersionId) {
@@ -261,9 +259,7 @@ public class UserParamsServiceTraversal {
count++;
}
}
- if (count == 0) {
- return null;
- } else if (count > 1) {
+ if (count > 1) {
buildAndThrowException(execution,
"Found multiple Network Collections in the Service model, only one per Service is supported.");
}
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
index 7db93e7979..210d5195e5 100644
--- 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
@@ -28,7 +28,6 @@ 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;
@@ -36,7 +35,10 @@ 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.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
import org.onap.so.client.exception.ExceptionBuilder;
@@ -69,35 +71,12 @@ public class VnfEBBLoader {
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);
+ org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI =
+ bbInputSetupUtils.getAAIServiceInstanceById(serviceId);
+ 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;
- }
- }
+ findVnfWithGivenId(serviceInstanceMSO, vnfId, aaiResourceIds, resourceList, execution);
}
} catch (Exception ex) {
logger.error("Exception in traverseAAIVnf", ex);
@@ -109,39 +88,13 @@ public class VnfEBBLoader {
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);
+ org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI =
+ bbInputSetupUtils.getAAIServiceInstanceById(serviceId);
+ 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;
- }
- }
+ findVnfWithGivenIdAndAddCustomizationUUID(serviceInstanceMSO, vnfId, aaiResourceIds, resourceList,
+ execution);
}
} catch (Exception ex) {
logger.error("Exception in customTraverseAAIVnf", ex);
@@ -151,6 +104,33 @@ public class VnfEBBLoader {
}
+ private void findVnfWithGivenId(ServiceInstance serviceInstanceMSO, String vnfId,
+ List<Pair<WorkflowType, String>> aaiResourceIds, List<Resource> resourceList, DelegateExecution execution) {
+ for (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));
+ processVfModules(vnf, aaiResourceIds, resourceList, execution);
+ processVolumeGroups(vnf, aaiResourceIds, resourceList);
+ break;
+ }
+ }
+ }
+
+ private void findVnfWithGivenIdAndAddCustomizationUUID(ServiceInstance serviceInstanceMSO, String vnfId,
+ List<Pair<WorkflowType, String>> aaiResourceIds, List<Resource> resourceList, DelegateExecution execution) {
+ for (GenericVnf vnf : serviceInstanceMSO.getVnfs()) {
+ if (vnf.getVnfId().equals(vnfId)) {
+ aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId()));
+ resourceList.add(new Resource(WorkflowType.VNF,
+ bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId(), false));
+ processVfModules(vnf, aaiResourceIds, resourceList, execution);
+ processVolumeGroups(vnf, aaiResourceIds, resourceList);
+ break;
+ }
+ }
+ }
+
private void findConfigurationsInsideVfModule(DelegateExecution execution, String vnfId, String vfModuleId,
List<Resource> resourceList, List<Pair<WorkflowType, String>> aaiResourceIds) {
try {
@@ -161,15 +141,7 @@ public class VnfEBBLoader {
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));
- }
- }
+ addConfigToResources(relationshipsOp, resourceList, aaiResourceIds);
}
} catch (Exception ex) {
logger.error("Exception in findConfigurationsInsideVfModule", ex);
@@ -177,6 +149,40 @@ public class VnfEBBLoader {
}
}
+ private void processVfModules(GenericVnf vnf, List<Pair<WorkflowType, String>> aaiResourceIds,
+ List<Resource> resourceList, DelegateExecution execution) {
+ 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);
+ }
+ }
+ }
+
+ private void processVolumeGroups(GenericVnf vnf, List<Pair<WorkflowType, String>> aaiResourceIds,
+ List<Resource> resourceList) {
+ if (vnf.getVolumeGroups() != null) {
+ for (VolumeGroup volumeGroup : vnf.getVolumeGroups()) {
+ aaiResourceIds.add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId()));
+ resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false));
+ }
+ }
+ }
+
+ private void addConfigToResources(Optional<Relationships> relationshipsOp, List<Resource> resourceList,
+ List<Pair<WorkflowType, String>> aaiResourceIds) {
+ 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));
+ }
+ }
+ }
+
private void buildAndThrowException(DelegateExecution execution, String msg) {
logger.error(msg);
execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg);