diff options
51 files changed, 769 insertions, 107 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 afe65284c7..6e65ec48c7 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 @@ -15,6 +15,7 @@ INSERT INTO northbound_request_ref_lookup(MACRO_ACTION, ACTION, REQUEST_SCOPE, I ('Service-Macro-Unassign', 'unassignInstance', 'Service', false,true, '7','7', 'DEFAULT', '*'), ('Service-Macro-Create', 'createInstance', 'Service', false,true, '7','7', 'DEFAULT', '*'), ('Service-Macro-Delete', 'deleteInstance', 'Service', false,true, '7','7', 'DEFAULT', '*'), +('Service-Macro-Upgrade', 'upgradeInstance', 'Service', false,true, '7','7', 'DEFAULT', '*'), ('Network-Create', 'createInstance', 'Network', true,true, '7','7', 'DEFAULT', '*'), ('Network-Delete', 'deleteInstance', 'Network', true,true, '7','7', 'DEFAULT', '*'), ('VNF-Macro-Create', 'createInstance', 'Vnf', false,true, '7','7', 'DEFAULT', '*'), @@ -103,6 +104,7 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FL ('Service-Macro-Delete', '14', 'UnassignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Delete', '15', 'UnassignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Delete', '16', 'UnassignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Upgrade', '1', 'ChangeModelServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Upgrade' and CLOUD_OWNER = 'DEFAULT')), ('Network-Create', '1', 'AssignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create' and CLOUD_OWNER = 'DEFAULT')), ('Network-Create', '2', 'CreateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create' and CLOUD_OWNER = 'DEFAULT')), ('Network-Create', '3', 'ActivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create' and CLOUD_OWNER = 'DEFAULT')), @@ -962,6 +964,12 @@ UPDATE vnf_recipe SET ORCHESTRATION_URI = '/mso/async/services/WorkflowActionBB' WHERE NF_ROLE = 'GR-API-DEFAULT' AND ACTION = 'applyUpdatedConfig'; +DELETE FROM service_recipe where ACTION = 'upgradeInstance'; +INSERT INTO service_recipe (ACTION, VERSION_STR, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT, SERVICE_MODEL_UUID) +VALUES +('upgradeInstance', '1.0', 'Gr api recipe to upgrade service-instance', '/mso/async/services/WorkflowActionBB', 180, 'd88da85c-d9e8-4f73-b837-3a72a431622b'); + + 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','*','*','*','*','Rollback','Abort','*', '*'), diff --git a/asdc-controller/pom.xml b/asdc-controller/pom.xml index d539e65b13..244d83f7db 100644 --- a/asdc-controller/pom.xml +++ b/asdc-controller/pom.xml @@ -215,7 +215,7 @@ <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> - <version>1.9</version> + <version>1.15</version> </dependency> <dependency> <groupId>org.onap.so</groupId> diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java index 054cc378ef..c6d92cc9ab 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java @@ -60,6 +60,9 @@ public class FlowManipulatorListenerRunner extends ListenerRunner { int sequenceBeforeFlowManipulator; do { sequenceBeforeFlowManipulator = execution.getVariable(BBConstants.G_CURRENT_SEQUENCE); + if (sequenceBeforeFlowManipulator >= flowsToExecute.size()) { + break; + } ExecuteBuildingBlock currentBB = flowsToExecute.get(execution.getCurrentSequence()); List<PreFlowManipulator> filtered = filterListeners(flowManipulators, (item -> item.shouldRunFor(currentBB.getBuildingBlock().getBpmnFlowName(), diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java index b554d7a9ba..4ad7fbdbd3 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java @@ -45,6 +45,14 @@ public class ModelInfoServiceInstance extends ModelInfoMetadata implements Seria private String namingPolicy; @JsonProperty("onap-generated-naming") private Boolean onapGeneratedNaming; + @JsonProperty("cds-blueprint-name") + private String blueprintName; + @JsonProperty("cds-blueprint-version") + private String blueprintVersion; + @JsonProperty("controller-actor") + private String controllerActor; + @JsonProperty("skip-post-instantiation-configuration") + private Boolean skipPostInstConf = Boolean.TRUE; public String getDescription() { @@ -119,4 +127,36 @@ public class ModelInfoServiceInstance extends ModelInfoMetadata implements Seria public void setOnapGeneratedNaming(Boolean onapGeneratedNaming) { this.onapGeneratedNaming = onapGeneratedNaming; } + + public String getBlueprintName() { + return blueprintName; + } + + public void setBlueprintName(String blueprintName) { + this.blueprintName = blueprintName; + } + + public String getBlueprintVersion() { + return blueprintVersion; + } + + public void setBlueprintVersion(String blueprintVersion) { + this.blueprintVersion = blueprintVersion; + } + + public String getControllerActor() { + return controllerActor; + } + + public void setControllerActor(String controllerActor) { + this.controllerActor = controllerActor; + } + + public Boolean getSkipPostInstConf() { + return skipPostInstConf; + } + + public void setSkipPostInstConf(Boolean skipPostInstConf) { + this.skipPostInstConf = skipPostInstConf; + } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index 569f6b1c77..d39da5ee37 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -1249,7 +1249,8 @@ public class BBInputSetup implements JavaDelegate { || requestAction.equalsIgnoreCase("activateInstance") || requestAction.equalsIgnoreCase("activateFabricConfiguration") || requestAction.equalsIgnoreCase("recreateInstance") - || requestAction.equalsIgnoreCase("replaceInstance")) { + || requestAction.equalsIgnoreCase("replaceInstance") + || requestAction.equalsIgnoreCase("upgradeInstance")) { return getGBBMacroExistingService(executeBB, lookupKeyMap, bbName, requestAction, requestDetails.getCloudConfiguration()); } @@ -1429,7 +1430,13 @@ public class BBInputSetup implements JavaDelegate { if (serviceInstanceId != null) { aaiServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId); if (aaiServiceInstance != null) { - service = bbInputSetupUtils.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); + String modelVersionId = aaiServiceInstance.getModelVersionId(); + if ("upgradeInstance".equalsIgnoreCase(requestAction)) { + modelVersionId = requestDetails.getModelInfo().getModelVersionId(); + } + + service = bbInputSetupUtils.getCatalogServiceByModelUUID(modelVersionId); + if (service == null) { String message = String.format( "Related service instance model not found in MSO CatalogDB: model-version-id=%s", diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForPnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForPnf.java index 0d79dbb375..f393d2a49d 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForPnf.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForPnf.java @@ -20,6 +20,7 @@ package org.onap.so.client.cds; +import static org.onap.so.client.cds.ConfigureInstanceParamsUtil.applyParamsToObject; import com.google.gson.JsonObject; import org.onap.so.client.exception.PayloadGenerationException; import org.onap.so.serviceinstancebeans.Service; @@ -51,13 +52,17 @@ public class ConfigureInstanceParamsForPnf { public void populateInstanceParams(JsonObject jsonObject, List<Map<String, Object>> userParamsFromRequest, String modelCustomizationUuid) throws PayloadGenerationException { try { - Service service = extractServiceFromUserParameters.getServiceFromRequestUserParams(userParamsFromRequest); - List<Map<String, String>> instanceParamsList = getInstanceParamForPnf(service, modelCustomizationUuid); + Optional<Service> service = + extractServiceFromUserParameters.getServiceFromRequestUserParams(userParamsFromRequest); - instanceParamsList.stream().flatMap(instanceParamsMap -> instanceParamsMap.entrySet().stream()) - .forEachOrdered(entry -> jsonObject.addProperty(entry.getKey(), entry.getValue())); + if (service.isPresent()) { + List<Map<String, String>> instanceParamsList = + getInstanceParamForPnf(service.get(), modelCustomizationUuid); + + applyParamsToObject(instanceParamsList, jsonObject); + } } catch (Exception exception) { - throw new PayloadGenerationException("Couldn't able to resolve instance parameters", exception); + throw new PayloadGenerationException("Failed to resolve instance parameters", exception); } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForService.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForService.java new file mode 100644 index 0000000000..e8c88e00d7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForService.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2021 Bell Canada + * ================================================================================ + * 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.client.cds; + +import static org.onap.so.client.cds.ConfigureInstanceParamsUtil.applyParamsToObject; +import com.google.gson.JsonObject; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.onap.so.client.exception.PayloadGenerationException; +import org.onap.so.serviceinstancebeans.Service; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class ConfigureInstanceParamsForService { + + @Autowired + private ExtractServiceFromUserParameters extractServiceFromUserParameters; + + /** + * Read instance parameters for Service and put into JsonObject. + * + * @param jsonObject - JsonObject which will hold the payload to send to CDS. + * @param userParamsFromRequest - User parameters. + * @throws PayloadGenerationException if it doesn't able to populate instance parameters from SO payload. + */ + public void populateInstanceParams(JsonObject jsonObject, List<Map<String, Object>> userParamsFromRequest) + throws PayloadGenerationException { + try { + Optional<Service> service = + extractServiceFromUserParameters.getServiceFromRequestUserParams(userParamsFromRequest); + + service.map(Service::getInstanceParams).ifPresent(p -> applyParamsToObject(p, jsonObject)); + } catch (Exception e) { + throw new PayloadGenerationException("Failed to resolve instance parameters", e); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModule.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModule.java index eeaecb9264..b1e632a701 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModule.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModule.java @@ -20,7 +20,9 @@ package org.onap.so.client.cds; +import static org.onap.so.client.cds.ConfigureInstanceParamsUtil.applyParamsToObject; import com.google.gson.JsonObject; +import java.util.Optional; import org.apache.commons.lang3.StringUtils; import org.onap.so.client.exception.PayloadGenerationException; import org.onap.so.serviceinstancebeans.Service; @@ -50,19 +52,22 @@ public class ConfigureInstanceParamsForVfModule { String vnfCustomizationUuid, String vfModuleCustomizationUuid, String vfModuleInstanceName) throws PayloadGenerationException { try { - Service service = extractServiceFromUserParameters.getServiceFromRequestUserParams(userParamsFromRequest); + Optional<Service> service = + extractServiceFromUserParameters.getServiceFromRequestUserParams(userParamsFromRequest); - List<Map<String, String>> instanceParamsList; - if (StringUtils.isNotBlank(vfModuleInstanceName)) { - instanceParamsList = getInstanceParamsByInstanceNames(service, vfModuleInstanceName); - } else { - instanceParamsList = getInstanceParams(service, vnfCustomizationUuid, vfModuleCustomizationUuid); - } + if (service.isPresent()) { + List<Map<String, String>> instanceParamsList; + if (StringUtils.isNotBlank(vfModuleInstanceName)) { + instanceParamsList = getInstanceParamsByInstanceNames(service.get(), vfModuleInstanceName); + } else { + instanceParamsList = + getInstanceParams(service.get(), vnfCustomizationUuid, vfModuleCustomizationUuid); + } - instanceParamsList.stream().flatMap(instanceParamsMap -> instanceParamsMap.entrySet().stream()) - .forEachOrdered(entry -> jsonObject.addProperty(entry.getKey(), entry.getValue())); + applyParamsToObject(instanceParamsList, jsonObject); + } } catch (Exception e) { - throw new PayloadGenerationException("Couldn't able to resolve instance parameters", e); + throw new PayloadGenerationException("Failed to resolve instance parameters", e); } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForVnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForVnf.java index 43283ac98b..5d8388b6e0 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForVnf.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForVnf.java @@ -20,8 +20,9 @@ package org.onap.so.client.cds; -import com.google.gson.JsonObject; +import static org.onap.so.client.cds.ConfigureInstanceParamsUtil.applyParamsToObject; import org.apache.commons.lang3.StringUtils; +import com.google.gson.JsonObject; import org.onap.so.client.exception.PayloadGenerationException; import org.onap.so.serviceinstancebeans.Service; import org.onap.so.serviceinstancebeans.Vnfs; @@ -48,19 +49,20 @@ public class ConfigureInstanceParamsForVnf { public void populateInstanceParams(JsonObject jsonObject, List<Map<String, Object>> userParamsFromRequest, String modelCustomizationUuid, String vnfInstanceName) throws PayloadGenerationException { try { - Service service = extractServiceFromUserParameters.getServiceFromRequestUserParams(userParamsFromRequest); + Optional<Service> service = + extractServiceFromUserParameters.getServiceFromRequestUserParams(userParamsFromRequest); - List<Map<String, String>> instanceParamsList; - if (StringUtils.isNotBlank(vnfInstanceName)) { - instanceParamsList = getInstanceParamByVnfInstanceName(service, vnfInstanceName); - } else { - instanceParamsList = getInstanceParamForVnf(service, modelCustomizationUuid); + if (service.isPresent()) { + List<Map<String, String>> instanceParamsList; + if (StringUtils.isNotBlank(vnfInstanceName)) { + instanceParamsList = getInstanceParamByVnfInstanceName(service.get(), vnfInstanceName); + } else { + instanceParamsList = getInstanceParamForVnf(service.get(), modelCustomizationUuid); + } + applyParamsToObject(instanceParamsList, jsonObject); } - - instanceParamsList.stream().flatMap(instanceParamsMap -> instanceParamsMap.entrySet().stream()) - .forEachOrdered(entry -> jsonObject.addProperty(entry.getKey(), entry.getValue())); } catch (Exception e) { - throw new PayloadGenerationException("Couldn't able to resolve instance parameters", e); + throw new PayloadGenerationException("Failed to resolve instance parameters", e); } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsUtil.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsUtil.java new file mode 100644 index 0000000000..117fd74498 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsUtil.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2021 Bell Canada + * ================================================================================ + * 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.client.cds; + +import com.google.gson.JsonObject; +import java.util.List; +import java.util.Map; + +public final class ConfigureInstanceParamsUtil { + + public static void applyParamsToObject(List<Map<String, String>> instanceParamsList, JsonObject jsonObject) { + instanceParamsList.stream().flatMap(instanceParamsMap -> instanceParamsMap.entrySet().stream()) + .forEachOrdered(entry -> jsonObject.addProperty(entry.getKey(), entry.getValue())); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ExtractServiceFromUserParameters.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ExtractServiceFromUserParameters.java index 43fabd3253..53e1da410e 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ExtractServiceFromUserParameters.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ExtractServiceFromUserParameters.java @@ -20,6 +20,7 @@ package org.onap.so.client.cds; import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.Optional; import org.onap.so.client.exception.PayloadGenerationException; import org.onap.so.serviceinstancebeans.Service; import org.springframework.beans.factory.annotation.Autowired; @@ -35,10 +36,13 @@ public class ExtractServiceFromUserParameters { @Autowired private ObjectMapper objectMapper; - public Service getServiceFromRequestUserParams(List<Map<String, Object>> userParams) throws Exception { - Map<String, Object> serviceMap = userParams.stream().filter(key -> key.containsKey(SERVICE_KEY)).findFirst() - .orElseThrow(() -> new Exception("Can not find service in userParams section in generalBuildingBlock")); - return getServiceObjectFromServiceMap(serviceMap); + public Optional<Service> getServiceFromRequestUserParams(List<Map<String, Object>> userParams) throws Exception { + Optional<Map<String, Object>> serviceMap = + userParams.stream().filter(key -> key.containsKey(SERVICE_KEY)).findFirst(); + if (serviceMap.isPresent()) { + return Optional.of(getServiceObjectFromServiceMap(serviceMap.get())); + } + return Optional.empty(); } private Service getServiceObjectFromServiceMap(Map<String, Object> serviceMap) throws PayloadGenerationException { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ServiceCDSRequestProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ServiceCDSRequestProvider.java index 12c841a2c6..ce784dd5d6 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ServiceCDSRequestProvider.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ServiceCDSRequestProvider.java @@ -21,8 +21,11 @@ package org.onap.so.client.cds; import com.google.gson.JsonObject; +import java.util.List; +import java.util.Map; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +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.PayloadGenerationException; @@ -38,21 +41,22 @@ import static org.onap.so.client.cds.PayloadConstants.SEPARATOR; @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class ServiceCDSRequestProvider implements CDSRequestProvider { - private static final String EMPTY_STRING = ""; private String resolutionKey; private BuildingBlockExecution execution; + private String bluePrintName; + private String bluePrintVersion; @Autowired - private ExtractPojosForBB extractPojosForBB; + private ConfigureInstanceParamsForService configureInstanceParamsForService; @Override public String getBlueprintName() { - return EMPTY_STRING; + return bluePrintName; } @Override public String getBlueprintVersion() { - return EMPTY_STRING; + return bluePrintVersion; } @Override @@ -65,17 +69,21 @@ public class ServiceCDSRequestProvider implements CDSRequestProvider { JsonObject cdsPropertyObject = new JsonObject(); JsonObject serviceObject = new JsonObject(); try { - ServiceInstance serviceInstance = - extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); - + ServiceInstance serviceInstance = execution.getGeneralBuildingBlock().getServiceInstance(); + bluePrintName = serviceInstance.getModelInfoServiceInstance().getBlueprintName(); + bluePrintVersion = serviceInstance.getModelInfoServiceInstance().getBlueprintVersion(); resolutionKey = serviceInstance.getServiceInstanceName(); - // TODO Need to figure out how to populate blueprint name and version for service. - serviceObject.addProperty("service-instance-id", serviceInstance.getServiceInstanceId()); serviceObject.addProperty("service-model-uuid", serviceInstance.getModelInfoServiceInstance().getModelUuid()); + final GeneralBuildingBlock buildingBlock = execution.getGeneralBuildingBlock(); + List<Map<String, Object>> userParamsFromRequest = + buildingBlock.getRequestContext().getRequestParameters().getUserParams(); + if (userParamsFromRequest != null && userParamsFromRequest.size() != 0) { + configureInstanceParamsForService.populateInstanceParams(serviceObject, userParamsFromRequest); + } } catch (Exception e) { throw new PayloadGenerationException("Failed to buildPropertyObjectForService", e); } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index 8961c996a8..b561055468 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -46,6 +46,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.UUID; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.junit.Assert; import org.junit.Rule; @@ -2984,6 +2985,31 @@ public class BBInputSetupTest { } @Test + public void testGetGBBMacroExistingServiceUpgrade() throws Exception { + String requestAction = "upgradeInstance"; + GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), + GeneralBuildingBlock.class); + ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), + ExecuteBuildingBlock.class); + RequestDetails requestDetails = mapper + .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceUpgrade.json"), RequestDetails.class); + Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap(); + executeBB.setRequestDetails(requestDetails); + + doReturn(new Service()).when(SPY_bbInputSetupUtils) + .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId()); + doReturn(new org.onap.aai.domain.yang.ServiceInstance()).when(SPY_bbInputSetupUtils) + .getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID)); + doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(any(BBInputSetupParameter.class)); + + SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap, + executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, null); + + verify(SPY_bbInputSetupUtils, times(1)) + .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId()); + } + + @Test public void testGetGBBMacroExistingServiceServiceinstancenotFoundInAai() throws Exception { ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractVnfCDSRequestProviderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractVnfCDSRequestProviderTest.java index 6de1364a47..42b29ea669 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractVnfCDSRequestProviderTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractVnfCDSRequestProviderTest.java @@ -20,6 +20,7 @@ package org.onap.so.client.cds; import com.google.gson.JsonParser; +import java.util.Optional; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; import org.junit.Before; @@ -143,12 +144,12 @@ public abstract class AbstractVnfCDSRequestProviderTest { return userParams; } - protected Service getUserParams() { + protected Optional<Service> getUserParams() { Service service = new Service(); Resources resources = new Resources(); resources.setVnfs(createVnfList()); service.setResources(resources); - return service; + return Optional.of(service); } protected List<Vnfs> createVnfList() { diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModuleTest.java index 0273b9dbf6..be100652c0 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModuleTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModuleTest.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.UUID; import org.junit.Test; import org.junit.runner.RunWith; @@ -67,7 +68,7 @@ public class ConfigureInstanceParamsForVfModuleTest { resources.setVnfs(createVnfs()); service.setResources(resources); - when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(service); + when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(Optional.of(service)); JsonObject jsonObject = new JsonObject(); configureInstanceParamsForVfModule.populateInstanceParams(jsonObject, new ArrayList<>(), VNF_CUSTOMIZATION_ID, @@ -85,7 +86,7 @@ public class ConfigureInstanceParamsForVfModuleTest { resources.setVnfs(createVnfs()); service.setResources(resources); - when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(service); + when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(Optional.of(service)); JsonObject jsonObject = new JsonObject(); // No instance name is passed diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVnfTest.java index 547129e898..6466da59d0 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVnfTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVnfTest.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.UUID; import org.junit.Test; import org.junit.runner.RunWith; @@ -64,7 +65,7 @@ public class ConfigureInstanceParamsForVnfTest { Resources resources = new Resources(); resources.setVnfs(createVnfs()); service.setResources(resources); - when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(service); + when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(Optional.of(service)); JsonObject jsonObject = new JsonObject(); configureInstanceParamsForVnf.populateInstanceParams(jsonObject, new ArrayList<>(), VNF_2_CUSTOMIZATION_ID, @@ -81,7 +82,7 @@ public class ConfigureInstanceParamsForVnfTest { Resources resources = new Resources(); resources.setVnfs(createVnfs()); service.setResources(resources); - when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(service); + when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(Optional.of(service)); JsonObject jsonObject = new JsonObject(); // No instance name is passed diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsUtilTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsUtilTest.java new file mode 100644 index 0000000000..f7c3e8a192 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsUtilTest.java @@ -0,0 +1,24 @@ +package org.onap.so.client.cds; + +import static org.junit.Assert.assertEquals; +import com.google.gson.JsonObject; +import java.util.List; +import java.util.Map; +import org.junit.Test; + +public class ConfigureInstanceParamsUtilTest { + + @Test + public void testApplyParamsToObject() { + List<Map<String, String>> instanceParamsList = + List.of(Map.of("test-param-1", "value1", "test-param-2", "value2"), Map.of("test-param-3", "value3")); + JsonObject jsonObject = new JsonObject(); + + ConfigureInstanceParamsUtil.applyParamsToObject(instanceParamsList, jsonObject); + + assertEquals("value1", jsonObject.get("test-param-1").getAsString()); + assertEquals("value2", jsonObject.get("test-param-2").getAsString()); + assertEquals("value3", jsonObject.get("test-param-3").getAsString()); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ServiceCDSRequestProviderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ServiceCDSRequestProviderTest.java index 70ce3a1eed..c860d0fc5e 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ServiceCDSRequestProviderTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ServiceCDSRequestProviderTest.java @@ -23,6 +23,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Test; import org.mockito.InjectMocks; +import org.mockito.Mock; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import static org.assertj.core.api.Assertions.assertThat; @@ -35,13 +36,15 @@ public class ServiceCDSRequestProviderTest extends AbstractVnfCDSRequestProvider @InjectMocks private ServiceCDSRequestProvider serviceCDSRequestProvider; + @Mock + private ConfigureInstanceParamsForService configureInstanceParamsForService; + @Test public void testRequestPayloadForCreateService() throws Exception { // given setScopeAndAction(SERVICE_SCOPE, SERVICE_ACTION); ServiceInstance instance = createServiceInstance(); - doReturn(instance).when(extractPojosForBB).extractByKey(buildingBlockExecution, - ResourceKey.SERVICE_INSTANCE_ID); + buildingBlockExecution.getGeneralBuildingBlock().setServiceInstance(instance); // when serviceCDSRequestProvider.setExecutionObject(buildingBlockExecution); diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ModelInfoServiceInstance.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ModelInfoServiceInstance.json index 42ae25a7b1..af3b3ffba8 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ModelInfoServiceInstance.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ModelInfoServiceInstance.json @@ -8,5 +8,6 @@ "service-type": "serviceType", "service-role": "serviceRole", "environment-context": "environmentContext", - "workload-context": "workloadContext" + "workload-context": "workloadContext", + "skip-post-instantiation-configuration": true }
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_serviceUpgrade.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_serviceUpgrade.json new file mode 100644 index 0000000000..2a721ddd96 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_serviceUpgrade.json @@ -0,0 +1,31 @@ +{ + "modelInfo": { + "modelType": "service", + "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b", + "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", + "modelName": "Sample Service Upgrade", + "modelVersion": "10.0" + }, + "owningEntity": { + "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489", + "owningEntityName": "TEST" + }, + "project": { + "projectName": "projectName" + }, + "subscriberInfo": { + "globalSubscriberId": "subscriberId" + }, + "requestInfo": { + "instanceName": "test_Service", + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "suppressRollback": false, + "requestorId": "xxxxxx" + }, + "requestParameters": { + "subscriptionServiceType": "test", + "aLaCarte": false, + "userParams": [] + } +} diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn index 5fd9701880..6fb7b5b5b4 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn @@ -1,5 +1,5 @@ <?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="3.1.2"> +<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="3.6.0"> <bpmn:process id="WorkflowActionBB" name="WorkflowActionBB" isExecutable="true"> <bpmn:extensionElements> <camunda:executionListener class="org.onap.so.bpmn.core.plugins.AsyncTaskExecutorListener" event="end" /> @@ -30,7 +30,7 @@ <camunda:in source="rollbackTargetState" target="rollbackTargetState" /> <camunda:out source="rollbackTargetState" target="rollbackTargetState" /> </bpmn:extensionElements> - <bpmn:incoming>SequenceFlow_0mew9im</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0duoleg</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1hsqed1</bpmn:outgoing> </bpmn:callActivity> <bpmn:sequenceFlow id="SequenceFlow_0mqrkxv" sourceRef="Task_SelectBB" targetRef="ServiceTask_0e2p0xs" /> @@ -183,7 +183,7 @@ <bpmn:incoming>SequenceFlow_0mqrkxv</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0mew9im</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:sequenceFlow id="SequenceFlow_0mew9im" sourceRef="ServiceTask_0e2p0xs" targetRef="Call_ExecuteBB" /> + <bpmn:sequenceFlow id="SequenceFlow_0mew9im" sourceRef="ServiceTask_0e2p0xs" targetRef="ExclusiveGateway_10j89d1" /> <bpmn:sequenceFlow id="SequenceFlow_0kf5sen" name="yes" sourceRef="ExclusiveGateway_isTopLevelFlowC" targetRef="Task_UpdateRequestComplete" /> <bpmn:sequenceFlow id="SequenceFlow_1tfizxf" sourceRef="Task_PreValidateWorkflow" targetRef="Task_SelectBB" /> <bpmn:serviceTask id="Task_PreValidateWorkflow" name="PreValidate Workflow" camunda:expression="${WorkflowValidatorRunner.preValidate(execution.getVariable("requestAction"), execution)}"> @@ -193,6 +193,7 @@ </bpmn:serviceTask> <bpmn:serviceTask id="ServiceTask_0lbkcyp" name="Post Processing Execute BB" camunda:expression="${WorkflowActionBBTasks.postProcessingExecuteBB(execution)}"> <bpmn:incoming>SequenceFlow_1hsqed1</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1knplug</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1fftixk</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_1hsqed1" sourceRef="Call_ExecuteBB" targetRef="ServiceTask_0lbkcyp" /> @@ -211,6 +212,15 @@ <bpmn:incoming>SequenceFlow_0ilo6lo</bpmn:incoming> </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_0ilo6lo" name="yes" sourceRef="ExclusiveGateway_1dez26n" targetRef="EndEvent_12f15tu" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_10j89d1" default="SequenceFlow_0duoleg"> + <bpmn:incoming>SequenceFlow_0mew9im</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0duoleg</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1knplug</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_0duoleg" sourceRef="ExclusiveGateway_10j89d1" targetRef="Call_ExecuteBB" /> + <bpmn:sequenceFlow id="SequenceFlow_1knplug" name="completed = true" sourceRef="ExclusiveGateway_10j89d1" targetRef="ServiceTask_0lbkcyp"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("completed")==true}</bpmn:conditionExpression> + </bpmn:sequenceFlow> </bpmn:process> <bpmn:error id="Error_0kd2o2a" name="java.lang.Exception" errorCode="java.lang.Exception" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> @@ -235,11 +245,11 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_03m7z4y_di" bpmnElement="Call_ExecuteBB"> - <dc:Bounds x="1150" y="356" width="100" height="80" /> + <dc:Bounds x="1200" y="356" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0mqrkxv_di" bpmnElement="SequenceFlow_0mqrkxv"> <di:waypoint x="929" y="396" /> - <di:waypoint x="990" y="396" /> + <di:waypoint x="960" y="396" /> <bpmndi:BPMNLabel> <dc:Bounds x="324.5" y="105" width="90" height="0" /> </bpmndi:BPMNLabel> @@ -531,11 +541,11 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0e2p0xs_di" bpmnElement="ServiceTask_0e2p0xs"> - <dc:Bounds x="990" y="356" width="100" height="80" /> + <dc:Bounds x="960" y="356" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0mew9im_di" bpmnElement="SequenceFlow_0mew9im"> - <di:waypoint x="1090" y="396" /> - <di:waypoint x="1150" y="396" /> + <di:waypoint x="1060" y="396" /> + <di:waypoint x="1105" y="396" /> <bpmndi:BPMNLabel> <dc:Bounds x="530" y="99" width="0" height="12" /> </bpmndi:BPMNLabel> @@ -561,17 +571,17 @@ <dc:Bounds x="670" y="356" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0lbkcyp_di" bpmnElement="ServiceTask_0lbkcyp"> - <dc:Bounds x="1325" y="356" width="100" height="80" /> + <dc:Bounds x="1350" y="356" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1hsqed1_di" bpmnElement="SequenceFlow_1hsqed1"> - <di:waypoint x="1250" y="396" /> - <di:waypoint x="1325" y="396" /> + <di:waypoint x="1300" y="396" /> + <di:waypoint x="1350" y="396" /> <bpmndi:BPMNLabel> <dc:Bounds x="697.5" y="99" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1fftixk_di" bpmnElement="SequenceFlow_1fftixk"> - <di:waypoint x="1425" y="396" /> + <di:waypoint x="1450" y="396" /> <di:waypoint x="1501" y="396" /> <bpmndi:BPMNLabel> <dc:Bounds x="873" y="99" width="0" height="12" /> @@ -618,6 +628,25 @@ <dc:Bounds x="727" y="173" width="18" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_10j89d1_di" bpmnElement="ExclusiveGateway_10j89d1" isMarkerVisible="true"> + <dc:Bounds x="1105" y="371" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1100" y="428" width="60" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0duoleg_di" bpmnElement="SequenceFlow_0duoleg"> + <di:waypoint x="1155" y="396" /> + <di:waypoint x="1200" y="396" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1knplug_di" bpmnElement="SequenceFlow_1knplug"> + <di:waypoint x="1130" y="371" /> + <di:waypoint x="1130" y="330" /> + <di:waypoint x="1400" y="330" /> + <di:waypoint x="1400" y="356" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1224" y="312" width="83" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy index 78cafa7be5..1e65c1a9dd 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy @@ -114,7 +114,7 @@ class AllocateSliceSubnet extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) } else { - execution.setVariable("networkType", networkType.toUpperCase()) + execution.setVariable("networkType", networkType.toLowerCase()) } //requestParameters, subscriptionServiceType is 5G diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy index d00f349690..a1acbb3377 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy @@ -215,13 +215,15 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { requestBody.replaceAll("\\s+", "") String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) - String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution) + String basicAuth = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) + def authHeader = utils.getBasicAuth(basicAuth, msoKey) + // String basicAuthValue = utils.encrypt(basicAuth, msoKey) // String encodeString = utils.getBasicAuth(basicAuthValue, msoKey) HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) // httpClient.addAdditionalHeader("Authorization", encodeString) - httpClient.addAdditionalHeader("Authorization", basicAuth) + httpClient.addAdditionalHeader("Authorization", authHeader) httpClient.addAdditionalHeader("Accept", "application/json") Response httpResponse = httpClient.delete(requestBody) handleNSSMFWFResponse(httpResponse, execution) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy index f3fca050a2..a4d503a86c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy @@ -565,7 +565,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { List<String> snssaiList = execution.getVariable("snssaiList") String snssai = snssaiList.get(0) //ANServiceInstance.setEnvironmentContext(snssai) - ANServiceInstance.setEnvironmentContext("an") //Network Type + ANServiceInstance.setEnvironmentContext(execution.getVariable("networkType")) //Network Type ANServiceInstance.setWorkloadContext("AN") //domain Type logger.debug("completed AN service instance build "+ ANServiceInstance.toString()) @@ -631,7 +631,8 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { ANServiceInstance.setServiceRole(serviceRole) List<String> snssaiList = execution.getVariable("snssaiList") String snssai = snssaiList.get(0) - ANServiceInstance.setEnvironmentContext(snssai) + //ANServiceInstance.setEnvironmentContext(snssai) + ANServiceInstance.setEnvironmentContext(execution.getVariable("networkType")) String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("modelUuid") ANServiceInstance.setModelInvariantId(modelInvariantUuid) @@ -651,7 +652,8 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { ANNFServiceInstance.setServiceRole(serviceRole) snssaiList = execution.getVariable("snssaiList") snssai = snssaiList.get(0) - ANNFServiceInstance.setEnvironmentContext(snssai) + //ANNFServiceInstance.setEnvironmentContext(snssai) + ANNFServiceInstance.setEnvironmentContext(execution.getVariable("networkType")) ANNFServiceInstance.setModelInvariantId(execution.getVariable("ANNF_modelInvariantUuid")) ANNFServiceInstance.setModelVersionId(execution.getVariable("ANNF_modelUuid")) ANNFServiceInstance.setWorkloadContext("AN_NF") @@ -923,7 +925,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { JsonObject commonHeader = new JsonObject() JsonObject payload = new JsonObject() JsonObject payloadInput = new JsonObject() - commonHeader.addProperty("timeStamp",new Date(System.currentTimeMillis()).format("yyyy-MM-dd'T'HH:mm:ss.sss'Z'", TimeZone.getDefault())) + commonHeader.addProperty("timestamp",new Date(System.currentTimeMillis()).format("yyyy-MM-dd'T'HH:mm:ss.sss'Z'", TimeZone.getDefault())) commonHeader.addProperty("api-ver", "1.0") commonHeader.addProperty("originator-id", "testing") commonHeader.addProperty("request-id", requestId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy index 8859af25f6..f6be861bde 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy @@ -388,12 +388,12 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { Optional<org.onap.aai.domain.yang.LogicalLink> resource = wrapper01.asBean(org.onap.aai.domain.yang.LogicalLink.class) if (resource.isPresent()) { org.onap.aai.domain.yang.LogicalLink logicalLinkInstance = resource.get() - if(domainType.equalsIgnoreCase("TN-FH")) + if(domainType.equalsIgnoreCase("TN_FH")) { execution.setVariable("tranportEp_ID_RU",logicalLinkInstance.getLinkName()) execution.setVariable("tranportEp_ID_DUIN",logicalLinkInstance.getLinkName2()) } - else if(domainType.equalsIgnoreCase("TN-MH")) + else if(domainType.equalsIgnoreCase("TN_MH")) { execution.setVariable("tranportEp_ID_DUEG",logicalLinkInstance.getLinkName()) execution.setVariable("tranportEp_ID_CUIN",logicalLinkInstance.getLinkName2()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy index 7e505d1912..146ceddab4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy @@ -142,7 +142,8 @@ class ModifySliceSubnet extends AbstractServiceTaskProcessor { ResourceOperationStatus initStatus = new ResourceOperationStatus() initStatus.setServiceId(nsiId) initStatus.setOperationId(jobId) - initStatus.setResourceTemplateUUID(modelUuid) + //initStatus.setResourceTemplateUUID(modelUuid) + initStatus.setResourceInstanceID(nssiId) initStatus.setOperType("Modify") requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn index 4012467df9..bfc8ccacb2 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn @@ -55,13 +55,13 @@ nss.sendSyncResponse(execution)</bpmn:script> <bpmn:sequenceFlow id="Flow_0ayd6dj" sourceRef="Activity_0qlstj2" targetRef="Activity_1usi32q" /> <bpmn:sequenceFlow id="Flow_0m5n6md" sourceRef="Activity_1usi32q" targetRef="Gateway_15a04ct" /> <bpmn:sequenceFlow id="Flow_1fij4ds" name="Is CN ?" sourceRef="Gateway_15a04ct" targetRef="CallDoAllocateCoreNSSI"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "CN"}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "cn"}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="Flow_0g7721r" name="Is TN ?" sourceRef="Gateway_15a04ct" targetRef="CallDoAllocateTransportNSSI"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "TN"}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "tn"}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="Flow_1kk0exp" name="Is AN ?" sourceRef="Gateway_15a04ct" targetRef="CallDoAllocateAccessNSSI"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "AN"}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "an"}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="Flow_09b50tn" sourceRef="CallDoAllocateAccessNSSI" targetRef="Event_18u424w" /> <bpmn:callActivity id="CallDoAllocateAccessNSSI" name="Call ANAllocateNSSI" calledElement="DoAllocateAccessNSSI"> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/GrpcNettyServer.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/GrpcNettyServer.java index 35c5fe1c14..7aaf558901 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/GrpcNettyServer.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/GrpcNettyServer.java @@ -26,7 +26,7 @@ import javax.annotation.PostConstruct; import org.junit.Rule; import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType; import org.onap.ccsdk.cds.controllerblueprints.common.api.Status; -import org.onap.ccsdk.cds.controllerblueprints.processing.api.BlueprintProcessingServiceGrpc.BlueprintProcessingServiceImplBase; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase; import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput; import org.slf4j.Logger; @@ -35,7 +35,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @Component -public class GrpcNettyServer extends BlueprintProcessingServiceImplBase { +public class GrpcNettyServer extends BluePrintProcessingServiceImplBase { private static final Logger logger = LoggerFactory.getLogger(GrpcNettyServer.class); @@ -55,7 +55,7 @@ public class GrpcNettyServer extends BlueprintProcessingServiceImplBase { @PostConstruct public void start() throws IOException { - final BlueprintProcessingServiceImplBase blueprintPrcessorImpl = new BlueprintProcessingServiceImplBase() { + final BluePrintProcessingServiceImplBase blueprintPrcessorImpl = new BluePrintProcessingServiceImplBase() { @Override public StreamObserver<ExecutionServiceInput> process( StreamObserver<ExecutionServiceOutput> responseObserver) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/AbstractControllerExecution.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/AbstractControllerExecution.java index f3b767a8f1..1da9ad584a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/AbstractControllerExecution.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/AbstractControllerExecution.java @@ -157,6 +157,16 @@ public abstract class AbstractControllerExecution<T> { } /** + * Check whether the controller scope is SERVICE + * + * @param controllerScope controller scope, e.g, pnf, vnf, vfModule, service + * @return true if the controller scope is service, else return false + */ + protected boolean isServiceResourceScope(final String controllerScope) { + return "service".equalsIgnoreCase(controllerScope); + } + + /** * Check whether the controller scope is VNF resource related. * * @param controllerScope controller scope, e.g, pnf, vnf, vfModule diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBB.java index 39a695b0b6..92be824691 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBB.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBB.java @@ -109,6 +109,8 @@ public class ControllerExecutionBB extends AbstractControllerExecution<BuildingB PnfResourceCustomization pnfResourceCustomization = catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(resourceCustomizationUuid); controllerActor = pnfResourceCustomization.getControllerActor(); + } else if (isServiceResourceScope(controllerScope)) { + return controllerActor; } else if (isVnfResourceScope(controllerScope)) { VnfResourceCustomization vnfResourceCustomization = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(resourceCustomizationUuid); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java index c56ab3e71d..f2f3b5da08 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java @@ -26,7 +26,9 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.client.exception.ExceptionBuilder; @@ -87,6 +89,11 @@ public class ControllerExecution { execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId()); execution.setVariable(PRC_BLUEPRINT_VERSION, pnfResourceCustomization.getBlueprintVersion()); execution.setVariable(PRC_BLUEPRINT_NAME, pnfResourceCustomization.getBlueprintName()); + } else if ("service".equalsIgnoreCase(scope)) { + GeneralBuildingBlock gbb = execution.getGeneralBuildingBlock(); + ModelInfoServiceInstance modelInfoServiceInstance = + gbb.getServiceInstance().getModelInfoServiceInstance(); + controllerActor = Optional.ofNullable(modelInfoServiceInstance.getControllerActor()).orElse("CDS"); } else { GenericVnf genericVnf = getGenericVnf(execution); String modelUuid = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid(); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java index 1fae5ce06c..5442f444ee 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java @@ -46,6 +46,7 @@ public class GenericCDSProcessingBB implements ControllerRunnable<BuildingBlockE public static final String CDS_ACTOR = "cds"; public static final String VNF_SCOPE = "vnf"; public static final String VF_MODULE_SCOPE = "vfmodule"; + public static final String SERVICE_SCOPE = "service"; @Autowired private ExceptionBuilder exceptionBuilder; @@ -59,8 +60,8 @@ public class GenericCDSProcessingBB implements ControllerRunnable<BuildingBlockE @Override public Boolean understand(ControllerContext<BuildingBlockExecution> context) { String scope = context.getControllerScope(); - return CDS_ACTOR.equalsIgnoreCase(context.getControllerActor()) - && (VNF_SCOPE.equalsIgnoreCase(scope) || VF_MODULE_SCOPE.equalsIgnoreCase(scope)); + return CDS_ACTOR.equalsIgnoreCase(context.getControllerActor()) && (SERVICE_SCOPE.equalsIgnoreCase(scope) + || VNF_SCOPE.equalsIgnoreCase(scope) || VF_MODULE_SCOPE.equalsIgnoreCase(scope)); } @Override diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java index 99cff932c5..2a8852a4bd 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java @@ -22,12 +22,14 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; +import java.io.Serializable; import java.util.ArrayList; import java.util.Comparator; import java.util.List; -public class Resource { +public class Resource implements Serializable { + private static final long serialVersionUID = 4259534487473481127L; private String resourceId; private WorkflowType resourceType; private boolean generated; @@ -37,6 +39,7 @@ public class Resource { private String vfModuleCustomizationId; private String cvnfModuleCustomizationId; private String instanceName; + private String modelInvariantId; private int processingPriority; private Resource parent; private List<Resource> children; @@ -129,6 +132,15 @@ public class Resource { this.instanceName = instanceName; } + public String getModelInvariantId() { + return modelInvariantId; + } + + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; + } + + public int getProcessingPriority() { return processingPriority == 0 ? (isBaseVfModule() ? Integer.MIN_VALUE + 1 : 0) : processingPriority; } 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 e49aed8b25..02508b8867 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 @@ -355,6 +355,7 @@ public class WorkflowAction { } else { updateResourceIdsFromAAITraversal(flowsToExecute, resourceList, aaiResourceIds, serviceInstanceId); } + execution.setVariable("resources", resourceList); return flowsToExecute; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index cd151bafea..b76cf1eb5f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -111,13 +111,15 @@ public class WorkflowActionBBTasks { } int currentSequence = (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE); - ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence); - - execution.setVariable("buildingBlock", ebb); - currentSequence++; - execution.setVariable(COMPLETED, currentSequence >= flowsToExecute.size()); - execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, currentSequence); - + boolean completed = false; + if (currentSequence < flowsToExecute.size()) { + ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence); + execution.setVariable("buildingBlock", ebb); + execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, currentSequence + 1); + } else { + completed = true; + } + execution.setVariable(COMPLETED, completed); } catch (Exception e) { workflowAction.buildAndThrowException(execution, "Internal Error occured during selectBB", e); } @@ -425,6 +427,9 @@ public class WorkflowActionBBTasks { final boolean aLaCarte = (boolean) execution.getVariable(BBConstants.G_ALACARTE); int currentSequence = (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE); logger.debug("Current Sequence: {}", currentSequence); + if (currentSequence >= flowsToExecute.size()) { + execution.setVariable(COMPLETED, true); + } ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence - 1); String bbFlowName = ebb.getBuildingBlock().getBpmnFlowName(); if ("ActivateVfModuleBB".equalsIgnoreCase(bbFlowName) && aLaCarte 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 38ba0077e2..8c6fb2b38b 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 @@ -39,6 +39,7 @@ public final class WorkflowActionConstants { public static final String CREATE_INSTANCE = "createInstance"; public static final String DEACTIVATE_INSTANCE = "deactivateInstance"; public static final String DELETE_INSTANCE = "deleteInstance"; + public static final String UPGRADE_INSTANCE = "upgradeInstance"; public static final String FABRIC_CONFIGURATION = "FabricConfiguration"; public static final String NETWORKCOLLECTION = "NetworkCollection"; public static final String RECREATE_INSTANCE = "recreateInstance"; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java index e4c6d2951f..c000e9475c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java @@ -61,6 +61,7 @@ import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConst import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.DEACTIVATE_INSTANCE; import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.DELETE_INSTANCE; import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.UNASSIGN_INSTANCE; +import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.UPGRADE_INSTANCE; import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.WORKFLOW_ACTION_ERROR_MESSAGE; import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE; import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.FABRIC_CONFIGURATION; @@ -136,6 +137,7 @@ public class ServiceEBBLoader { } } else if ((ACTIVATE_INSTANCE.equalsIgnoreCase(requestAction) || UNASSIGN_INSTANCE.equalsIgnoreCase(requestAction) || DELETE_INSTANCE.equalsIgnoreCase(requestAction) + || UPGRADE_INSTANCE.equalsIgnoreCase(requestAction) || requestAction.equalsIgnoreCase("activate" + FABRIC_CONFIGURATION))) { // SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and // SERVICE-MACRO-DELETE @@ -193,8 +195,9 @@ public class ServiceEBBLoader { ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(resourceId); org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = bbInputSetup.getExistingServiceInstance(serviceInstanceAAI); - Resource serviceResource = + var serviceResource = new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false, null); + serviceResource.setModelInvariantId(serviceInstanceAAI.getModelInvariantId()); resourceList.add(serviceResource); traverseServiceInstanceMSOVnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO); traverseServiceInstanceMSOPnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java index 272c6189b4..ff6c113af3 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java @@ -29,8 +29,10 @@ import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; import org.onap.so.bpmn.common.listener.flowmanipulator.PreFlowManipulator; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.db.catalog.beans.PnfResourceCustomization; +import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; @@ -76,11 +78,11 @@ public class SkipCDSBuildingBlockListener implements PreFlowManipulator { BuildingBlockExecution execution) { String customizationUUID = currentBB.getBuildingBlock().getKey(); - if (Strings.isEmpty(customizationUUID)) { - return; - } - - if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("VNF") + if ("SERVICE".equalsIgnoreCase(currentBB.getBuildingBlock().getBpmnScope())) { + String modelUUID = currentBB.getRequestDetails().getModelInfo().getModelUuid(); + Service service = catalogDbClient.getServiceByID(modelUUID); + currentSequenceSkipCheck(execution, service.getSkipPostInstConf()); + } else if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("VNF") && containsIgnoreCaseAction(currentBB, vnfActions)) { List<VnfResourceCustomization> vnfResourceCustomizations = catalogDbClient.getVnfResourceCustomizationByModelUuid( diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/validators/UpgradePreWorkflowValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/validators/UpgradePreWorkflowValidator.java new file mode 100644 index 0000000000..5e82b4f284 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/validators/UpgradePreWorkflowValidator.java @@ -0,0 +1,114 @@ +package org.onap.so.bpmn.infrastructure.workflow.tasks.validators; + +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import org.onap.so.bpmn.common.BBConstants; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreWorkflowValidator; +import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource; +import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType; +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; +import org.springframework.stereotype.Component; + +@Component +public class UpgradePreWorkflowValidator implements PreWorkflowValidator { + + private static final String ERR_MSG_INVARIANT_MISMATCH = + "Request service modelInvariantId: %s does not match AAI service modelInvariantId: %s"; + private static final String ERR_MSG_EXISTING_VNFS_NOT_SUPPORTED = + "Existing vnfs in AAI are not supported by service model. Unsupported vnfCustomizationIds: %s"; + + private final CatalogDbClient catalogDbClient; + + private static final Function<WorkflowType, Predicate<Resource>> resourceType = + workflowType -> resource -> resource.getResourceType() == workflowType; + + public UpgradePreWorkflowValidator(CatalogDbClient catalogDbClient) { + this.catalogDbClient = catalogDbClient; + } + + @Override + public boolean shouldRunFor(String requestAction) { + return "upgradeInstance".equalsIgnoreCase(requestAction); + } + + @Override + public Optional<String> validate(BuildingBlockExecution execution) { + final String bpmnRequest = execution.getVariable(BBConstants.G_BPMN_REQUEST); + List<Resource> resources = execution.getVariable("resources"); + + Optional<ServiceInstancesRequest> sir = parseBpmnRequest(bpmnRequest); + if (sir.isEmpty()) { + return Optional.of("Failed to parse bpmnRequest"); + } + var requestDetails = sir.get().getRequestDetails(); + String requestModelInvariantId = requestDetails.getModelInfo().getModelInvariantId(); + + Optional<String> modelInvariantMismatch = validateInvariantId(resources, requestModelInvariantId); + if (modelInvariantMismatch.isPresent()) { + return modelInvariantMismatch; + } + + List<Resource> aaiVnfResources = getVnfResources(resources); + if (aaiVnfResources.isEmpty()) { + return Optional.empty(); + } + + String serviceModelUuid = requestDetails.getModelInfo().getModelUuid(); + Optional<List<VnfResourceCustomization>> vnfResourceCustomizations = + getVnfResourceCustomizations(serviceModelUuid); + if (vnfResourceCustomizations.isEmpty()) { + return Optional.of(String.format("Service model: %s does not exist in catalog db.", serviceModelUuid)); + } + + return validateExistingVnfsSupported(aaiVnfResources, vnfResourceCustomizations.get()); + } + + private Optional<ServiceInstancesRequest> parseBpmnRequest(String bpmnRequest) { + try { + return Optional.of(new ObjectMapper().readValue(bpmnRequest, ServiceInstancesRequest.class)); + } catch (IOException e) { + return Optional.empty(); + } + } + + private Optional<String> validateInvariantId(List<Resource> resources, String requestModelInvariantId) { + return resources.stream().filter(resourceType.apply(WorkflowType.SERVICE)).findFirst() + .filter(r -> !r.getModelInvariantId().equals(requestModelInvariantId)) + .map(r -> String.format(ERR_MSG_INVARIANT_MISMATCH, requestModelInvariantId, r.getModelInvariantId())); + } + + private Optional<List<VnfResourceCustomization>> getVnfResourceCustomizations(String serviceModelUuid) { + return Optional.ofNullable(catalogDbClient.getServiceByModelUUID(serviceModelUuid)) + .map(Service::getVnfCustomizations); + } + + private List<Resource> getVnfResources(List<Resource> resources) { + return resources.stream().filter(resourceType.apply(WorkflowType.VNF)).collect(Collectors.toList()); + } + + private Optional<String> validateExistingVnfsSupported(List<Resource> vnfResources, + List<VnfResourceCustomization> vnfResourceCustomizations) { + Set<String> modeledVnfCustomizationIds = vnfResourceCustomizations.stream() + .map(VnfResourceCustomization::getModelCustomizationUUID).collect(Collectors.toSet()); + + String unsupportedVnfCustomizationIds = vnfResources.stream().map(Resource::getVnfCustomizationId) + .filter(id -> !modeledVnfCustomizationIds.contains(id)).collect(Collectors.joining(",")); + + if (unsupportedVnfCustomizationIds.isEmpty()) { + return Optional.empty(); + } + return Optional.of(String.format(ERR_MSG_EXISTING_VNFS_NOT_SUPPORTED, unsupportedVnfCustomizationIds)); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java index cc99f178bd..8c1e8f6d62 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java @@ -181,9 +181,27 @@ public class AAIServiceInstanceResources { .createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstance.getServiceInstanceId())); org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = aaiObjectMapper.mapServiceInstance(serviceInstance); + mapEmptyStringsToNull(aaiServiceInstance); injectionHelper.getAaiClient().update(serviceInstanceURI, aaiServiceInstance); } + /* + * Per serialization configurations in GraphInventoryCommonObjectMapperPatchProvider, empty strings are mapped to + * null and included in the payload. Null values are on the other hand excluded. Passing null values in a PATCH + * request to AAI will fail. We need to map empty strings to null before serialization in order to exclude these + * values from the payload. + */ + private void mapEmptyStringsToNull(org.onap.aai.domain.yang.ServiceInstance serviceInstance) { + if (serviceInstance != null) { + if ("".equals(serviceInstance.getServiceType())) + serviceInstance.setServiceType(null); + if ("".equals(serviceInstance.getServiceRole())) + serviceInstance.setServiceRole(null); + if ("".equals(serviceInstance.getServiceFunction())) + serviceInstance.setServiceFunction(null); + } + } + public boolean checkInstanceServiceNameInUse(ServiceInstance serviceInstance) { AAIPluralResourceUri uriSI = AAIUriFactory.createNodesUri(Types.SERVICE_INSTANCES.getFragment()) .queryParam("service-instance-name", serviceInstance.getServiceInstanceName()); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/GrpcNettyServer.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/GrpcNettyServer.java index a6e29227a0..a0a47a1d16 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/GrpcNettyServer.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/GrpcNettyServer.java @@ -31,7 +31,7 @@ import javax.annotation.PostConstruct; import org.junit.Rule; import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType; import org.onap.ccsdk.cds.controllerblueprints.common.api.Status; -import org.onap.ccsdk.cds.controllerblueprints.processing.api.BlueprintProcessingServiceGrpc.BlueprintProcessingServiceImplBase; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase; import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput; import org.slf4j.Logger; @@ -40,7 +40,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @Component -public class GrpcNettyServer extends BlueprintProcessingServiceImplBase { +public class GrpcNettyServer extends BluePrintProcessingServiceImplBase { private static final Logger logger = LoggerFactory.getLogger(GrpcNettyServer.class); @@ -60,7 +60,7 @@ public class GrpcNettyServer extends BlueprintProcessingServiceImplBase { @PostConstruct public void start() throws IOException { - final BlueprintProcessingServiceImplBase blueprintPrcessorImpl = new BlueprintProcessingServiceImplBase() { + final BluePrintProcessingServiceImplBase blueprintPrcessorImpl = new BluePrintProcessingServiceImplBase() { @Override public StreamObserver<ExecutionServiceInput> process( StreamObserver<ExecutionServiceOutput> responseObserver) { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index 5cd3055b5f..cbb746d514 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -149,7 +149,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { workflowActionBBTasks.selectBB(execution); boolean success = (boolean) execution.getVariable("completed"); int currentSequence = (int) execution.getVariable("gCurrentSequence"); - assertTrue(success); + assertFalse(success); assertEquals(1, currentSequence); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java index fdf4d36c89..b23147e351 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java @@ -37,6 +37,7 @@ import org.onap.so.bpmn.common.DelegateExecutionImpl; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.db.catalog.beans.PnfResourceCustomization; +import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; @@ -46,6 +47,7 @@ import org.onap.so.serviceinstancebeans.RequestDetails; @RunWith(MockitoJUnitRunner.Silent.class) public class SkipCDSBuildingBlockListenerTest { + private static final String SERVICE_SCOPE = "service"; private static final String VNF_SCOPE = "VNF"; private static final String VF_SCOPE = "VFModule"; private static final String PNF_SCOPE = "pnf"; @@ -90,6 +92,18 @@ public class SkipCDSBuildingBlockListenerTest { } @Test + public void testSkipCDSforService() { + setBuildingBlockAndCurrentSequence(SERVICE_SCOPE, "service-config-assign", 0); + Service service = new Service(); + when(catalogDbClient.getServiceByID(TEST_MODELUUID)).thenReturn(service); + + skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution); + + actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE); + assertEquals(1, actual); + } + + @Test public void testProcessForVNFToSkipCDSBB() { // given setBuildingBlockAndCurrentSequence(VNF_SCOPE, VNF_TEST_ACTION, 0); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/validators/UpgradePreWorkflowValidatorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/validators/UpgradePreWorkflowValidatorTest.java new file mode 100644 index 0000000000..1066ca1317 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/validators/UpgradePreWorkflowValidatorTest.java @@ -0,0 +1,156 @@ +package org.onap.so.bpmn.infrastructure.workflow.tasks.validators; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.when; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.so.bpmn.common.BBConstants; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource; +import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType; +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; + +public class UpgradePreWorkflowValidatorTest { + + @Mock + private CatalogDbClient catalogDbClient; + + private UpgradePreWorkflowValidator validator; + + private ObjectMapper objectMapper; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + validator = new UpgradePreWorkflowValidator(catalogDbClient); + objectMapper = new ObjectMapper(); + } + + @Test + public void shouldRunFor() { + assertTrue(validator.shouldRunFor("upgradeInstance")); + assertFalse(validator.shouldRunFor("createInstance")); + } + + private BuildingBlockExecution createExecution(ServiceInstancesRequest sir, List<Resource> resourceList) + throws JsonProcessingException { + BuildingBlockExecution mock = Mockito.mock(BuildingBlockExecution.class); + String jsonSir = objectMapper.writer().writeValueAsString(sir); + when(mock.getVariable(BBConstants.G_BPMN_REQUEST)).thenReturn(jsonSir); + when(mock.getVariable("resources")).thenReturn(resourceList); + return mock; + } + + @Test + public void validateModelInvariantMismatch() throws JsonProcessingException { + ServiceInstancesRequest sir = new ServiceInstancesRequest(); + sir.setRequestDetails(new RequestDetails()); + sir.getRequestDetails().setModelInfo(new ModelInfo()); + sir.getRequestDetails().getModelInfo().setModelInvariantId(UUID.randomUUID().toString()); + + Resource serviceResource = new Resource(WorkflowType.SERVICE, "", false, null); + String aaiModelInvariantId = UUID.randomUUID().toString(); + serviceResource.setModelInvariantId(aaiModelInvariantId); + + BuildingBlockExecution execution = createExecution(sir, Arrays.asList(serviceResource)); + + Optional<String> message = validator.validate(execution); + + assertTrue(message.isPresent()); + assertTrue(message.get().startsWith("Request service modelInvariantId")); + } + + @Test + public void validateNoVnfsInAAI() throws JsonProcessingException { + ServiceInstancesRequest sir = new ServiceInstancesRequest(); + sir.setRequestDetails(new RequestDetails()); + sir.getRequestDetails().setModelInfo(new ModelInfo()); + String modelInvariantId = UUID.randomUUID().toString(); + sir.getRequestDetails().getModelInfo().setModelInvariantId(modelInvariantId); + + Resource serviceResource = new Resource(WorkflowType.SERVICE, "", false, null); + serviceResource.setModelInvariantId(modelInvariantId); + + BuildingBlockExecution execution = createExecution(sir, Arrays.asList(serviceResource)); + + Optional<String> message = validator.validate(execution); + + assertThat(message).isEmpty(); + } + + @Test + public void validateAAIVnfsNotSupported() throws JsonProcessingException { + ServiceInstancesRequest sir = new ServiceInstancesRequest(); + sir.setRequestDetails(new RequestDetails()); + sir.getRequestDetails().setModelInfo(new ModelInfo()); + sir.getRequestDetails().getModelInfo().setModelUuid(UUID.randomUUID().toString()); + String modelInvariantId = UUID.randomUUID().toString(); + sir.getRequestDetails().getModelInfo().setModelInvariantId(modelInvariantId); + + Resource serviceResource = new Resource(WorkflowType.SERVICE, "", false, null); + serviceResource.setModelInvariantId(modelInvariantId); + Resource vnfResource = new Resource(WorkflowType.VNF, "", false, serviceResource); + vnfResource.setVnfCustomizationId(UUID.randomUUID().toString()); + + Service service = new Service(); + VnfResourceCustomization vnfCustomization = new VnfResourceCustomization(); + vnfCustomization.setModelCustomizationUUID(UUID.randomUUID().toString()); + service.setVnfCustomizations(Arrays.asList(vnfCustomization)); + + when(catalogDbClient.getServiceByModelUUID(anyString())).thenReturn(service); + + BuildingBlockExecution execution = createExecution(sir, Arrays.asList(serviceResource, vnfResource)); + + Optional<String> message = validator.validate(execution); + + assertTrue(message.isPresent()); + assertTrue(message.get().startsWith("Existing vnfs in AAI are not supported by service model")); + } + + @Test + public void validateHappyCase() throws JsonProcessingException { + ServiceInstancesRequest sir = new ServiceInstancesRequest(); + sir.setRequestDetails(new RequestDetails()); + sir.getRequestDetails().setModelInfo(new ModelInfo()); + sir.getRequestDetails().getModelInfo().setModelUuid(UUID.randomUUID().toString()); + String modelInvariantId = UUID.randomUUID().toString(); + sir.getRequestDetails().getModelInfo().setModelInvariantId(modelInvariantId); + + Resource serviceResource = new Resource(WorkflowType.SERVICE, "", false, null); + serviceResource.setModelInvariantId(modelInvariantId); + Resource vnfResource = new Resource(WorkflowType.VNF, "", false, serviceResource); + String vnfCustomiationId = UUID.randomUUID().toString(); + vnfResource.setVnfCustomizationId(vnfCustomiationId); + + Service service = new Service(); + VnfResourceCustomization vnfCustomization = new VnfResourceCustomization(); + vnfCustomization.setModelCustomizationUUID(vnfCustomiationId); + service.setVnfCustomizations(Arrays.asList(vnfCustomization)); + + when(catalogDbClient.getServiceByModelUUID(anyString())).thenReturn(service); + + BuildingBlockExecution execution = createExecution(sir, Arrays.asList(serviceResource, vnfResource)); + + Optional<String> message = validator.validate(execution); + + assertFalse(message.isPresent()); + } + +} diff --git a/common/pom.xml b/common/pom.xml index 31d715d6f3..39a980d7c8 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -14,7 +14,7 @@ <grpc.version>1.25.0</grpc.version> <protobuf.version>3.10.0</protobuf.version> <grpc.netty.version>4.1.30.Final</grpc.netty.version> - <ccsdk.version>1.1.2</ccsdk.version> + <ccsdk.version>1.1.5</ccsdk.version> <spring-cloud-sleuth.version>2.0.2.RELEASE</spring-cloud-sleuth.version> <tomcat-catalina-version>9.0.45</tomcat-catalina-version> </properties> @@ -108,6 +108,7 @@ <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> + <version>5.4.6</version> </dependency> <dependency> <groupId>org.mockito</groupId> diff --git a/common/src/main/java/org/onap/so/client/cds/CDSProcessingHandler.java b/common/src/main/java/org/onap/so/client/cds/CDSProcessingHandler.java index a0a5577402..6097f7e3fd 100644 --- a/common/src/main/java/org/onap/so/client/cds/CDSProcessingHandler.java +++ b/common/src/main/java/org/onap/so/client/cds/CDSProcessingHandler.java @@ -24,8 +24,8 @@ import io.grpc.ManagedChannel; import io.grpc.stub.StreamObserver; import java.util.concurrent.CountDownLatch; import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; -import org.onap.ccsdk.cds.controllerblueprints.processing.api.BlueprintProcessingServiceGrpc; -import org.onap.ccsdk.cds.controllerblueprints.processing.api.BlueprintProcessingServiceGrpc.BlueprintProcessingServiceStub; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceStub; import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput; import org.slf4j.Logger; @@ -50,7 +50,7 @@ class CDSProcessingHandler { final CountDownLatch finishLatch = new CountDownLatch(1); - final BlueprintProcessingServiceStub asyncStub = BlueprintProcessingServiceGrpc.newStub(channel); + final BluePrintProcessingServiceStub asyncStub = BluePrintProcessingServiceGrpc.newStub(channel); final StreamObserver<ExecutionServiceOutput> responseObserver = new StreamObserver<ExecutionServiceOutput>() { @Override diff --git a/common/src/test/java/org/onap/so/client/cds/CDSProcessingClientTest.java b/common/src/test/java/org/onap/so/client/cds/CDSProcessingClientTest.java index b92326cc89..5792c28f5f 100644 --- a/common/src/test/java/org/onap/so/client/cds/CDSProcessingClientTest.java +++ b/common/src/test/java/org/onap/so/client/cds/CDSProcessingClientTest.java @@ -41,7 +41,7 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.Mock; import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; -import org.onap.ccsdk.cds.controllerblueprints.processing.api.BlueprintProcessingServiceGrpc.BlueprintProcessingServiceImplBase; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase; import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput; @@ -72,7 +72,7 @@ public class CDSProcessingClientTest { client = new CDSProcessingClient(InProcessChannelBuilder.forName(serverName).directExecutor().build(), handler); - final BlueprintProcessingServiceImplBase routeChatImpl = new BlueprintProcessingServiceImplBase() { + final BluePrintProcessingServiceImplBase routeChatImpl = new BluePrintProcessingServiceImplBase() { @Override public StreamObserver<ExecutionServiceInput> process( StreamObserver<ExecutionServiceOutput> responseObserver) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java index 88c4bc3b04..2a91eaef5a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java @@ -26,6 +26,7 @@ public enum Action implements Actions { updateInstance, deleteInstance, configureInstance, + upgradeInstance, replaceInstance, replaceInstanceRetainAssignments, activateInstance, diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index bcbc7c7ca6..36922a878f 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -379,6 +379,24 @@ public class ServiceInstances extends AbstractRestHandler { } @POST + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/upgrade") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Operation(description = "Upgrade a Service Instance to newer model", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + @Transactional + public Response upgradeServiceInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + + return serviceInstances(request, Action.upgradeInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/replace") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) diff --git a/mso-catalog-db/pom.xml b/mso-catalog-db/pom.xml index c2bcf9b44f..c4913e6d85 100644 --- a/mso-catalog-db/pom.xml +++ b/mso-catalog-db/pom.xml @@ -73,6 +73,7 @@ <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-rest-hal-browser</artifactId> + <version>3.3.9.RELEASE</version> </dependency> <dependency> <groupId>org.ow2.asm</groupId> @@ -74,7 +74,7 @@ <appc.client.version>1.7.2</appc.client.version> <bowman.client.version>0.9.0</bowman.client.version> <aaf.cadi.version>2.1.15</aaf.cadi.version> - <so-etsi-sol003-adapter-version>1.8.1-SNAPSHOT</so-etsi-sol003-adapter-version> + <so-etsi-sol003-adapter-version>1.9.0-SNAPSHOT</so-etsi-sol003-adapter-version> <onap-logging-version>1.6.9</onap-logging-version> </properties> <distributionManagement> @@ -884,7 +884,7 @@ <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> - <version>1.12</version> + <version>1.15</version> <scope>compile</scope> </dependency> <dependency> |