From 4e63348e5b0c9b8df287ee6eba33b69ffd5f2516 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Fri, 1 Feb 2019 18:13:35 -0500 Subject: compare resources from openstack to aai Address Review comments on pull request Update Unit test to have proper variable for testing update logic inside bpmn to reflect proper variable Update unit test to check property for audit Add flag to turn on and off audit behavior Add license headers, remove un-used files Update Building Block Tests and Activity Names Fix additional unit tests in so-bpmn-tasks layer Fix broken Junit Test, and correct Bug in if statement Add annotation to ignore class under test profile Additional bug fixes and unit tests for classes Add Additional JUNITS, add more sample data Add Openstack Audit functionality to Adapter Change-Id: I0492063271e991eefc608b56336a5cdf1d5a7778 Issue-ID: SO-1456 Signed-off-by: Benjamin, Max (mb388a) --- .../so/bpmn/infrastructure/audit/AuditTasks.java | 83 ++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java (limited to 'bpmn/so-bpmn-tasks/src/main') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java new file mode 100644 index 0000000000..aaa9e51d15 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.audit; + + +import org.onap.so.audit.beans.AuditInventory; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.exception.BBObjectNotFoundException; +import org.onap.so.client.exception.ExceptionBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +@Component +public class AuditTasks { + + private static final Logger logger = LoggerFactory.getLogger(AuditTasks.class); + + @Autowired + private ExceptionBuilder exceptionUtil; + + @Autowired + private ExtractPojosForBB extractPojosForBB; + + @Autowired + private Environment env; + + public void isAuditNeeded(BuildingBlockExecution execution) { + try { + logger.debug("auditInventoryNeeded Value: {}", env.getProperty("mso.infra.auditInventory")); + execution.setVariable("auditInventoryNeeded",env.getProperty("mso.infra.auditInventory")); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + public void setupAuditVariable(BuildingBlockExecution execution) { + try { + execution.setVariable("auditInventory",createAuditInventory(execution)); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + private AuditInventory createAuditInventory(BuildingBlockExecution execution) throws BBObjectNotFoundException { + AuditInventory auditInventory = new AuditInventory(); + + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); + CloudRegion cloudRegion = gBBInput.getCloudRegion(); + + auditInventory.setCloudOwner(cloudRegion.getCloudOwner()); + auditInventory.setCloudRegion(cloudRegion.getLcpCloudRegionId()); + auditInventory.setTenantId(cloudRegion.getTenantId()); + auditInventory.setHeatStackName(vfModule.getVfModuleName()); + return auditInventory; + } +} -- cgit 1.2.3-korg