aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/UserParamsServiceTraversal.java227
-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
-rw-r--r--common/src/main/java/org/onap/so/logger/MaskLogStatements.java71
-rw-r--r--common/src/test/java/org/onap/so/logging/MaskLogStatementsTest.java90
-rw-r--r--common/src/test/resources/__files/logging/openstack-payload.json26
8 files changed, 519 insertions, 205 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 6c6bd61041..aa1108cbb9 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
@@ -58,6 +58,7 @@ public class UserParamsServiceTraversal {
private final CatalogDbClient catalogDbClient;
private final ExceptionBuilder exceptionBuilder;
+ private boolean foundVfModuleOrVG;
UserParamsServiceTraversal(CatalogDbClient catalogDbClient, ExceptionBuilder exceptionBuilder) {
this.catalogDbClient = catalogDbClient;
@@ -68,103 +69,13 @@ public class UserParamsServiceTraversal {
List<Map<String, Object>> userParams, String serviceModelVersionId, String requestAction)
throws IOException {
List<Resource> resourceList = new ArrayList<>();
- boolean foundVfModuleOrVG = false;
- String vnfCustomizationUUID = "";
- String vfModuleCustomizationUUID = "";
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);
- resourceList.add(
- new Resource(WorkflowType.SERVICE, validate.getModelInfo().getModelVersionId(), false));
- if (validate.getResources().getVnfs() != null) {
- for (Vnfs vnf : validate.getResources().getVnfs()) {
- resourceList.add(new Resource(WorkflowType.VNF,
- vnf.getModelInfo().getModelCustomizationId(), false));
- if (vnf.getModelInfo() != null && vnf.getModelInfo().getModelCustomizationUuid() != null) {
- vnfCustomizationUUID = vnf.getModelInfo().getModelCustomizationUuid();
- }
- if (vnf.getVfModules() != null) {
- for (VfModules vfModule : vnf.getVfModules()) {
- VfModuleCustomization vfModuleCustomization =
- catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(
- vfModule.getModelInfo().getModelCustomizationUuid());
- if (vfModuleCustomization != null) {
-
- if (vfModuleCustomization.getVfModule() != null
- && vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null
- && vfModuleCustomization.getVolumeHeatEnv() != null) {
- resourceList.add(new Resource(WorkflowType.VOLUMEGROUP,
- vfModuleCustomization.getModelCustomizationUUID(), false));
- foundVfModuleOrVG = true;
- }
-
- if ((vfModuleCustomization.getVfModule() != null)
- && ((vfModuleCustomization.getVfModule().getModuleHeatTemplate() != null
- && vfModuleCustomization.getHeatEnvironment() != null))
- || (vfModuleCustomization.getVfModule() != null
- && vfModuleCustomization.getVfModule().getModelName() != null
- && vfModuleCustomization.getVfModule().getModelName()
- .contains("helm"))) {
- foundVfModuleOrVG = true;
- Resource resource = new Resource(WorkflowType.VFMODULE,
- vfModuleCustomization.getModelCustomizationUUID(), false);
- resource.setBaseVfModule(
- vfModuleCustomization.getVfModule().getIsBase() != null
- && vfModuleCustomization.getVfModule().getIsBase());
- resourceList.add(resource);
- if (vfModule.getModelInfo() != null
- && vfModule.getModelInfo().getModelCustomizationUuid() != null) {
- vfModuleCustomizationUUID =
- vfModule.getModelInfo().getModelCustomizationUuid();
- }
- if (!vnfCustomizationUUID.isEmpty()
- && !vfModuleCustomizationUUID.isEmpty()) {
- List<CvnfcConfigurationCustomization> configs =
- traverseCatalogDbForConfiguration(
- validate.getModelInfo().getModelVersionId(),
- vnfCustomizationUUID, vfModuleCustomizationUUID);
- for (CvnfcConfigurationCustomization config : configs) {
- Resource configResource = new Resource(WorkflowType.CONFIGURATION,
- config.getConfigurationResource().getModelUUID(), false);
- resource.setVnfCustomizationId(
- vnf.getModelInfo().getModelCustomizationId());
- resource.setVfModuleCustomizationId(
- vfModule.getModelInfo().getModelCustomizationId());
- resourceList.add(configResource);
- }
- }
- }
- if (!foundVfModuleOrVG) {
- buildAndThrowException(execution,
- "Could not determine if vfModule was a vfModule or volume group. Heat template and Heat env are null");
- }
- }
- }
- }
- }
- }
- if (validate.getResources().getPnfs() != null) {
- for (Pnfs pnf : validate.getResources().getPnfs()) {
- resourceList.add(new Resource(WorkflowType.PNF,
- pnf.getModelInfo().getModelCustomizationId(), false));
- }
- }
- if (validate.getResources().getNetworks() != null) {
- for (Networks network : validate.getResources().getNetworks()) {
- resourceList.add(new Resource(WorkflowType.NETWORK,
- network.getModelInfo().getModelCustomizationId(), false));
- }
- if (requestAction.equals(CREATE_INSTANCE)) {
- String networkColCustId =
- queryCatalogDbForNetworkCollection(execution, serviceModelVersionId);
- if (networkColCustId != null) {
- resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, networkColCustId, false));
- }
- }
- }
+ setResourceList(execution, serviceModelVersionId, requestAction, resourceList, validate);
break;
}
}
@@ -172,6 +83,140 @@ public class UserParamsServiceTraversal {
return resourceList;
}
+ private void setResourceList(DelegateExecution execution, String serviceModelVersionId, String requestAction,
+ List<Resource> resourceList, Service validate) {
+ resourceList.add(new Resource(WorkflowType.SERVICE, validate.getModelInfo().getModelVersionId(), false));
+ if (validate.getResources().getVnfs() != null) {
+ setResourceListForVnfs(execution, resourceList, validate);
+ }
+ if (validate.getResources().getPnfs() != null) {
+ setResourceListForPnfs(resourceList, validate);
+ }
+ if (validate.getResources().getNetworks() != null) {
+ setResourceListForNetworks(execution, serviceModelVersionId, requestAction, resourceList, validate);
+ }
+ }
+
+ private void setResourceListForVnfs(DelegateExecution execution, List<Resource> resourceList, Service validate) {
+ foundVfModuleOrVG = false;
+ for (Vnfs vnf : validate.getResources().getVnfs()) {
+ resourceList.add(new Resource(WorkflowType.VNF, vnf.getModelInfo().getModelCustomizationId(), false));
+ setResourceListForVfModules(execution, resourceList, validate, vnf);
+ }
+ }
+
+ private void setResourceListForVfModules(DelegateExecution execution, List<Resource> resourceList, Service validate,
+ Vnfs vnf) {
+ if (vnf.getVfModules() != null) {
+ for (VfModules vfModule : vnf.getVfModules()) {
+ VfModuleCustomization vfModuleCustomization =
+ catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(
+ vfModule.getModelInfo().getModelCustomizationUuid());
+ if (vfModuleCustomization != null) {
+ setVolumeGroupWorkFlowTypeToResourceList(resourceList, vfModuleCustomization);
+ setVfModuleAndConfigurationWorkFlowTypeToResourceList(resourceList, validate, vnf, vfModule,
+ vfModuleCustomization);
+ if (!foundVfModuleOrVG) {
+ buildAndThrowException(execution,
+ "Could not determine if vfModule was a vfModule or volume group. Heat template and Heat env are null");
+ }
+ }
+ }
+ }
+ }
+
+ private void setVolumeGroupWorkFlowTypeToResourceList(List<Resource> resourceList,
+ VfModuleCustomization vfModuleCustomization) {
+ if (vfModuleCustomization.getVfModule() != null
+ && vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null
+ && vfModuleCustomization.getVolumeHeatEnv() != null) {
+ foundVfModuleOrVG = true;
+ resourceList.add(
+ new Resource(WorkflowType.VOLUMEGROUP, vfModuleCustomization.getModelCustomizationUUID(), false));
+ }
+ }
+
+ 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
+ && vfModuleCustomization.getVfModule().getModelName().contains("helm"))) {
+ foundVfModuleOrVG = true;
+ Resource resource = setVfModuleWorkFlowTypeToResourceList(resourceList, vfModuleCustomization);
+ setConfigurationWorkFlowTypeToResourceList(resourceList, validate, vnf, vfModule, resource);
+ }
+ }
+
+ private Resource setVfModuleWorkFlowTypeToResourceList(List<Resource> resourceList,
+ VfModuleCustomization vfModuleCustomization) {
+ Resource resource =
+ new Resource(WorkflowType.VFMODULE, vfModuleCustomization.getModelCustomizationUUID(), false);
+ resource.setBaseVfModule(vfModuleCustomization.getVfModule().getIsBase() != null
+ && vfModuleCustomization.getVfModule().getIsBase());
+ resourceList.add(resource);
+ return resource;
+ }
+
+ 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);
+ for (CvnfcConfigurationCustomization config : configs) {
+ Resource configResource = new Resource(WorkflowType.CONFIGURATION,
+ config.getConfigurationResource().getModelUUID(), false);
+ resource.setVnfCustomizationId(vnf.getModelInfo().getModelCustomizationId());
+ resource.setVfModuleCustomizationId(vfModule.getModelInfo().getModelCustomizationId());
+ resourceList.add(configResource);
+ }
+ }
+ }
+
+ private String getVfModuleCustomizationUUID(VfModules vfModule) {
+ String vfModuleCustomizationUUID;
+ if (vfModule.getModelInfo() != null && vfModule.getModelInfo().getModelCustomizationUuid() != null) {
+ vfModuleCustomizationUUID = vfModule.getModelInfo().getModelCustomizationUuid();
+ } else {
+ vfModuleCustomizationUUID = "";
+ }
+ return vfModuleCustomizationUUID;
+ }
+
+ private String getVnfCustomizationUUID(Vnfs vnf) {
+ String vnfCustomizationUUID;
+ if (vnf.getModelInfo() != null && vnf.getModelInfo().getModelCustomizationUuid() != null) {
+ vnfCustomizationUUID = vnf.getModelInfo().getModelCustomizationUuid();
+ } else {
+ vnfCustomizationUUID = "";
+ }
+ return vnfCustomizationUUID;
+ }
+
+ private void setResourceListForPnfs(List<Resource> resourceList, Service validate) {
+ for (Pnfs pnf : validate.getResources().getPnfs()) {
+ resourceList.add(new Resource(WorkflowType.PNF, pnf.getModelInfo().getModelCustomizationId(), false));
+ }
+ }
+
+ private void setResourceListForNetworks(DelegateExecution execution, String serviceModelVersionId,
+ String requestAction, List<Resource> resourceList, Service validate) {
+ for (Networks network : validate.getResources().getNetworks()) {
+ resourceList
+ .add(new Resource(WorkflowType.NETWORK, network.getModelInfo().getModelCustomizationId(), false));
+ }
+ if (requestAction.equals(CREATE_INSTANCE)) {
+ String networkColCustId = queryCatalogDbForNetworkCollection(execution, serviceModelVersionId);
+ if (networkColCustId != null) {
+ resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, networkColCustId, false));
+ }
+ }
+ }
+
private List<CvnfcConfigurationCustomization> traverseCatalogDbForConfiguration(String serviceModelUUID,
String vnfCustomizationUUID, String vfModuleCustomizationUUID) {
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();
diff --git a/common/src/main/java/org/onap/so/logger/MaskLogStatements.java b/common/src/main/java/org/onap/so/logger/MaskLogStatements.java
new file mode 100644
index 0000000000..cadadcf9f3
--- /dev/null
+++ b/common/src/main/java/org/onap/so/logger/MaskLogStatements.java
@@ -0,0 +1,71 @@
+package org.onap.so.logger;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import ch.qos.logback.classic.PatternLayout;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+
+public class MaskLogStatements extends PatternLayout {
+
+ private String patternsProperty;
+ private String maskChar = "*";
+ private Optional<Pattern> pattern = Optional.empty();
+ private static final Pattern authPattern =
+ Pattern.compile("Authorization(?:\\:|=)\\s?(?:\"|\\[)(?:Basic|Bearer) (.*?)(?:\"|\\])");
+ private static final Pattern openstackPattern = Pattern.compile("\"password\"\\s?:\\s?\"(.*?)\"");
+
+ public String getPatternsProperty() {
+ return patternsProperty;
+ }
+
+ public void setPatternsProperty(String patternsProperty) {
+ this.patternsProperty = patternsProperty;
+ if (this.patternsProperty != null) {
+ this.pattern = Optional.of(Pattern.compile(patternsProperty, Pattern.MULTILINE));
+ }
+ }
+
+ public String getMaskChar() {
+ return maskChar;
+ }
+
+ public void setMaskChar(String maskChar) {
+ this.maskChar = maskChar;
+ }
+
+
+ protected Collection<Pattern> getPatterns() {
+ return Arrays.asList(authPattern, openstackPattern);
+ }
+
+ @Override
+ public String doLayout(ILoggingEvent event) {
+
+ final StringBuilder message = new StringBuilder(super.doLayout(event));
+ List<Pattern> patterns = new ArrayList<>(getPatterns());
+ if (pattern.isPresent()) {
+ patterns.add(pattern.get());
+ }
+ patterns.forEach(p -> {
+ Matcher matcher = p.matcher(message);
+ while (matcher.find()) {
+ int group = 1;
+ while (group <= matcher.groupCount()) {
+ if (matcher.group(group) != null) {
+ for (int i = matcher.start(group); i < matcher.end(group); i++) {
+ message.setCharAt(i, maskChar.charAt(0));
+ }
+ }
+ group++;
+ }
+ }
+ });
+ return message.toString();
+ }
+
+}
diff --git a/common/src/test/java/org/onap/so/logging/MaskLogStatementsTest.java b/common/src/test/java/org/onap/so/logging/MaskLogStatementsTest.java
new file mode 100644
index 0000000000..ba5aeb522a
--- /dev/null
+++ b/common/src/test/java/org/onap/so/logging/MaskLogStatementsTest.java
@@ -0,0 +1,90 @@
+package org.onap.so.logging;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import org.junit.Test;
+import org.onap.so.logger.MaskLogStatements;
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.spi.LoggingEvent;
+
+public class MaskLogStatementsTest {
+
+ private LoggerContext lc = new LoggerContext();
+ private Logger logger = lc.getLogger(MaskLogStatementsTest.class);
+
+ @Test
+ public void verifyOpenStackPayload() throws IOException {
+ String payload =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/logging/openstack-payload.json")));
+
+ ILoggingEvent event = makeLoggingEvent(payload);
+
+ MaskLogStatements mask = new MaskLogStatements();
+
+ mask.setContext(lc);
+ mask.setPattern("%m");
+ mask.start();
+ String result = mask.doLayout(event);
+
+ assertTrue(result.matches("(?s).*?\"password\"\\s?:\\s?\"\\*+\".*"));
+
+ }
+
+ @Test
+ public void maskAuthHeaderTest() {
+ String msg = "Headers : [Accept:\"application/json\", Authorization:\"Basic dklfjeaklfjdkalf\","
+ + "Content-Type:\"application/json\", Content-Length:\"10\","
+ + "X-RequestID:\"db2a0462-69d0-499f-93ec-e2a064ef1f59\", X-TransactionID:\"db2a0462-69d0-499f-93ec-e2a064ef1f59\","
+ + "X-ECOMP-RequestID:\"db2a0462-69d0-499f-93ec-e2a064ef1f59\", X-ONAP-PartnerName:\"SO.APIH\","
+ + "X-InvocationID:\"885e4f99-6f24-4f17-ab1b-584b37715b49\"]";
+
+ String expected = "Headers : [Accept:\"application/json\", Authorization:\"Basic ****************\","
+ + "Content-Type:\"application/json\", Content-Length:\"10\","
+ + "X-RequestID:\"db2a0462-69d0-499f-93ec-e2a064ef1f59\", X-TransactionID:\"db2a0462-69d0-499f-93ec-e2a064ef1f59\","
+ + "X-ECOMP-RequestID:\"db2a0462-69d0-499f-93ec-e2a064ef1f59\", X-ONAP-PartnerName:\"SO.APIH\","
+ + "X-InvocationID:\"885e4f99-6f24-4f17-ab1b-584b37715b49\"]";
+ ILoggingEvent event = makeLoggingEvent(msg);
+
+ MaskLogStatements mask = new MaskLogStatements();
+
+ mask.setContext(lc);
+ mask.setPattern("%m");
+ mask.start();
+ String result = mask.doLayout(event);
+
+ assertEquals(expected, result);
+ }
+
+ @Test
+ public void maskAuthHeaderObjectStringTest() {
+ String msg = "Headers: {Accept=[text/plain, application/json, application/*+json, */*],"
+ + "Authorization=[Basic aaaaa],"
+ + "connection=[keep-alive], Content-Length=[217], content-type=[application/xml],"
+ + "host=[mso-bpmn-infra-svc:9200], user-agent=[Java/11.0.6]}";
+ String expected = "Headers: {Accept=[text/plain, application/json, application/*+json, */*],"
+ + "Authorization=[Basic -----],"
+ + "connection=[keep-alive], Content-Length=[217], content-type=[application/xml],"
+ + "host=[mso-bpmn-infra-svc:9200], user-agent=[Java/11.0.6]}";
+ ILoggingEvent event = makeLoggingEvent(msg);
+
+ MaskLogStatements mask = new MaskLogStatements();
+
+ mask.setContext(lc);
+ mask.setPattern("%m");
+ mask.setMaskChar("-");
+ mask.start();
+ String result = mask.doLayout(event);
+
+ assertEquals(expected, result);
+ }
+
+ private ILoggingEvent makeLoggingEvent(String message) {
+ return new LoggingEvent(MaskLogStatementsTest.class.getName(), logger, Level.INFO, message, null, null);
+ }
+}
diff --git a/common/src/test/resources/__files/logging/openstack-payload.json b/common/src/test/resources/__files/logging/openstack-payload.json
new file mode 100644
index 0000000000..ac4d1639dc
--- /dev/null
+++ b/common/src/test/resources/__files/logging/openstack-payload.json
@@ -0,0 +1,26 @@
+{
+ "auth": {
+ "identity": {
+ "password": {
+ "user": {
+ "name": "j0000",
+ "domain": {
+ "name": "name"
+ },
+ "password": "my-password-wow"
+ }
+ },
+ "methods": [
+ "password"
+ ]
+ },
+ "scope": {
+ "project": {
+ "id": "ad299b37da30413391e9c28138f0b0dd",
+ "domain": {
+ "name": "name"
+ }
+ }
+ }
+ }
+}