From a5c5b045553342376e240a506a05d0f7b947d191 Mon Sep 17 00:00:00 2001 From: "Bonkur, Venkat" Date: Wed, 25 Mar 2020 17:02:20 -0400 Subject: mso vnf configuration update composite flow Existing Change Management VNF Configuration Update flow migrated to the generic building blocks Introduced Activity BB VNFConfigModifyActivity.bpmn Updates to AppcOrcherationPreProcessor, ApplicationControllerTaskImpl to handle the ConfigModify Activity block. Updates to the catalog migration scripts to include VNF-Config-Update Macro flow. Issue-ID: SO-2768 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I06be7a83fb2738b91b0257e1ec84298a7dafc1a1 --- .../Activity/VNFConfigModifyActivity.bpmn | 67 ++++++++++++++++++++++ .../subprocess/VNFConfigModifyActivityTest.java | 54 +++++++++++++++++ .../appc/tasks/AppcOrchestratorPreProcessor.java | 21 ++++++- .../tasks/AppcOrchestratorPreProcessorTest.java | 43 ++++++++++++++ .../appcTaskRequestConfigModify.json | 13 +++++ 5 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFConfigModifyActivity.bpmn create mode 100644 bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFConfigModifyActivityTest.java create mode 100644 bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json (limited to 'bpmn') diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFConfigModifyActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFConfigModifyActivity.bpmn new file mode 100644 index 0000000000..d77b1cebb1 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFConfigModifyActivity.bpmn @@ -0,0 +1,67 @@ + + + + + SequenceFlow_0d87xrn + + + SequenceFlow_05oatn2 + SequenceFlow_1pg83wr + + + + SequenceFlow_1pg83wr + + + + SequenceFlow_0d87xrn + SequenceFlow_05oatn2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFConfigModifyActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFConfigModifyActivityTest.java new file mode 100644 index 0000000000..99ee8d9fcb --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFConfigModifyActivityTest.java @@ -0,0 +1,54 @@ +/*- + * ============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.bpmn.subprocess; + +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doThrow; +import java.util.List; +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Test; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.BaseBPMNTest; + +public class VNFConfigModifyActivityTest extends BaseBPMNTest { + @Test + public void sunnyDayVNFConfigModifyActivity_Test() throws InterruptedException { + ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFConfigModifyActivity", variables); + assertThat(pi).isNotNull(); + processExternalTasks(pi, "ConfigModify"); + assertThat(pi).isStarted().hasPassedInOrder("Start_VNFConfigModifyActivity", "PreProcessActivity", + "ConfigModify", "End_VNFConfigModifyActivity"); + assertThat(pi).isEnded(); + } + + @Test + public void rainyDayVNFConfigModifyActivity_Test() throws Exception { + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); + ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFConfigModifyActivity", variables); + assertThat(pi).isNotNull().isStarted().hasPassedInOrder("Start_VNFConfigModifyActivity", "PreProcessActivity") + .hasNotPassed("ConfigModify", "End_VNFConfigModifyActivity"); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java index 9697246b03..9c55d0a922 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java @@ -1,7 +1,9 @@ package org.onap.so.bpmn.infrastructure.appc.tasks; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Optional; import org.onap.aai.domain.yang.Vserver; import org.onap.appc.client.lcm.model.Action; @@ -29,6 +31,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; @Component public class AppcOrchestratorPreProcessor { @@ -84,8 +88,16 @@ public class AppcOrchestratorPreProcessor { appcTaskRequest.setNewSoftwareVersion(newSoftwareVersion); String operationsTimeout = JsonUtils.getJsonValue(payload, "operations_timeout"); appcTaskRequest.setOperationsTimeout(operationsTimeout); - } + Map configMap = new HashMap<>(); + ObjectMapper objectMapper = new ObjectMapper(); + String configParamsStr = JsonUtils.getJsonValue(payload, "configuration_parameters"); + if (configParamsStr != null) { + configMap = + objectMapper.readValue(configParamsStr, new TypeReference>() {}); + } + appcTaskRequest.setConfigParams(configMap); + } ControllerSelectionReference controllerSelectionReference = catalogDbClient .getControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, action.toString()); String controllerType = null; @@ -229,8 +241,13 @@ public class AppcOrchestratorPreProcessor { .isEmpty()) { errorMessage = "APPC action Snapshot is missing vserverId parameter. "; } - break; } + break; + case ConfigModify: + if (appcTaskRequest.getConfigParams().isEmpty() || appcTaskRequest.getConfigParams() == null) { + errorMessage = "APPC action ConfigModify is missing Configuration parameters. "; + } + break; default: break; } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java index c78b652bd0..ea1f7b47ad 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java @@ -45,6 +45,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.policy.JettisonStyleMapperProvider; @@ -163,4 +164,46 @@ public class AppcOrchestratorPreProcessorTest extends BaseTaskTest { genericVnf.setIpv4OamAddress("127.0.0.1"); return genericVnf; } + + @Test + public void buildAppcTaskRequestConfigModifyTest() throws Exception { + final String expectedRequestJson = + new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "appcTaskRequestConfigModify.json"))); + ApplicationControllerTaskRequest expectedTaskRequest = + mapper.readValue(expectedRequestJson, ApplicationControllerTaskRequest.class); + execution.getLookupMap().put(ResourceKey.GENERIC_VNF_ID, "-TEST"); + fillRequiredAppcExecutionFieldsConfigModify(); + GenericVnf genericVnf = getTestGenericVnf(); + when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf); + mockReferenceResponseForConfigModify(); + execution.getLookupMap().put(ResourceKey.VF_MODULE_ID, "VF-MODULE-ID-TEST"); + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("VF-MODULE-ID"); + when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); + appcOrchestratorPreProcessor.buildAppcTaskRequest(execution, "ConfigModify"); + ApplicationControllerTaskRequest actualTaskRequest = execution.getVariable("appcOrchestratorRequest"); + assertThat(actualTaskRequest, sameBeanAs(expectedTaskRequest)); + } + + private void fillRequiredAppcExecutionFieldsConfigModify() { + RequestContext context = new RequestContext(); + RequestParameters requestParameters = new RequestParameters(); + requestParameters.setPayload( + "{\"request_parameters\":{\"host_ip_address\":\"10.10.10.10\"},\"configuration_parameters\":{\"name1\":\"value1\",\"name2\":\"value2\"}}"); + context.setRequestParameters(requestParameters); + context.setMsoRequestId("TEST-MSO-ID"); + execution.setVariable("aicIdentity", "AIC-TEST"); + execution.setVariable("vmIdList", "VM-ID-LIST-TEST"); + execution.setVariable("vserverIdList", "VSERVER-ID-LIST"); + execution.setVariable("identityUrl", "IDENTITY-URL-TEST"); + execution.getGeneralBuildingBlock().setRequestContext(context); + } + + private void mockReferenceResponseForConfigModify() { + ControllerSelectionReference reference = new ControllerSelectionReference(); + reference.setControllerName("APPC"); + when(catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(eq("TEST-VNF-TYPE"), + eq(Action.ConfigModify.toString()))).thenReturn(reference); + } + } diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json new file mode 100644 index 0000000000..040c680d1c --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json @@ -0,0 +1,13 @@ +{ + "ApplicationControllerTaskRequest": { + "controllerType": "APPC", + "action": "ConfigModify", + "identityUrl": "IDENTITY-URL-TEST", + "applicationControllerVnf": { + "vnfId": "TEST-VNF-ID", + "vnfName": "TEST-VNF-NAME", + "vnfHostIpAddress": "127.0.0.1" + }, + "configParams": {"name1":"value1", "name2":"value2"} +} +} -- cgit 1.2.3-korg