diff options
10 files changed, 287 insertions, 8 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql index e5daf24d6c..b70d409cd8 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql @@ -30,7 +30,8 @@ INSERT INTO northbound_request_ref_lookup(MACRO_ACTION, ACTION, REQUEST_SCOPE, I ('NetworkCollection-Macro-Create', 'createInstance', 'NetworkCollection', false,true, '7','7', 'DEFAULT', '*'), ('NetworkCollection-Macro-Delete', 'deleteInstance', 'NetworkCollection', false,true, '7','7', 'DEFAULT', '*'), ('VFModule-ScaleOut', 'scaleOut', 'VfModule', true, true, '7','7', 'DEFAULT', '*'), -('VNF-InPlaceUpdate', 'inPlaceSoftwareUpdate', 'Vnf', true, true, '7','7', 'DEFAULT', '*'); +('VNF-InPlaceUpdate', 'inPlaceSoftwareUpdate', 'Vnf', true, true, '7','7', 'DEFAULT', '*'), +('VNF-Config-Update', 'applyUpdatedConfig', 'Vnf', true, true, '7','7', 'DEFAULT', '*'); INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID) VALUES @@ -198,9 +199,16 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FL ('VNF-InPlaceUpdate', '15', 'VNFResumeTrafficActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), ('VNF-InPlaceUpdate', '16', 'VNFUnlockActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), ('VNF-InPlaceUpdate', '17', 'VNFUnsetInMaintFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), -('VNF-InPlaceUpdate', '18', 'VNFUnsetClosedLoopDisabledFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')); - - +('VNF-InPlaceUpdate', '18', 'VNFUnsetClosedLoopDisabledFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-Config-Update', '1', 'VNFCheckPserversLockedFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')), +('VNF-Config-Update', '2', 'VNFCheckInMaintFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')), +('VNF-Config-Update', '3', 'VNFSetInMaintFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')), +('VNF-Config-Update', '4', 'VNFSetClosedLoopDisabledFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')), +('VNF-Config-Update', '5', 'VNFHealthCheckActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')), +('VNF-Config-Update', '6', 'VNFConfigModifyActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')), +('VNF-Config-Update', '7', 'VNFHealthCheckActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')), +('VNF-Config-Update', '8', 'VNFUnsetInMaintFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')), +('VNF-Config-Update', '9', 'VNFUnsetClosedLoopDisabledFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')); INSERT INTO rainy_day_handler_macro (FLOW_NAME, SERVICE_TYPE, VNF_TYPE, ERROR_CODE, WORK_STEP, POLICY) VALUES @@ -860,7 +868,8 @@ VALUES ('VNFUpgradePostCheckActivity', 'NO_VALIDATE', 'CUSTOM'), ('VNFUpgradePreCheckActivity', 'NO_VALIDATE', 'CUSTOM'), ('VNFUpgradeSoftwareActivity', 'NO_VALIDATE', 'CUSTOM'), -('VnfInPlaceSoftwareUpdate', 'NO_VALIDATE', 'CUSTOM'); +('VnfInPlaceSoftwareUpdate', 'NO_VALIDATE', 'CUSTOM'), +('VNFConfigModifyActivity', 'NO_VALIDATE', 'CUSTOM'); UPDATE northbound_request_ref_lookup SET SERVICE_TYPE = '*' WHERE SERVICE_TYPE IS NULL; @@ -881,6 +890,10 @@ UPDATE vnf_recipe SET ORCHESTRATION_URI = '/mso/async/services/WorkflowActionBB' WHERE NF_ROLE = 'GR-API-DEFAULT' AND ACTION = 'inPlaceSoftwareUpdate'; +UPDATE vnf_recipe +SET ORCHESTRATION_URI = '/mso/async/services/WorkflowActionBB' +WHERE NF_ROLE = 'GR-API-DEFAULT' AND ACTION = 'applyUpdatedConfig'; + INSERT INTO rainy_day_handler_macro (FLOW_NAME, SERVICE_TYPE, VNF_TYPE, ERROR_CODE, WORK_STEP, POLICY, SECONDARY_POLICY, REG_EX_ERROR_MESSAGE, SERVICE_ROLE) VALUES ('VNFCheckPserversLockedFlagActivity','*','*','*','*','Manual','Abort','*', '*'), diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/ConfigurationParameters.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/ConfigurationParameters.java index b065e9a0c3..e5321067ac 100644 --- a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/ConfigurationParameters.java +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/ConfigurationParameters.java @@ -1,5 +1,10 @@ package org.onap.so.adapters.appc.orchestrator.client.beans; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -14,6 +19,8 @@ public class ConfigurationParameters { private String nodeList; @JsonProperty("file_parameter_content") private String fileParameterContent; + @JsonIgnore + private Map<String, String> additionalProperties = new HashMap<>(); @JsonProperty("vnf_name") @@ -50,4 +57,18 @@ public class ConfigurationParameters { this.fileParameterContent = fileParameterContent; } + @JsonAnyGetter + public Map<String, String> getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, String value) { + this.additionalProperties.put(name, value); + } + + public void setAdditionalProperties(Map<String, String> map) { + this.additionalProperties = map; + } + } diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java index a174ccb05a..99d6b4dc12 100644 --- a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java @@ -32,10 +32,10 @@ public class ApplicationControllerTaskImpl { Optional<String> vserverId = Optional.empty(); Parameters parameters = new Parameters(); ConfigurationParameters configParams = new ConfigurationParameters(); + RequestParameters requestParams = new RequestParameters(); switch (request.getAction()) { case HealthCheck: - RequestParameters requestParams = new RequestParameters(); requestParams.setHostIpAddress(request.getApplicationControllerVnf().getVnfHostIpAddress()); parameters.setRequestParameters(requestParams); payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); @@ -75,6 +75,12 @@ public class ApplicationControllerTaskImpl { payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); break; case ConfigModify: + requestParams.setHostIpAddress(request.getApplicationControllerVnf().getVnfHostIpAddress()); + configParams.setAdditionalProperties(request.getConfigParams()); + parameters.setRequestParameters(requestParams); + parameters.setConfigurationParameters(configParams); + payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + break; case ConfigScaleOut: break; case UpgradePreCheck: @@ -97,6 +103,7 @@ public class ApplicationControllerTaskImpl { vserverId = Optional .of(request.getApplicationControllerVnf().getApplicationControllerVm().getVserverId()); } + break; default: // errorMessage = "Unable to idenify Action request for AppCClient"; break; diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java index 640e2dbd6e..973430c37e 100644 --- a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java @@ -1,5 +1,7 @@ package org.onap.so.adapters.appc.orchestrator.service; +import java.util.HashMap; +import java.util.Map; import java.util.Optional; import org.junit.Before; import org.junit.Test; @@ -50,6 +52,10 @@ public class ApplicationControllerTaskImplTest { request.setNewSoftwareVersion("2.0"); request.setExistingSoftwareVersion("1.0"); request.setOperationsTimeout("30"); + Map<String, String> reqConfigParams = new HashMap<>(); + reqConfigParams.put("name1", "value1"); + reqConfigParams.put("name2", "value2"); + request.setConfigParams(reqConfigParams); ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf(); applicationControllerVnf.setVnfHostIpAddress("100.100"); applicationControllerVnf.setVnfId("testVnfId"); @@ -228,6 +234,33 @@ public class ApplicationControllerTaskImplTest { } @Test + public void testExcute_configModify() throws JsonProcessingException, ApplicationControllerOrchestratorException { + request.setAction(Action.ConfigModify); + + Parameters parameters = new Parameters(); + RequestParameters requestParams = new RequestParameters(); + requestParams.setHostIpAddress(request.getApplicationControllerVnf().getVnfHostIpAddress()); + parameters.setRequestParameters(requestParams); + ConfigurationParameters configParams = new ConfigurationParameters(); + Map<String, String> configParamMap = new HashMap<>(); + configParamMap.put("name1", "value1"); + configParamMap.put("name2", "value2"); + configParams.setAdditionalProperties(configParamMap); + parameters.setConfigurationParameters(configParams); + Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + + Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener)).thenReturn(new Status()); + + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + + Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener); + } + + @Test public void testListener() throws Exception { request.setAction(Action.QuiesceTraffic); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.9.0"> + <bpmn:process id="VNFConfigModifyActivity" name="VNFConfigModifyActivity" isExecutable="true"> + <bpmn:startEvent id="Start_VNFConfigModifyActivity" name="Start"> + <bpmn:outgoing>SequenceFlow_0d87xrn</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:serviceTask id="ConfigModify" name="VNF Config Modify " camunda:type="external" camunda:topic="AppcService"> + <bpmn:incoming>SequenceFlow_05oatn2</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1pg83wr</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0d87xrn" sourceRef="Start_VNFConfigModifyActivity" targetRef="PreProcessActivity" /> + <bpmn:endEvent id="End_VNFConfigModifyActivity" name="End"> + <bpmn:incoming>SequenceFlow_1pg83wr</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1pg83wr" sourceRef="ConfigModify" targetRef="End_VNFConfigModifyActivity" /> + <bpmn:serviceTask id="PreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"ConfigModify")}"> + <bpmn:incoming>SequenceFlow_0d87xrn</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_05oatn2</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_05oatn2" sourceRef="PreProcessActivity" targetRef="ConfigModify" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="VNFConfigModifyActivity"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="Start_VNFConfigModifyActivity"> + <dc:Bounds x="173" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="179" y="138" width="25" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1q3bjtz_di" bpmnElement="ConfigModify"> + <dc:Bounds x="532" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0d87xrn_di" bpmnElement="SequenceFlow_0d87xrn"> + <di:waypoint xsi:type="dc:Point" x="209" y="120" /> + <di:waypoint xsi:type="dc:Point" x="257" y="120" /> + <di:waypoint xsi:type="dc:Point" x="257" y="120" /> + <di:waypoint xsi:type="dc:Point" x="304" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="272" y="114" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_15t8iwk_di" bpmnElement="End_VNFConfigModifyActivity"> + <dc:Bounds x="756" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="764" y="142" width="20" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1pg83wr_di" bpmnElement="SequenceFlow_1pg83wr"> + <di:waypoint xsi:type="dc:Point" x="632" y="120" /> + <di:waypoint xsi:type="dc:Point" x="756" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="694" y="99" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0h60lbz_di" bpmnElement="PreProcessActivity"> + <dc:Bounds x="308" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_05oatn2_di" bpmnElement="SequenceFlow_05oatn2"> + <di:waypoint xsi:type="dc:Point" x="408" y="120" /> + <di:waypoint xsi:type="dc:Point" x="532" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="470" y="99" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> 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<String, String> configMap = new HashMap<>(); + ObjectMapper objectMapper = new ObjectMapper(); + String configParamsStr = JsonUtils.getJsonValue(payload, "configuration_parameters"); + if (configParamsStr != null) { + configMap = + objectMapper.readValue(configParamsStr, new TypeReference<HashMap<String, String>>() {}); + } + 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"} +} +} diff --git a/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java index 3811b52551..c240957ae9 100644 --- a/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java +++ b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java @@ -1,6 +1,8 @@ package org.onap.so.appc.orchestrator.service.beans; import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; import org.onap.appc.client.lcm.model.Action; import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf; @@ -18,6 +20,15 @@ public class ApplicationControllerTaskRequest implements Serializable { private String existingSoftwareVersion; private String newSoftwareVersion; private ApplicationControllerVnf applicationControllerVnf; + private Map<String, String> configParams = new HashMap<String, String>(); + + public Map<String, String> getConfigParams() { + return configParams; + } + + public void setConfigParams(Map<String, String> configParams) { + this.configParams = configParams; + } public Action getAction() { return action; |