diff options
61 files changed, 5081 insertions, 63 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/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql index c5a3701a82..c613f26c30 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql @@ -55,6 +55,14 @@ INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORC INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (20,'activateInstance','1','Custom recipe to activate/deactivate 3gpp service-instance if no custom BPMN flow is found','/mso/async/services/ActivateSliceSubnet',NULL,180,NULL,'2020-08-18 18:40:03','3d30a774-e149-11ea-87d0-0242ac130003'); INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (21,'deactivateInstance','1','Custom recipe to activate/deactivate 3gpp service-instance if no custom BPMN flow is found','/mso/async/services/ActivateSliceSubnet',NULL,180,NULL,'2020-08-18 18:40:03','3d30a774-e149-11ea-87d0-0242ac130003'); +-- Recipe for Service Intent + +INSERT INTO `service` (`MODEL_UUID`, `MODEL_NAME`, `MODEL_INVARIANT_UUID`, `MODEL_VERSION`, `DESCRIPTION`, `CREATION_TIMESTAMP`, `TOSCA_CSAR_ARTIFACT_UUID`) VALUES ('6790ab0e-034f-11eb-adc1-0242ac120002','COMMON_SI_DEFAULT','6790ab0e-034f-11eb-adc1-0242ac120002','1.0','Default service for Service Intent','2021-08-18 17:40:03',NULL); + +INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (22,'createInstance','1','Custom recipe to create Service Intent instance if no custom BPMN flow is found','/mso/async/services/CreateServiceIntentInstance',NULL,180,NULL,'2021-08-18 17:40:03','6790ab0e-034f-11eb-adc1-0242ac120002'); +INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (23,'deleteInstance','1','Custom recipe to delete Service Intent instance if no custom BPMN flow is found','/mso/async/services/DeleteServiceIntentInstance',NULL,180,NULL,'2021-08-18 18:40:03','6790ab0e-034f-11eb-adc1-0242ac120002'); +INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (24,'updateInstance','1','Custom recipe to modify Service Intent instance if no custom BPMN flow is found','/mso/async/services/ModifyServiceIntentInstance',NULL,180,NULL,'2021-08-18 18:40:03','6790ab0e-034f-11eb-adc1-0242ac120002'); + -- Recipe for E2E service update (R2 just support adding/deleting network service) INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (15,'updateInstance','1','Custom recipe to update E2E service-instance if no custom BPMN flow is found','/mso/async/services/UpdateCustomE2EServiceInstance',NULL,180,NULL,'2018-03-05 10:52:03','dfcd7471-16c7-444e-8268-d4c50d90593a'); INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (16,'scaleInstance','1','Custom recipe to scale E2E service-instance if no custom BPMN flow is found','/mso/async/services/ScaleCustomE2EServiceInstance',NULL,180,NULL,'2018-05-15 18:52:03','dfcd7471-16c7-444e-8268-d4c50d90593a'); 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/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-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateServiceIntentInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateServiceIntentInstance.groovy new file mode 100644 index 0000000000..303b685a38 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateServiceIntentInstance.groovy @@ -0,0 +1,153 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, Wipro Limited. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import static org.apache.commons.lang3.StringUtils.isBlank + +class CreateServiceIntentInstance extends AbstractServiceTaskProcessor { + + String Prefix = "CreateSiInstance_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + RequestDBUtil requestDBUtil = new RequestDBUtil() + JsonUtils jsonUtil = new JsonUtils() + ServiceIntentUtils serviceIntentUtils = new ServiceIntentUtils() + private static final Logger logger = LoggerFactory.getLogger(CreateServiceIntentInstance.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + serviceIntentUtils.setCommonExecutionVars(execution) + + //modelInfo + String modelInvariantUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelInvariantUuid") + if (isBlank(modelInvariantUuid)) { + msg = "Input modelInvariantUuid is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("modelInvariantUuid", modelInvariantUuid) + } + + logger.debug("modelInvariantUuid: " + modelInvariantUuid) + + String modelUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelUuid") + if (isBlank(modelUuid)) { + msg = "Input modelUuid is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("modelUuid", modelUuid) + } + + logger.debug("modelUuid: " + modelUuid) + + String additionalPropJsonStr = execution.getVariable("serviceIntentParams") + String siId = jsonUtil.getJsonValue(additionalPropJsonStr, "serviceInstanceID") //for debug + if (isBlank(siId)) { + siId = UUID.randomUUID().toString() + } + + logger.debug("serviceInstanceID: " + modelUuid) + execution.setVariable("serviceInstanceID", siId) + + String sST = jsonUtil.getJsonValue(subnetInstanceReq, "sst") + execution.setVariable("sst", sST) + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in CreateServiceIntentInstance.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String modelUuid = execution.getVariable("modelUuid") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("serviceInstanceID") + logger.debug("Generated new job for Service Instance serviceId:" + modelUuid + " jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(nsiId) // set nsiId to this field + initStatus.setOperationId(jobId) // set jobId to this field + initStatus.setResourceTemplateUUID(modelUuid) // set modelUuid to this field + initStatus.setOperType("Create") + //initStatus.setResourceInstanceID() // set nssiId to this field + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String allocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""" + .trim().replaceAll(" ", "").trim().replaceAll(" ", "") + + logger.debug("sendSyncResponse to APIH:" + "\n" + allocateSyncResponse) + sendWorkflowResponse(execution, 202, allocateSyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteServiceIntentInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteServiceIntentInstance.groovy new file mode 100644 index 0000000000..59cf5ee7fe --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteServiceIntentInstance.groovy @@ -0,0 +1,127 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, Wipro Limited. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import static org.apache.commons.lang3.StringUtils.isBlank + +class DeleteServiceIntentInstance extends AbstractServiceTaskProcessor { + String Prefix = "DCLL_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + ServiceIntentUtils serviceIntentUtils = new ServiceIntentUtils() + + private static final Logger logger = LoggerFactory.getLogger(DeleteServiceIntentInstance.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + serviceIntentUtils.setCommonExecutionVars(execution) + + String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") + if (isBlank(serviceInstanceID)) { + msg = "Input serviceInstanceID is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("serviceInstanceID", serviceInstanceID) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in DeAllocateSliceSubnet.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String siId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = siId + String modelUuid = serviceIntentUtils.getModelUuidFromServiceInstance(siId) + logger.debug("Generated new job for Service Instance serviceId:" + nsiId + " jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(nsiId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(modelUuid) + initStatus.setOperType("Delete") + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String deAllocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""".trim().replaceAll(" ", "") + + logger.debug("sendSyncResponse to APIH:" + "\n" + deAllocateSyncResponse) + sendWorkflowResponse(execution, 202, deAllocateSyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } + +} + diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineCreate.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineCreate.groovy new file mode 100644 index 0000000000..2e0f3cfd66 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineCreate.groovy @@ -0,0 +1,391 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.NetworkPolicy +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.springframework.web.util.UriUtils + +import static org.apache.commons.lang3.StringUtils.isBlank + +class DoCloudLeasedLineCreate extends AbstractServiceTaskProcessor { + + private static final Logger logger = LoggerFactory.getLogger(DoCloudLeasedLineCreate.class); + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + ServiceIntentUtils serviceIntentUtils = new ServiceIntentUtils() + ExceptionUtil exceptionUtil = new ExceptionUtil() + String Prefix = "CLLC_" + + + void preProcessRequest(DelegateExecution execution) { + logger.debug("Start preProcessRequest") + execution.setVariable("prefix", Prefix) + String msg = "" + + try { + execution.setVariable("startTime", System.currentTimeMillis()) + + msg = serviceIntentUtils.getExecutionInputParams(execution) + logger.debug("Create CLL input parameters: " + msg) + + serviceIntentUtils.setSdncCallbackUrl(execution, true) + logger.debug("SDNC Callback URL: " + execution.getVariable("sdncCallbackUrl")) + + String additionalPropJsonStr = execution.getVariable("serviceIntentParams") + + String cllId = jsonUtil.getJsonValue(additionalPropJsonStr, "serviceInstanceID") //for debug + if (isBlank(cllId)) { + cllId = UUID.randomUUID().toString() + } + + String operationId = UUID.randomUUID().toString() + execution.setVariable("operationId", operationId) + + logger.debug("Generate new CLL ID:" + cllId) + cllId = UriUtils.encode(cllId, "UTF-8") + execution.setVariable("cllId", cllId) + + String cllName = execution.getVariable("servicename") + execution.setVariable("cllName", cllName) + + String sst = execution.getVariable("sst") + execution.setVariable("sst", sst) + + String transportNetworks = jsonUtil.getJsonValue(additionalPropJsonStr, "transportNetworks") + if (isBlank(transportNetworks)) { + msg = "ERROR: preProcessRequest: Input transportNetworks is null" + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("transportNetworks", transportNetworks) + } + logger.debug("transportNetworks: " + transportNetworks) + + if (isBlank(serviceIntentUtils.setExecVarFromJsonIfExists(execution, additionalPropJsonStr, + "enableSdnc", "enableSdnc"))) { + serviceIntentUtils.setEnableSdncConfig(execution) + } + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("Finish preProcessRequest") + } + + void updateAAIOrchStatus(DelegateExecution execution) { + logger.debug("Start updateAAIOrchStatus") + String cllId = execution.getVariable("cllId") + String orchStatus = execution.getVariable("orchestrationStatus") + + try { + ServiceInstance si = new ServiceInstance() + si.setOrchestrationStatus(orchStatus) + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.Types.SERVICE_INSTANCE.getFragment(cllId)) + client.update(uri, si) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in CreateSliceService.updateAAIOrchStatus " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + logger.debug("Finish updateAAIOrchStatus") + } + + void prepareUpdateJobStatus(DelegateExecution execution, + String status, + String progress, + String statusDescription) { + String cllId = execution.getVariable("cllId") + String modelUuid = execution.getVariable("modelUuid") + String jobId = execution.getVariable("jobId") + String nsiId = cllId + String operType = "CREATE" + + ResourceOperationStatus roStatus = serviceIntentUtils.buildRoStatus(modelUuid, cllId, + jobId, nsiId, operType, status, progress, statusDescription) + + logger.debug("prepareUpdateJobStatus: roStatus={}", roStatus) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) + } + + + void createServiceInstance(DelegateExecution execution) { + + String serviceRole = "cll" + String serviceType = execution.getVariable("serviceType") + String cllId = execution.getVariable("cllId") + try { + org.onap.aai.domain.yang.ServiceInstance ss = new org.onap.aai.domain.yang.ServiceInstance() + ss.setServiceInstanceId(cllId) + String cllName = execution.getVariable("cllName") + if (isBlank(cllName)) { + logger.error("ERROR: createServiceInstance: cllName is null") + cllName = cllId + } + ss.setServiceInstanceName(cllName) + ss.setServiceType(serviceType) + String serviceStatus = "created" + ss.setOrchestrationStatus(serviceStatus) + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelUuid = execution.getVariable("modelUuid") + ss.setModelInvariantId(modelInvariantUuid) + ss.setModelVersionId(modelUuid) + ss.setEnvironmentContext("cll") + ss.setServiceRole(serviceRole) + + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(cllId)) + client.create(uri, ss) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoCloudLeasedLineCreate.createServiceInstance: " + ex.getMessage() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + + void createAllottedResource(DelegateExecution execution) { + String cllId = execution.getVariable('cllId') + + try { + List<String> networkStrList = jsonUtil.StringArrayToList(execution.getVariable("transportNetworks")) + + for (String networkStr : networkStrList) { + String networkId = jsonUtil.getJsonValue(networkStr, "id") + String allottedResourceId = isBlank(networkId) ? UUID.randomUUID().toString() : networkId + + AAIResourceUri allottedResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(execution.getVariable("cllId")) + .allottedResource(allottedResourceId)) + execution.setVariable("allottedResourceUri", allottedResourceUri) + String modelInvariantId = execution.getVariable("modelInvariantUuid") + String modelVersionId = execution.getVariable("modelUuid") + + String slaStr = jsonUtil.getJsonValue(networkStr, "sla") + if (slaStr == null || slaStr.isEmpty()) { + String msg = "ERROR: createNetworkPolicy: SLA is null" + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + org.onap.aai.domain.yang.AllottedResource resource = new org.onap.aai.domain.yang.AllottedResource() + resource.setId(allottedResourceId) + resource.setType("TsciNetwork") + resource.setAllottedResourceName("network_" + allottedResourceId) + getAAIClient().create(allottedResourceUri, resource) + + createNetworkPolicyForAllocatedResource(execution, cllId, allottedResourceId, slaStr) + + String linkArrayStr = jsonUtil.getJsonValue(networkStr, "connectionLinks") + createLogicalLinksForAllocatedResource(execution, linkArrayStr, cllId, allottedResourceId) + } + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoCloudLeasedLineCreate.createAllottedResource: " + ex.getMessage() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + void createNetworkPolicy(DelegateExecution execution, String cllId, String networkPolicyId, String slaStr) { + try { + + + NetworkPolicy networkPolicy = new NetworkPolicy(); + networkPolicy.setNetworkPolicyId(networkPolicyId) + networkPolicy.setName("TSCi policy") + networkPolicy.setType("SLA") + networkPolicy.setNetworkPolicyFqdn(cllId) + + String latencyStr = jsonUtil.getJsonValue(slaStr, "latency") + if (latencyStr != null && !latencyStr.isEmpty()) { + networkPolicy.setLatency(Integer.parseInt(latencyStr)) + } + + String bwStr = jsonUtil.getJsonValue(slaStr, "maxBandwidth") + if (bwStr != null && !bwStr.isEmpty()) { + networkPolicy.setMaxBandwidth(Integer.parseInt(bwStr)) + } else { + logger.debug("ERROR: createNetworkPolicy: maxBandwidth is null") + } + + //networkPolicy.setReliability(new Object()) + + AAIResourceUri networkPolicyUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy(networkPolicyId)) + getAAIClient().create(networkPolicyUri, networkPolicy) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + void createNetworkPolicyForAllocatedResource(DelegateExecution execution, + String cllId, + String allottedResourceId, String slaStr) { + try { + AAIResourceUri allottedResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(cllId) + .allottedResource(allottedResourceId)) + + if (!getAAIClient().exists(allottedResourceUri)) { + logger.info("ERROR: createLogicalLinksForAllocatedResource: allottedResource not exist: uri={}", + allottedResourceUri) + return + } + + String networkPolicyId = UUID.randomUUID().toString() + createNetworkPolicy(execution, cllId, networkPolicyId, slaStr) + + serviceIntentUtils.attachNetworkPolicyToAllottedResource(execution, serviceIntentUtils.AAI_VERSION, + allottedResourceUri, + networkPolicyId); + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + void createLogicalLinksForAllocatedResource(DelegateExecution execution, + String linkArrayStr, String cllId, + String allottedResourceId) { + try { + AAIResourceUri allottedResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(cllId) + .allottedResource(allottedResourceId)) + + if (!getAAIClient().exists(allottedResourceUri)) { + logger.info("ERROR: createLogicalLinksForAllocatedResource: allottedResource not exist: uri={}", + allottedResourceUri) + return + } + + List<String> linkStrList = jsonUtil.StringArrayToList(linkArrayStr) + + for (String linkStr : linkStrList) { + String linkId = jsonUtil.getJsonValue(linkStr, "name") + if (isBlank(linkId)) { + linkId = "cll-" + UUID.randomUUID().toString() + } + logger.debug("createLogicalLinksForAllocatedResource: linkId=" + linkId) + + String epA = jsonUtil.getJsonValue(linkStr, "transportEndpointA") + String epB = jsonUtil.getJsonValue(linkStr, "transportEndpointB") + String modelInvariantId = execution.getVariable("modelInvariantUuid") + String modelVersionId = execution.getVariable("modelUuid") + + org.onap.aai.domain.yang.LogicalLink resource = new org.onap.aai.domain.yang.LogicalLink() + resource.setLinkId(linkId) + resource.setLinkName(epA) + resource.setLinkName2(epB) + resource.setLinkType("TsciConnectionLink") + resource.setInMaint(false) + + //epA is link-name + AAIResourceUri logicalLinkUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(epA)) + getAAIClient().create(logicalLinkUri, resource) + + serviceIntentUtils.attachLogicalLinkToAllottedResource(execution, serviceIntentUtils.AAI_VERSION, + allottedResourceUri, epA); + } + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoCloudLeasedLineCreate.createLogicalLinksForAllocatedResource: " + ex.getMessage() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + void preprocessSdncCreateCllRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logger.trace('Entered ' + method) + + logger.trace("STARTED preProcessSDNCActivateRequest Process") + try { + String serviceInstanceId = execution.getVariable("cllId") + + String createSDNCRequest = serviceIntentUtils.buildSDNCRequest(execution, serviceInstanceId, "create") + + execution.setVariable("CLL_SDNCRequest", createSDNCRequest) + logger.debug("Outgoing SDNCRequest is: \n" + createSDNCRequest) + + } catch (Exception e) { + logger.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, + "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage()) + } + logger.trace("COMPLETED preProcessSDNCActivateRequest Process") + } + + + void validateSDNCResponse(DelegateExecution execution, String response, String method) { + serviceIntentUtils.validateSDNCResponse(execution, response, method) + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineDelete.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineDelete.groovy new file mode 100644 index 0000000000..b7f206cedc --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineDelete.groovy @@ -0,0 +1,174 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import static org.apache.commons.lang3.StringUtils.isBlank +import static org.apache.commons.lang3.StringUtils.isEmpty + +class DoCloudLeasedLineDelete extends AbstractServiceTaskProcessor { + String Prefix = "DCLL_" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + ServiceIntentUtils serviceIntentUtils = new ServiceIntentUtils() + private static final Logger logger = LoggerFactory.getLogger(DoCloudLeasedLineDelete.class) + + + void preProcessRequest(DelegateExecution execution) { + logger.debug("Start preProcessRequest") + + execution.setVariable("startTime", System.currentTimeMillis()) + String msg = serviceIntentUtils.getExecutionInputParams(execution) + logger.debug("Deallocate CLL input parameters: " + msg) + + execution.setVariable("prefix", Prefix) + + serviceIntentUtils.setSdncCallbackUrl(execution, true) + logger.debug("SDNC Callback URL: " + execution.getVariable("sdncCallbackUrl")) + + String cllId = execution.getVariable("serviceInstanceID") + execution.setVariable("cllId", cllId) + + String cllName = execution.getVariable("servicename") + execution.setVariable("cllName", cllName) + + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelUuid = execution.getVariable("modelUuid") + if (isEmpty(modelUuid)) { + modelUuid = serviceIntentUtils.getModelUuidFromServiceInstance(execution.getVariable("serviceInstanceID")) + } + def isDebugLogEnabled = true + execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + + String additionalPropJsonStr = execution.getVariable("serviceIntentParams") + if (isBlank(additionalPropJsonStr) || + isBlank(serviceIntentUtils.setExecVarFromJsonIfExists(execution, + additionalPropJsonStr, + "enableSdnc", "enableSdnc"))) { + serviceIntentUtils.setEnableSdncConfig(execution) + } + + logger.debug("Finish preProcessRequest") + } + + void preprocessSdncDeleteCllRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preprocessSdncDeallocateCllRequest(' + + 'execution=' + execution.getId() + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logger.trace('Entered ' + method) + + try { + String serviceInstanceId = execution.getVariable("serviceInstanceID") + + String sdncRequest = serviceIntentUtils.buildSDNCRequest(execution, serviceInstanceId, "delete") + + execution.setVariable("CLL_SDNCRequest", sdncRequest) + logger.debug("Outgoing SDNCRequest is: \n" + sdncRequest) + + } catch (Exception e) { + logger.debug("Exception Occurred Processing preprocessSdncDeallocateCllRequest. Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCActivateRequest Method:\n" + e.getMessage()) + } + logger.trace("COMPLETED preprocessSdncDeallocateCllRequest Process") + } + + + void validateSDNCResponse(DelegateExecution execution, String response, String method) { + serviceIntentUtils.validateSDNCResponse(execution, response, method) + } + + void deleteServiceInstance(DelegateExecution execution) { + try { + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("serviceInstanceID"))) + client.delete(uri) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoDeallocateCll.deleteServiceInstance. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + public void updateAAIOrchStatus(DelegateExecution execution) { + logger.debug("Start updateAAIOrchStatus") + String cllId = execution.getVariable("cllId") + String orchStatus = execution.getVariable("orchestrationStatus") + + try { + ServiceInstance si = new ServiceInstance() + si.setOrchestrationStatus(orchStatus) + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(cllId)) + client.update(uri, si) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in CreateSliceService.updateAAIOrchStatus " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + logger.debug("Finish updateAAIOrchStatus") + } + + void prepareUpdateJobStatus(DelegateExecution execution, + String status, + String progress, + String statusDescription) { + String cllId = execution.getVariable("cllId") + String modelUuid = execution.getVariable("modelUuid") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + + ResourceOperationStatus roStatus = serviceIntentUtils.buildRoStatus(modelUuid, cllId, + jobId, nsiId, "DELETE", status, progress, statusDescription) + + logger.debug("prepareUpdateJobStatus: roStatus={}", roStatus) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) + } +} + diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineModify.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineModify.groovy new file mode 100644 index 0000000000..5c9877840d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineModify.groovy @@ -0,0 +1,502 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.AllottedResource +import org.onap.aai.domain.yang.AllottedResources +import org.onap.aai.domain.yang.NetworkPolicy +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import static org.apache.commons.lang3.StringUtils.isBlank +import static org.apache.commons.lang3.StringUtils.isEmpty +import static org.apache.commons.lang3.StringUtils.isNotBlank + +public class DoCloudLeasedLineModify extends AbstractServiceTaskProcessor { + String Prefix = "MCLL_" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + ServiceIntentUtils serviceIntentUtils = new ServiceIntentUtils() + private static final Logger logger = LoggerFactory.getLogger(DoCloudLeasedLineModify.class) + + + void preProcessRequest(DelegateExecution execution) { + logger.debug("Start preProcessRequest") + execution.setVariable("prefix", Prefix) + String msg = "" + + try { + execution.setVariable("startTime", System.currentTimeMillis()) + msg = serviceIntentUtils.getExecutionInputParams(execution) + logger.debug("Modify CLL input parameters: " + msg) + + execution.setVariable("prefix", Prefix) + + serviceIntentUtils.setSdncCallbackUrl(execution, true) + logger.debug("SDNC Callback URL: " + execution.getVariable("sdncCallbackUrl")) + + String additionalPropJsonStr = execution.getVariable("serviceIntentParams") + if (isBlank(additionalPropJsonStr)) { + msg = "ERROR: preProcessRequest: additionalPropJsonStr is null" + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String cllId = execution.getVariable("serviceInstanceID") + if (isBlank(cllId)) { + msg = "ERROR: cllId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("cllId", cllId) + + String cllName = execution.getVariable("servicename") + execution.setVariable("cllName", cllName) + + String operationId = UUID.randomUUID().toString() + execution.setVariable("operationId", operationId) + + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelUuid = execution.getVariable("modelUuid") + if (isEmpty(modelUuid)) { + modelUuid = serviceIntentUtils.getModelUuidFromServiceInstance(execution.getVariable("serviceInstanceID")) + } + + def isDebugLogEnabled = true + execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + + + serviceIntentUtils.setExecVarFromJsonStr(execution, additionalPropJsonStr, + "transportNetworks", "transportNetworks", true) + logger.debug("transportNetworks: " + execution.getVariable("transportNetworks")) + + if (isBlank(serviceIntentUtils.setExecVarFromJsonIfExists(execution, additionalPropJsonStr, + "enableSdnc", "enableSdnc"))) { + serviceIntentUtils.setEnableSdncConfig(execution) + } + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("Finish preProcessRequest") + } + + + void deleteServiceInstance(DelegateExecution execution) { + try { + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("serviceInstanceID"))) + client.delete(uri) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoDeallocateTnNssi.deleteServiceInstance. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + + void getExistingServiceInstance(DelegateExecution execution) { + String serviceInstanceId = execution.getVariable("cllId") + + AAIResourcesClient resourceClient = getAAIClient() + AAIResourceUri ssServiceuri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) + + try { + Optional<ServiceInstance> ssOpt = resourceClient.get(ServiceInstance.class, ssServiceuri) + if (ssOpt.isPresent()) { + ServiceInstance ss = ssOpt.get() + AllottedResources ars = serviceIntentUtils.getAllottedResourcesFromAai(execution, serviceInstanceId, true) + if (ars != null) { + List<AllottedResource> arList = ars.getAllottedResource() + List<String> arIdList = new ArrayList<>() + Map<String, String> policyMap = new HashMap<>() + Map<String, List<String>> logicalLinksMap = new HashMap<>() + for (AllottedResource ar : arList) { + String arId = ar.getId() + arIdList.add(arId) + String policyId = serviceIntentUtils.getPolicyIdFromAr(execution, serviceInstanceId, arId, true) + policyMap.put(arId, policyId) + List<String> logicalLinkList = serviceIntentUtils.getLogicalLinkNamesFromAr(execution, + serviceInstanceId, arId, true) + logicalLinksMap.put(arId, logicalLinkList) + } + execution.setVariable("arIdList", arIdList) + execution.setVariable("arPolicyMap", policyMap) + execution.setVariable("arLogicalLinkMap", logicalLinksMap) + } else { + logger.error("ERROR: getExistingServiceInstance: getAllottedResources() returned null. ss=" + ss + .toString()) + } + } else { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai to " + + "associate allotted resource for service :" + serviceInstanceId) + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + String msg = "Exception in getExistingServiceInstance. " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + void updateServiceInstanceInAAI(DelegateExecution execution) { + getExistingServiceInstance(execution) + updateTsciNetworks(execution) + } + + void updateServiceInstance(DelegateExecution execution) { + String cllId = execution.getVariable("cllId") + try { + ServiceInstance ss = new ServiceInstance() + //ss.setServiceInstanceId(cllId) + String serviceStatus = "modified" + ss.setOrchestrationStatus(serviceStatus) + ss.setEnvironmentContext("tn") + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(cllId)) + client.update(uri, ss) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoModifyCllInstance.updateServiceInstance. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + + String getValidArId(DelegateExecution execution, String arIdStr) { + List<String> arIdList = execution.getVariable("arIdList") + /* + * If arId is not specified by the caller, then we assume the caller + * wants to modify the first network (i.e., allotted resource) in the TSCi tree. + */ + String arId = isBlank(arIdStr) ? arIdList.get(0) : arIdStr + + return arId + } + + void updateLogicalLinksInAr(DelegateExecution execution, String arId, String linkArrayJsonStr) { + try { + String serviceInstanceId = execution.getVariable('cllId') + + /* + * Each TSCi connection-link in linkArrayJsonStr is considered as an "ADD" new + * link to allotted-resource. So, if the link already exists under AR, then do + * nothing. Otherwise, create logical-link. + */ + List<String> linkStrList = jsonUtil.StringArrayToList(linkArrayJsonStr) + for (String linkStr : linkStrList) { + if (logicalLinkExists(execution, arId, linkStr)) { + continue + } + + createLogicalLinkForAllocatedResource(execution, linkStr, serviceInstanceId, arId) + } + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, + "Exception in updateLogicalLinksInAr" + ex.getMessage()) + } + } + + void updateLogicalLinksInNetwork(DelegateExecution execution, String networkJsonStr) { + try { + String arId = getValidArId(execution, jsonUtil.getJsonValue(networkJsonStr, "id")) + String linkArrayStr = jsonUtil.getJsonValue(networkJsonStr, "connectionLinks") + updateLogicalLinksInAr(execution, arId, linkArrayStr) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = String.format("ERROR: updateLogicalLinksInNetwork: exception: %s", ex.getMessage()) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); + } + } + + void updateTsciNetworks(DelegateExecution execution) { + try { + List<String> networkStrList = jsonUtil.StringArrayToList(execution.getVariable("transportNetworks")) + for (String networkStr : networkStrList) { + updateLogicalLinksInNetwork(execution, networkStr) + updateNetworkPolicy(execution, networkStr) + } + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, + "Exception in updateTsciNetworks" + ex.getMessage()) + } + } + + int getMaxBwFromNetworkJsonStr(DelegateExecution execution, String networkJsonStr) { + int maxBw = 0 + try { + if (isBlank(networkJsonStr)) { + String msg = "ERROR: getMaxBw: networkJsonStr is null" + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + String slaStr = jsonUtil.getJsonValue(networkJsonStr, "sla") + if (isBlank(slaStr)) { + String msg = "ERROR: getMaxBw: slaStr is null" + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + String bwStr = jsonUtil.getJsonValue(slaStr, "maxBandwidth") + if (isNotBlank(bwStr)) { + maxBw = Integer.parseInt(bwStr) + } else { + logger.error("ERROR: getMaxBw: maxBandwidth is null") + } + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, + "Exception in getMaxBw" + ex.getMessage()) + } + + return maxBw + } + + void updatePolicyMaxBandwidthInAAI(DelegateExecution execution, String policyId, int maxBw) { + try { + NetworkPolicy networkPolicy = new NetworkPolicy() + networkPolicy.setMaxBandwidth(maxBw) + AAIResourceUri networkPolicyUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy(policyId)) + getAAIClient().update(networkPolicyUri, networkPolicy) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoModifyCllInstance.updatePolicyMaxBandwidthInAAI. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + void updateNetworkPolicy(DelegateExecution execution, String networkJsonStr) { + try { + int maxBw = getMaxBwFromNetworkJsonStr(execution, networkJsonStr) + + String arId = getValidArId(execution, jsonUtil.getJsonValue(networkJsonStr, "id")) + Map<String, String> policyMap = execution.getVariable("arPolicyMap") + String policyId = policyMap.get(arId) + if (isBlank(policyId)) { + String msg = String.format("ERROR: updateNetworkPolicy: policyId not found. arId=%s", arId) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + updatePolicyMaxBandwidthInAAI(execution, policyId, maxBw) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = String.format("ERROR: updateNetworkPolicy: exception: %s", ex.getMessage()) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); + } + } + + + void createLogicalLinkForAllocatedResource(DelegateExecution execution, + String linkJsonStr, String cllId, + String allottedResourceId) { + try { + AAIResourceUri allottedResourceUri = serviceIntentUtils.buildAllottedResourceUri(execution, + cllId, allottedResourceId) + + if (!getAAIClient().exists(allottedResourceUri)) { + logger.info("ERROR: createLogicalLinksForAllocatedResource: allottedResource not exist: uri={}", + allottedResourceUri) + return + } + + String linkId = jsonUtil.getJsonValue(linkJsonStr, "id") + if (isBlank(linkId)) { + linkId = "cll-" + UUID.randomUUID().toString() + } + logger.debug("createLogicalLinkForAllocatedResource: linkId=" + linkId) + + String epA = jsonUtil.getJsonValue(linkJsonStr, "transportEndpointA") + String epB = jsonUtil.getJsonValue(linkJsonStr, "transportEndpointB") + String modelInvariantId = execution.getVariable("modelInvariantUuid") + String modelVersionId = execution.getVariable("modelUuid") + + org.onap.aai.domain.yang.LogicalLink resource = new org.onap.aai.domain.yang.LogicalLink() + resource.setLinkId(linkId) + resource.setLinkName(epA) + resource.setLinkName2(epB) + resource.setLinkType("TsciConnectionLink") + resource.setInMaint(false) + + //epA is link-name + AAIResourceUri logicalLinkUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(epA)) + getAAIClient().create(logicalLinkUri, resource) + + serviceIntentUtils.attachLogicalLinkToAllottedResource(execution, serviceIntentUtils.AAI_VERSION, + allottedResourceUri, epA); + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoModifyCllInstance.createLogicalLinksForAllocatedResource: " + ex.getMessage() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + + void preprocessSdncModifyCllRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preprocessSdncModifyCllRequest(' + + 'execution=' + execution.getId() + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logger.trace('Entered ' + method) + + try { + String serviceInstanceId = execution.getVariable("cllId") + + String sdncRequest = serviceIntentUtils.buildSDNCRequest(execution, serviceInstanceId, "update") + + execution.setVariable("CLL_SDNCRequest", sdncRequest) + logger.debug("Outgoing SDNCRequest is: \n" + sdncRequest) + + } catch (BpmnError e) { + throw e + } catch (Exception e) { + logger.debug("Exception Occurred Processing preprocessSdncModifyCllRequest. Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCActivateRequest Method:\n" + e.getMessage()) + } + logger.trace("COMPLETED preprocessSdncModifyCllRequest Process") + } + + + void validateSDNCResponse(DelegateExecution execution, String response, String method) { + serviceIntentUtils.validateSDNCResponse(execution, response, method) + } + + + void updateAAIOrchStatus(DelegateExecution execution) { + logger.debug("Start updateAAIOrchStatus") + String cllId = execution.getVariable("cllId") + String orchStatus = execution.getVariable("orchestrationStatus") + + try { + ServiceInstance si = new ServiceInstance() + si.setOrchestrationStatus(orchStatus) + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(cllId)) + client.update(uri, si) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in CreateSliceService.updateAAIOrchStatus " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + logger.debug("Finish updateAAIOrchStatus") + } + + void prepareUpdateJobStatus(DelegateExecution execution, + String status, + String progress, + String statusDescription) { + String cllId = execution.getVariable("cllId") + String modelUuid = execution.getVariable("modelUuid") + String jobId = execution.getVariable("jobId") + String nsiId = cllId + String operType = "MODIFY" + + ResourceOperationStatus roStatus = serviceIntentUtils.buildRoStatus(modelUuid, cllId, + jobId, nsiId, operType, status, progress, statusDescription) + + logger.debug("prepareUpdateJobStatus: roStatus={}", roStatus) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) + } + + boolean logicalLinkExists(DelegateExecution execution, String arIdStr, String linkJsonStr) { + if (isBlank(arIdStr)) { + logger.error("ERROR: logicalLinkExists: arIdStr is empty") + return false + } + if (isBlank(linkJsonStr)) { + logger.error("ERROR: logicalLinkExists: linkJsonStr is empty") + return false + } + + Map<String, List<String>> logicalLinksMap = execution.getVariable("arLogicalLinkMap") + if (logicalLinksMap == null) { + logger.error("ERROR: logicalLinkExists: logicalLinksMap is null") + return false + } + + List<String> logicalLinkNameList = logicalLinksMap.get(arIdStr) + if (logicalLinksMap == null) { + logger.error("ERROR: logicalLinkExists: logicalLinkNameList is null. arIdStr=" + arIdStr) + return false + } + + String linkName = jsonUtil.getJsonValue(linkJsonStr, "transportEndpointA") + if (isBlank(linkName)) { + logger.error("ERROR: logicalLinkExists: epA is empty") + return false + } + + return logicalLinkNameList.contains(linkName) + } +} + diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifyServiceIntentInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifyServiceIntentInstance.groovy new file mode 100644 index 0000000000..df817ed90b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifyServiceIntentInstance.groovy @@ -0,0 +1,128 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, Wipro Limited. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import static org.apache.commons.lang3.StringUtils.isBlank + +class ModifyServiceIntentInstance extends AbstractServiceTaskProcessor { + String Prefix="MCLL_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + ServiceIntentUtils serviceIntentUtils = new ServiceIntentUtils() + + private static final Logger logger = LoggerFactory.getLogger(ModifyServiceIntentInstance.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + serviceIntentUtils.setCommonExecutionVars(execution) + + String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") + if (isBlank(serviceInstanceID)) { + msg = "Input serviceInstanceID is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("serviceInstanceID", serviceInstanceID) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in ModifyServiceIntentInstance.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String siId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = siId + String modelUuid = serviceIntentUtils.getModelUuidFromServiceInstance(siId) + logger.debug("Generated new job for Service Instance serviceId:" + nsiId + "jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(nsiId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(modelUuid) + initStatus.setOperType("Modify") + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String modifySyncResponse = """{"jobId": "${jobId}","status": "processing"}""" + .trim().replaceAll(" ", "") + logger.debug("sendSyncResponse to APIH:" + "\n" + modifySyncResponse) + sendWorkflowResponse(execution, 202, modifySyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ServiceIntentUtils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ServiceIntentUtils.groovy new file mode 100644 index 0000000000..f60bfa1c47 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ServiceIntentUtils.groovy @@ -0,0 +1,669 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.AllottedResources +import org.onap.aai.domain.yang.LogicalLink +import org.onap.aai.domain.yang.NetworkPolicy +import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.AAIVersion +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.Relationships +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import static org.apache.commons.lang3.StringUtils.isBlank +import static org.apache.commons.lang3.StringUtils.isNotBlank + +class ServiceIntentUtils { + static final String AAI_VERSION = AAIVersion.LATEST + private static final Logger logger = LoggerFactory.getLogger(ServiceIntentUtils.class); + + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + MsoUtils msoUtils = new MsoUtils() + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + + ServiceIntentUtils() { + } + + + void setCommonExecutionVars(DelegateExecution execution) { + setCommonExecutionVars(execution, true) + } + + void setCommonExecutionVars(DelegateExecution execution, boolean exceptionOnErr) { + def msg + try { + // get request input + String bpmnRequestStr = execution.getVariable("bpmnRequest") + logger.debug("Input Request: " + bpmnRequestStr) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("requestId: " + requestId) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(bpmnRequestStr, "globalSubscriberId") + if (isBlank(globalSubscriberId) && exceptionOnErr) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + String serviceType = jsonUtil.getJsonValue(bpmnRequestStr, "serviceType") + if (isBlank(serviceType) && exceptionOnErr) { + msg = "Input serviceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("serviceType", serviceType) + } + + String servicename = jsonUtil.getJsonValue(bpmnRequestStr, "name") + if (isNotBlank(servicename)) { + execution.setVariable("servicename", servicename) + } else { + logger.debug("erviceIntentUtils.setCommonExecutionVars: servicename is NOT set") + } + + //requestParameters, subscriptionServiceType is 5G + String subscriptionServiceType = jsonUtil.getJsonValue(bpmnRequestStr, "subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + String sliceParams = jsonUtil.getJsonValue(bpmnRequestStr, "additionalProperties") + execution.setVariable("serviceIntentParams", sliceParams) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in ServiceIntentUtils.setCommonExecutionVars: " + ex.getMessage() + logger.debug(msg) + if (exceptionOnErr) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + } + + void setSdncCallbackUrl(DelegateExecution execution, boolean exceptionOnErr) { + setSdncCallbackUrl(execution, "sdncCallbackUrl", exceptionOnErr) + } + + void setSdncCallbackUrl(DelegateExecution execution, String variableName, boolean exceptionOnErr) { + String sdncCallbackUrl = UrnPropertiesReader.getVariable('mso.workflow.sdncadapter.callback', execution) + + if (isBlank(sdncCallbackUrl) && exceptionOnErr) { + String msg = "mso.workflow.sdncadapter.callback is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable(variableName, sdncCallbackUrl) + } + } + + String buildSDNCRequest(DelegateExecution execution, String svcInstId, String svcAction) { + String reqAction + switch (svcAction) { + case "create": + reqAction = "CreateCloudLeasedLineInstance" + break + case "delete": + reqAction = "DeleteCloudLeasedLineInstance" + break + case "activate": + reqAction = "ActivateCloudLeasedLineInstance" + break + case "deactivate": + reqAction = "DeactivateCloudLeasedLineInstance" + break + case "update": + reqAction = "ModifyCloudLeasedLineInstance" + break + default: + reqAction = svcAction + } + + buildSDNCRequest(execution, svcInstId, svcAction, reqAction) + } + + String buildSDNCRequest(DelegateExecution execution, String svcInstId, String svcAction, String reqAction) { + + String uuid = execution.getVariable('testReqId') // for junits + if (uuid == null) { + uuid = execution.getVariable("msoRequestId") + "-" + System.currentTimeMillis() + } + + def callbackURL = execution.getVariable("sdncCallbackUrl") + def requestId = execution.getVariable("msoRequestId") + def serviceId = execution.getVariable("sliceServiceInstanceId") + def subServiceType = execution.getVariable("subscriptionServiceType") + def vnfType = execution.getVariable("serviceType") + def vnfName = execution.getVariable("sliceServiceInstanceName") + def tenantId = execution.getVariable("sliceServiceInstanceId") + def source = execution.getVariable("sliceServiceInstanceId") + def vnfId = execution.getVariable("sliceServiceInstanceId") + def cloudSiteId = execution.getVariable("sliceServiceInstanceId") + def serviceModelInfo = execution.getVariable("serviceModelInfo") + def vnfModelInfo = execution.getVariable("serviceModelInfo") + def globalSubscriberId = execution.getVariable("globalSubscriberId") + + String vnfNameString = """<vnf-name>${MsoUtils.xmlEscape(vnfName)}</vnf-name>""" + String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo) + String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo) + + String sdncVNFParamsXml = "" + + if (execution.getVariable("vnfParamsExistFlag") == true) { + sdncVNFParamsXml = buildSDNCParamsXml(execution) + } else { + sdncVNFParamsXml = buildDefaultVnfInputParams(vnfId) + } + + String sdncRequest = + """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1" + xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" + xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1"> + <sdncadapter:RequestHeader> + <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId> + <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId> + <sdncadapter:SvcAction>${MsoUtils.xmlEscape(svcAction)}</sdncadapter:SvcAction> + <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation> + <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl> + <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> + </sdncadapter:RequestHeader> + <sdncadapterworkflow:SDNCRequestData> + <request-information> + <request-id>${MsoUtils.xmlEscape(requestId)}</request-id> + <request-action>${MsoUtils.xmlEscape(reqAction)}</request-action> + <source>${MsoUtils.xmlEscape(source)}</source> + <notification-url/> + <order-number/> + <order-version/> + </request-information> + <service-information> + <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id> + <subscription-service-type>${MsoUtils.xmlEscape(subServiceType)}</subscription-service-type> + ${serviceEcompModelInformation} + <service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id> + <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id> + </service-information> + <vnf-information> + <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> + <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type> + ${vnfEcompModelInformation} + </vnf-information> + <vnf-request-input> + ${vnfNameString} + <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant> + <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region> + ${sdncVNFParamsXml} + </vnf-request-input> + </sdncadapterworkflow:SDNCRequestData> + </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" + + logger.debug("sdncRequest: " + sdncRequest) + return sdncRequest + } + + + String buildDefaultVnfInputParams(String vnfName) { + String res = + """<vnf-input-parameters> + <param> + <name>${MsoUtils.xmlEscape(vnfName)}</name> + </param> + </vnf-input-parameters>""" + + return res + } + + String buildSDNCParamsXml(DelegateExecution execution) { + String params = "" + StringBuilder sb = new StringBuilder() + Map<String, String> paramsMap = execution.getVariable("TNNSSMF_vnfParamsMap") + + for (Map.Entry<String, String> entry : paramsMap.entrySet()) { + String paramsXml + String key = entry.getKey(); + String value = entry.getValue() + paramsXml = """<${key}>$value</$key>""" + params = sb.append(paramsXml) + } + return params + } + + void validateSDNCResponse(DelegateExecution execution, String response, String method) { + validateSDNCResponse(execution, response, method, true) + } + + void validateSDNCResponse(DelegateExecution execution, String response, String method, boolean exceptionOnErr) { + logger.debug("STARTED ValidateSDNCResponse Process") + + String msg + + String prefix = execution.getVariable("prefix") + if (isBlank(prefix)) { + if (exceptionOnErr) { + msg = "validateSDNCResponse: prefix is null" + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + return + } + + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + logger.debug("ServiceIntentUtils.validateSDNCResponse: SDNCResponse: " + response) + logger.debug("ServiceIntentUtils.validateSDNCResponse: workflowException: " + workflowException) + + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + String sdncResponse = response + if (execution.getVariable(prefix + 'sdncResponseSuccess') == true) { + logger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse) + RollbackData rollbackData = execution.getVariable("rollbackData") + if (rollbackData == null) { + rollbackData = new RollbackData() + } + + if (method.equals("allocate")) { + rollbackData.put("VNFMODULE", "rollbackSDNCRequestAllocate", "true") + } else if (method.equals("deallocate")) { + rollbackData.put("VNFMODULE", "rollbackSDNCRequestDeallocate", "true") + } else if (method.equals("activate")) { + rollbackData.put("VNFMODULE", "rollbackSDNCRequestActivate", "true") + } else if (method.equals("deactivate")) { + rollbackData.put("VNFMODULE", "rollbackSDNCRequestDeactivate", "true") + } else if (method.equals("modify")) { + rollbackData.put("VNFMODULE", "rollbackSDNCRequestModify", "true") + } + execution.setVariable("rollbackData", rollbackData) + } else { + if (exceptionOnErr) { + msg = "ServiceIntentUtils.validateSDNCResponse: bad Response from SDNC Adapter for " + method + " SDNC Call." + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + } + + logger.debug("COMPLETED ValidateSDNCResponse Process") + } + + String getExecutionInputParams(DelegateExecution execution) { + String res = "\n msoRequestId=" + execution.getVariable("msoRequestId") + + "\n modelInvariantUuid=" + execution.getVariable("modelInvariantUuid") + + "\n modelUuid=" + execution.getVariable("modelUuid") + + "\n serviceInstanceID=" + execution.getVariable("serviceInstanceID") + + "\n operationType=" + execution.getVariable("operationType") + + "\n globalSubscriberId=" + execution.getVariable("globalSubscriberId") + + "\n dummyServiceId=" + execution.getVariable("dummyServiceId") + + "\n nsiId=" + execution.getVariable("nsiId") + + "\n serviceType=" + execution.getVariable("serviceType") + + "\n subscriptionServiceType=" + execution.getVariable("subscriptionServiceType") + + "\n jobId=" + execution.getVariable("jobId") + + "\n serviceIntentParams=" + execution.getVariable("serviceIntentParams") + + "\n servicename=" + execution.getVariable("servicename") + + return res + } + + String getFirstSnssaiFromSliceProfile(String sliceProfileStr) { + String snssaiListStr = jsonUtil.getJsonValue(sliceProfileStr, "snssaiList") + String snssai = jsonUtil.StringArrayToList(snssaiListStr).get(0) + + return snssai + } + + String getFirstPlmnIdFromSliceProfile(String sliceProfileStr) { + String plmnListStr = jsonUtil.getJsonValue(sliceProfileStr, "plmnIdList") + String res = jsonUtil.StringArrayToList(plmnListStr).get(0) + + return res + } + + void createRelationShipInAAI(DelegateExecution execution, AAIResourceUri uri, Relationship relationship) { + logger.debug("createRelationShipInAAI Start") + String msg + AAIResourcesClient client = new AAIResourcesClient() + try { + if (!client.exists(uri)) { + logger.info("ERROR: createRelationShipInAAI: not exist: uri={}", uri) + return + } + AAIResourceUri from = ((AAIResourceUri) (uri.clone())).relationshipAPI() + client.create(from, relationship) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in createRelationShipInAAI. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("createRelationShipInAAI Exit") + } + + void attachLogicalLinkToAllottedResource(DelegateExecution execution, String aaiVersion, AAIResourceUri arUri, + String logicalLinkId) { + + String toLink = "aai/${aaiVersion}/network/logical-links/logical-link/${logicalLinkId}" + + Relationship relationship = new Relationship() + relationship.setRelatedLink(toLink) + relationship.setRelatedTo("logical-link") + relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf") + + createRelationShipInAAI(execution, arUri, relationship) + } + + void attachNetworkPolicyToAllottedResource(DelegateExecution execution, String aaiVersion, + AAIResourceUri aaiResourceUri, String networkPolicyId) { + + String toLink = "aai/${aaiVersion}/network/network-policies/network-policy/${networkPolicyId}" + + Relationship relationship = new Relationship() + relationship.setRelatedLink(toLink) + relationship.setRelatedTo("network-policy") + relationship.setRelationshipLabel("org.onap.relationships.inventory.Uses") + + createRelationShipInAAI(execution, aaiResourceUri, relationship) + + } + + ResourceOperationStatus buildRoStatus(String nsstId, + String nssiId, + String jobId, + String nsiId, + String action, + String status, + String progress, + String statusDescription) { + ResourceOperationStatus roStatus = new ResourceOperationStatus() + roStatus.setResourceTemplateUUID(nsstId) + roStatus.setResourceInstanceID(nssiId) + roStatus.setServiceId(nsiId) + roStatus.setOperationId(jobId) + roStatus.setOperType(action) + roStatus.setProgress(progress) + roStatus.setStatus(status) + roStatus.setStatusDescription(statusDescription) + + return roStatus + } + + + void setEnableSdncConfig(DelegateExecution execution) { + String enableSdnc = UrnPropertiesReader.getVariable( + "mso.workflow.TnNssmf.enableSDNCNetworkConfig") + if (isBlank(enableSdnc)) { + logger.debug("mso.workflow.TnNssmf.enableSDNCNetworkConfig is undefined, so use default value (true)") + enableSdnc = "true" + } + + logger.debug("setEnableSdncConfig: enableSdnc=" + enableSdnc) + + execution.setVariable("enableSdnc", enableSdnc) + } + + String setExecVarFromJsonIfExists(DelegateExecution execution, + String jsonStr, String jsonKey, String varName) { + return setExecVarFromJsonStr(execution, jsonStr, jsonKey, varName, false) + } + + String setExecVarFromJsonStr(DelegateExecution execution, + String jsonStr, String jsonKey, String varName, + boolean exceptionOnErr) { + String msg = "" + String valueStr = jsonUtil.getJsonValue(jsonStr, jsonKey) + if (isBlank(valueStr)) { + if (exceptionOnErr) { + msg = "cannot find " + jsonKey + " in " + jsonStr + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + } else { + execution.setVariable(varName, valueStr) + } + + return valueStr + } + + ServiceInstance getServiceInstanceFromAai(String serviceInstanceId) { + if (isBlank(serviceInstanceId)) { + logger.error("ERROR: getServiceInstanceFromAai: serviceInstanceId is blank") + return null + } + + ServiceInstance nssi = null + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.Types.SERVICE_INSTANCE + .getFragment(serviceInstanceId)) + Optional<ServiceInstance> nssiOpt = client.get(ServiceInstance.class, uri) + + if (nssiOpt.isPresent()) { + nssi = nssiOpt.get() + return nssi + } else { + String msg = String.format("ERROR: getServiceInstanceFromAai: NSSI %s not found in AAI", serviceInstanceId) + logger.error(msg) + } + + return nssi; + } + + String getModelUuidFromServiceInstance(String serviceInstanceId) { + ServiceInstance si = getServiceInstanceFromAai(serviceInstanceId) + if (si == null) { + String msg = String.format("ERROR: getModelUuidFromServiceInstance: getServiceInstanceFromAai() failed. " + + "serviceInstanceId=%s", serviceInstanceId) + logger.error(msg) + return null + } + + return si.getModelVersionId() + } + + AAIResourceUri buildNetworkPolicyUri(String networkPolicyId) { + AAIResourceUri networkPolicyUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy(networkPolicyId)) + + return networkPolicyUri + } + + AAIResourceUri buildAllottedResourceUri(DelegateExecution execution, String serviceInstanceId, + String allottedResourceId) { + + AAIResourceUri allottedResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(serviceInstanceId) + .allottedResource(allottedResourceId)) + + return allottedResourceUri + } + + AAIPluralResourceUri buildAllottedResourcesUri(DelegateExecution execution, String serviceInstanceId) { + + AAIPluralResourceUri arsUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(serviceInstanceId) + .allottedResources()) + + return arsUri + } + + AllottedResources getAllottedResourcesFromAai(DelegateExecution execution, String serviceInstanceId, boolean exceptionOnErr) { + AllottedResources res + try { + AAIResourcesClient client = new AAIResourcesClient() + + AAIPluralResourceUri arsUri = buildAllottedResourcesUri(execution, serviceInstanceId) + + //AAIResultWrapper wrapperAllotted = client.get(arsUri, NotFoundException.class) + //Optional<AllottedResources> allAllotted = wrapperAllotted.asBean(AllottedResources.class) + //AllottedResources allottedResources = allAllotted.get() + + Optional<AllottedResources> arsOpt = client.get(AllottedResources.class, arsUri) + if (arsOpt.isPresent()) { + res = arsOpt.get() + return res + } else { + String msg = String.format("ERROR: getAllottedResourcesFromAai: ars not found. nssiId=%s", serviceInstanceId) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } catch (BpmnError e) { + if (exceptionOnErr) { + throw e; + } + } catch (Exception ex) { + if (exceptionOnErr) { + String msg = String.format("ERROR: getAllottedResourcesFromAai: %s", ex.getMessage()) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + + return res + } + + String getPolicyIdFromAr(DelegateExecution execution, String serviceInstanceId, + String arId, boolean exceptionOnErr) { + String res + try { + AAIResourcesClient client = new AAIResourcesClient() + + AAIResourceUri arUri = buildAllottedResourceUri(execution, serviceInstanceId, arId) + List<AAIResourceUri> policyUriList = getRelationshipUriListInAai(execution, arUri, + AAIFluentTypeBuilder.Types.NETWORK_POLICY, exceptionOnErr) + for (AAIResourceUri policyUri : policyUriList) { + Optional<NetworkPolicy> policyOpt = client.get(NetworkPolicy.class, policyUri) + if (policyOpt.isPresent()) { + NetworkPolicy policy = policyOpt.get() + return policy.getNetworkPolicyId() + } else { + String msg = String.format("ERROR: getPolicyIdFromAr: arUri=%s", policyUri) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + } catch (BpmnError e) { + if (exceptionOnErr) { + throw e; + } + } catch (Exception ex) { + if (exceptionOnErr) { + String msg = String.format("ERROR: getPolicyIdFromAr: %s", ex.getMessage()) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + + return res + } + + + List<AAIResourceUri> getRelationshipUriListInAai(DelegateExecution execution, + AAIResourceUri uri, + Object info, + boolean exceptionOnErr) { + AAIResourcesClient client = new AAIResourcesClient() + AAIResultWrapper wrapper = client.get(uri); + Optional<Relationships> relationships = wrapper.getRelationships() + if (relationships.isPresent()) { + return relationships.get().getRelatedUris(info) + } else { + if (exceptionOnErr) { + String msg = "ERROR: getRelationshipUriListInAai: No relationship found" + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + + return null + } + + List<String> getLogicalLinkNamesFromAr(DelegateExecution execution, String serviceInstanceId, + String arId, boolean exceptionOnErr) { + List<String> res = new ArrayList<>() + try { + AAIResourcesClient client = new AAIResourcesClient() + + AAIResourceUri arUri = buildAllottedResourceUri(execution, serviceInstanceId, arId) + List<AAIResourceUri> logicalLinkUriList = getRelationshipUriListInAai(execution, arUri, + AAIFluentTypeBuilder.Types.LOGICAL_LINK, exceptionOnErr) + for (AAIResourceUri logicalLinkUri : logicalLinkUriList) { + Optional<LogicalLink> logicalLinkOpt = client.get(LogicalLink.class, logicalLinkUri) + if (logicalLinkOpt.isPresent()) { + LogicalLink logicalLink = logicalLinkOpt.get() + res.add(logicalLink.getLinkName()) + } else { + String msg = String.format("ERROR: getLogicalLinkNamesFromAr: logicalLinkUri=%s", logicalLinkUri) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + } catch (BpmnError e) { + if (exceptionOnErr) { + throw e; + } + } catch (Exception ex) { + if (exceptionOnErr) { + String msg = String.format("ERROR: getLogicalLinkNamesFromAr: %s", ex.getMessage()) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + + return res + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateServiceIntentInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateServiceIntentInstance.bpmn new file mode 100644 index 0000000000..7e8290d728 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateServiceIntentInstance.bpmn @@ -0,0 +1,175 @@ +<?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: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" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_04bdlh3" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="CreateServiceIntentInstance" name="CreateServiceIntentInstance" isExecutable="true"> + <bpmn:startEvent id="Event_16inlk9" name="Start"> + <bpmn:outgoing>Flow_0cmaj9d</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="Activity_1hyt0pb" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_0cmaj9d</bpmn:incoming> + <bpmn:outgoing>Flow_0ou7wr9</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new CreateServiceIntentInstance() +nss.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1usi32q" name="Send Sync Response" scriptFormat="groovy"> + <bpmn:incoming>Flow_0ayd6dj</bpmn:incoming> + <bpmn:outgoing>Flow_0m5n6md</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new CreateServiceIntentInstance() +nss.sendSyncResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_15a04ct" name="which Intent service ?"> + <bpmn:incoming>Flow_0m5n6md</bpmn:incoming> + <bpmn:outgoing>Flow_1fij4ds</bpmn:outgoing> + <bpmn:outgoing>Flow_0g7721r</bpmn:outgoing> + <bpmn:outgoing>Flow_1kk0exp</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="Event_18u424w"> + <bpmn:incoming>Flow_189zwjw</bpmn:incoming> + <bpmn:incoming>Flow_1fij4ds</bpmn:incoming> + <bpmn:incoming>Flow_1kk0exp</bpmn:incoming> + </bpmn:endEvent> + <bpmn:serviceTask id="Activity_0qlstj2" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${initResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_18cgkru</bpmn:incoming> + <bpmn:outgoing>Flow_0ayd6dj</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0cmaj9d" sourceRef="Event_16inlk9" targetRef="Activity_1hyt0pb" /> + <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="Other" sourceRef="Gateway_15a04ct" targetRef="Event_18u424w"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("serviceType") != "CLL"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0g7721r" name="Clould Leased Line" sourceRef="Gateway_15a04ct" targetRef="CallDoCloudLeasedLineCreate"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("serviceType") == "CLL"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1kk0exp" sourceRef="Gateway_15a04ct" targetRef="Event_18u424w"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "AN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:scriptTask id="Activity_1ydx2rx" name="Init Resource Operation Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0ou7wr9</bpmn:incoming> + <bpmn:outgoing>Flow_18cgkru</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new CreateServiceIntentInstance() +nss.prepareInitOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0ou7wr9" sourceRef="Activity_1hyt0pb" targetRef="Activity_1ydx2rx" /> + <bpmn:sequenceFlow id="Flow_18cgkru" sourceRef="Activity_1ydx2rx" targetRef="Activity_0qlstj2" /> + <bpmn:sequenceFlow id="Flow_189zwjw" sourceRef="CallDoCloudLeasedLineCreate" targetRef="Event_18u424w" /> + <bpmn:callActivity id="CallDoCloudLeasedLineCreate" name="Call CloudLeasedLineCreate" calledElement="DoCloudLeasedLineCreate"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="modelInvariantUuid" target="modelInvariantUuid" /> + <camunda:in source="modelUuid" target="modelUuid" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="serviceType" target="serviceType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="serviceIntentParams" target="serviceIntentParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0g7721r</bpmn:incoming> + <bpmn:outgoing>Flow_189zwjw</bpmn:outgoing> + </bpmn:callActivity> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateServiceIntentInstance"> + <bpmndi:BPMNEdge id="Flow_189zwjw_di" bpmnElement="Flow_189zwjw"> + <di:waypoint x="1080" y="230" /> + <di:waypoint x="1170" y="230" /> + <di:waypoint x="1170" y="148" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_18cgkru_di" bpmnElement="Flow_18cgkru"> + <di:waypoint x="480" y="130" /> + <di:waypoint x="550" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ou7wr9_di" bpmnElement="Flow_0ou7wr9"> + <di:waypoint x="320" y="130" /> + <di:waypoint x="380" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1kk0exp_di" bpmnElement="Flow_1kk0exp"> + <di:waypoint x="915" y="130" /> + <di:waypoint x="1152" y="130" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="930" y="125" width="37" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0g7721r_di" bpmnElement="Flow_0g7721r"> + <di:waypoint x="890" y="155" /> + <di:waypoint x="890" y="230" /> + <di:waypoint x="980" y="230" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="897" y="203" width="71" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1fij4ds_di" bpmnElement="Flow_1fij4ds"> + <di:waypoint x="915" y="130" /> + <di:waypoint x="1152" y="130" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1021" y="112" width="28" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0m5n6md_di" bpmnElement="Flow_0m5n6md"> + <di:waypoint x="800" y="130" /> + <di:waypoint x="865" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ayd6dj_di" bpmnElement="Flow_0ayd6dj"> + <di:waypoint x="650" y="130" /> + <di:waypoint x="700" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0cmaj9d_di" bpmnElement="Flow_0cmaj9d"> + <di:waypoint x="188" y="130" /> + <di:waypoint x="220" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_16inlk9_di" bpmnElement="Event_16inlk9"> + <dc:Bounds x="152" y="112" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="158" y="155" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1hyt0pb_di" bpmnElement="Activity_1hyt0pb"> + <dc:Bounds x="220" y="90" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1usi32q_di" bpmnElement="Activity_1usi32q"> + <dc:Bounds x="700" y="90" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_15a04ct_di" bpmnElement="Gateway_15a04ct" isMarkerVisible="true"> + <dc:Bounds x="865" y="105" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="861" y="76" width="58" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_18u424w_di" bpmnElement="Event_18u424w"> + <dc:Bounds x="1152" y="112" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0qlstj2_di" bpmnElement="Activity_0qlstj2"> + <dc:Bounds x="550" y="90" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1ydx2rx_di" bpmnElement="Activity_1ydx2rx"> + <dc:Bounds x="380" y="90" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_00awuik_di" bpmnElement="CallDoCloudLeasedLineCreate"> + <dc:Bounds x="980" y="190" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteServiceIntentInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteServiceIntentInstance.bpmn new file mode 100644 index 0000000000..384f9657d3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteServiceIntentInstance.bpmn @@ -0,0 +1,161 @@ +<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1stoy5y" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="DeleteServiceIntentInstance" name="DeallocateSliceSubnet" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1" name="Start"> + <bpmn:outgoing>Flow_143ck2k</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="Flow_143ck2k" sourceRef="StartEvent_1" targetRef="Activity_0zyhkvj" /> + <bpmn:scriptTask id="Activity_0zyhkvj" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_143ck2k</bpmn:incoming> + <bpmn:outgoing>Flow_0pttfuf</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DeleteServiceIntentInstance() +nss.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0c6o2o7" name="Send Sync Response" scriptFormat="groovy"> + <bpmn:incoming>Flow_1c1j5i1</bpmn:incoming> + <bpmn:outgoing>Flow_1kljyhj</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DeleteServiceIntentInstance() +nss.sendSyncResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1dykbz9" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${initResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_04jsg9s</bpmn:incoming> + <bpmn:outgoing>Flow_1c1j5i1</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0pttfuf" sourceRef="Activity_0zyhkvj" targetRef="Activity_1fj0cge" /> + <bpmn:sequenceFlow id="Flow_1c1j5i1" sourceRef="Activity_1dykbz9" targetRef="Activity_0c6o2o7" /> + <bpmn:scriptTask id="Activity_1fj0cge" name="Init Resource Operation Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0pttfuf</bpmn:incoming> + <bpmn:outgoing>Flow_04jsg9s</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DeleteServiceIntentInstance() +nss.prepareInitOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_04jsg9s" sourceRef="Activity_1fj0cge" targetRef="Activity_1dykbz9" /> + <bpmn:exclusiveGateway id="Gateway_1jagvdq" name="Which Intent service type?"> + <bpmn:incoming>Flow_1kljyhj</bpmn:incoming> + <bpmn:outgoing>Flow_0zwyxxc</bpmn:outgoing> + <bpmn:outgoing>Flow_0roz1jy</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:callActivity id="Activity_0li16m1" name="Call CloudLeasedLineDelete" calledElement="DoCloudLeasedLineDelete"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="serviceType" target="serviceType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="serviceIntentParams" target="serviceIntentParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0zwyxxc</bpmn:incoming> + <bpmn:outgoing>Flow_1l74oic</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:endEvent id="Event_1ecylff"> + <bpmn:incoming>Flow_1l74oic</bpmn:incoming> + <bpmn:incoming>Flow_0roz1jy</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_0zwyxxc" name="Cloud Leased Line" sourceRef="Gateway_1jagvdq" targetRef="Activity_0li16m1"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("serviceType") == "CLL"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0roz1jy" name="Other service type" sourceRef="Gateway_1jagvdq" targetRef="Event_1ecylff"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("serviceType") != "CLL"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1l74oic" sourceRef="Activity_0li16m1" targetRef="Event_1ecylff" /> + <bpmn:sequenceFlow id="Flow_1kljyhj" sourceRef="Activity_0c6o2o7" targetRef="Gateway_1jagvdq" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeleteServiceIntentInstance"> + <bpmndi:BPMNEdge id="Flow_1kljyhj_di" bpmnElement="Flow_1kljyhj"> + <di:waypoint x="890" y="250" /> + <di:waypoint x="975" y="250" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1l74oic_di" bpmnElement="Flow_1l74oic"> + <di:waypoint x="1190" y="120" /> + <di:waypoint x="1280" y="120" /> + <di:waypoint x="1280" y="232" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0roz1jy_di" bpmnElement="Flow_0roz1jy"> + <di:waypoint x="1025" y="250" /> + <di:waypoint x="1262" y="250" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1085" y="232" width="90" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0zwyxxc_di" bpmnElement="Flow_0zwyxxc"> + <di:waypoint x="1000" y="225" /> + <di:waypoint x="1000" y="120" /> + <di:waypoint x="1090" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="996" y="86" width="68" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_04jsg9s_di" bpmnElement="Flow_04jsg9s"> + <di:waypoint x="520" y="250" /> + <di:waypoint x="600" y="250" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1c1j5i1_di" bpmnElement="Flow_1c1j5i1"> + <di:waypoint x="700" y="250" /> + <di:waypoint x="790" y="250" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0pttfuf_di" bpmnElement="Flow_0pttfuf"> + <di:waypoint x="330" y="250" /> + <di:waypoint x="420" y="250" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_143ck2k_di" bpmnElement="Flow_143ck2k"> + <di:waypoint x="168" y="250" /> + <di:waypoint x="230" y="250" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="132" y="232" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="138" y="275" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1jawdkz_di" bpmnElement="Activity_0zyhkvj"> + <dc:Bounds x="230" y="210" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1n1ajr4_di" bpmnElement="Activity_0c6o2o7"> + <dc:Bounds x="790" y="210" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1dykbz9_di" bpmnElement="Activity_1dykbz9"> + <dc:Bounds x="600" y="210" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1fj0cge_di" bpmnElement="Activity_1fj0cge"> + <dc:Bounds x="420" y="210" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1jagvdq_di" bpmnElement="Gateway_1jagvdq" isMarkerVisible="true"> + <dc:Bounds x="975" y="225" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="967" y="286" width="65" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0li16m1_di" bpmnElement="Activity_0li16m1"> + <dc:Bounds x="1090" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1ecylff_di" bpmnElement="Event_1ecylff"> + <dc:Bounds x="1262" y="232" width="36" height="36" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ModifyServiceIntentInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ModifyServiceIntentInstance.bpmn new file mode 100644 index 0000000000..e042c1a552 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ModifyServiceIntentInstance.bpmn @@ -0,0 +1,173 @@ +<?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: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" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0fme930" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="ModifyServiceIntentInstance" name="ModifyServiceIntentInstance" isExecutable="true"> + <bpmn:startEvent id="Event_05idy03" name="Start"> + <bpmn:outgoing>Flow_1t0w8dn</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="Activity_0kd9pxx" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_1t0w8dn</bpmn:incoming> + <bpmn:outgoing>Flow_0fzchbl</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new ModifyServiceIntentInstance() +nss.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1dzkfh2" name="Send Sync Response" scriptFormat="groovy"> + <bpmn:incoming>Flow_1q030ul</bpmn:incoming> + <bpmn:outgoing>Flow_0ps6iyc</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new ModifyServiceIntentInstance() +nss.sendSyncResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_1baxf7k" name="Which Intent Service"> + <bpmn:incoming>Flow_0ps6iyc</bpmn:incoming> + <bpmn:outgoing>Flow_15luvlg</bpmn:outgoing> + <bpmn:outgoing>Flow_0usuozn</bpmn:outgoing> + <bpmn:outgoing>Flow_1dfyoe6</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="Event_103vvkf"> + <bpmn:incoming>Flow_1b2k523</bpmn:incoming> + <bpmn:incoming>Flow_1dfyoe6</bpmn:incoming> + <bpmn:incoming>Flow_15luvlg</bpmn:incoming> + </bpmn:endEvent> + <bpmn:serviceTask id="Activity_0ptby3d" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${initResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1grhlet</bpmn:incoming> + <bpmn:outgoing>Flow_1q030ul</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1t0w8dn" sourceRef="Event_05idy03" targetRef="Activity_0kd9pxx" /> + <bpmn:sequenceFlow id="Flow_0fzchbl" sourceRef="Activity_0kd9pxx" targetRef="Activity_1s8ojcr" /> + <bpmn:sequenceFlow id="Flow_1q030ul" sourceRef="Activity_0ptby3d" targetRef="Activity_1dzkfh2" /> + <bpmn:sequenceFlow id="Flow_0ps6iyc" sourceRef="Activity_1dzkfh2" targetRef="Gateway_1baxf7k" /> + <bpmn:sequenceFlow id="Flow_15luvlg" sourceRef="Gateway_1baxf7k" targetRef="Event_103vvkf"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "TN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0usuozn" name="Cloud Leased Line" sourceRef="Gateway_1baxf7k" targetRef="Activity_0t1g4mp"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("serviceType") == "CLL"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:scriptTask id="Activity_1s8ojcr" name="Init Resource Operation Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0fzchbl</bpmn:incoming> + <bpmn:outgoing>Flow_1grhlet</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new ModifyServiceIntentInstance() +nss.prepareInitOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1grhlet" sourceRef="Activity_1s8ojcr" targetRef="Activity_0ptby3d" /> + <bpmn:callActivity id="Activity_0t1g4mp" name="Call CloudLeasedLineModify" calledElement="DoCloudLeasedLineModify"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="serviceType" target="serviceType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="serviceIntentParams" target="serviceIntentParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0usuozn</bpmn:incoming> + <bpmn:outgoing>Flow_1b2k523</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_1b2k523" sourceRef="Activity_0t1g4mp" targetRef="Event_103vvkf" /> + <bpmn:sequenceFlow id="Flow_1dfyoe6" name="Other servcie" sourceRef="Gateway_1baxf7k" targetRef="Event_103vvkf"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("serviceType") != "CLL"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ModifyServiceIntentInstance"> + <bpmndi:BPMNEdge id="Flow_1dfyoe6_di" bpmnElement="Flow_1dfyoe6"> + <di:waypoint x="855" y="270" /> + <di:waypoint x="1092" y="270" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="917" y="252" width="66" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1b2k523_di" bpmnElement="Flow_1b2k523"> + <di:waypoint x="1020" y="140" /> + <di:waypoint x="1110" y="140" /> + <di:waypoint x="1110" y="252" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1grhlet_di" bpmnElement="Flow_1grhlet"> + <di:waypoint x="440" y="270" /> + <di:waypoint x="490" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0usuozn_di" bpmnElement="Flow_0usuozn"> + <di:waypoint x="830" y="245" /> + <di:waypoint x="830" y="140" /> + <di:waypoint x="920" y="140" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="816" y="113" width="68" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_15luvlg_di" bpmnElement="Flow_15luvlg"> + <di:waypoint x="855" y="270" /> + <di:waypoint x="1092" y="270" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="852" y="365" width="36" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ps6iyc_di" bpmnElement="Flow_0ps6iyc"> + <di:waypoint x="740" y="270" /> + <di:waypoint x="805" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1q030ul_di" bpmnElement="Flow_1q030ul"> + <di:waypoint x="590" y="270" /> + <di:waypoint x="640" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0fzchbl_di" bpmnElement="Flow_0fzchbl"> + <di:waypoint x="310" y="270" /> + <di:waypoint x="340" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1t0w8dn_di" bpmnElement="Flow_1t0w8dn"> + <di:waypoint x="188" y="270" /> + <di:waypoint x="210" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_05idy03_di" bpmnElement="Event_05idy03"> + <dc:Bounds x="152" y="252" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="158" y="295" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0kd9pxx_di" bpmnElement="Activity_0kd9pxx"> + <dc:Bounds x="210" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1dzkfh2_di" bpmnElement="Activity_1dzkfh2"> + <dc:Bounds x="640" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1baxf7k_di" bpmnElement="Gateway_1baxf7k" isMarkerVisible="true"> + <dc:Bounds x="805" y="245" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="799" y="306" width="62" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_103vvkf_di" bpmnElement="Event_103vvkf"> + <dc:Bounds x="1092" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ptby3d_di" bpmnElement="Activity_0ptby3d"> + <dc:Bounds x="490" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1s8ojcr_di" bpmnElement="Activity_1s8ojcr"> + <dc:Bounds x="340" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0t1g4mp_di" bpmnElement="Activity_0t1g4mp"> + <dc:Bounds x="920" y="100" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCloudLeasedLineCreate.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCloudLeasedLineCreate.bpmn new file mode 100644 index 0000000000..96ebce2297 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCloudLeasedLineCreate.bpmn @@ -0,0 +1,321 @@ +<?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: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" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1wio50w" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="DoCloudLeasedLineCreate" name="DoCloudLeasedLineCreate" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1nbljfd" name="Create Cloud Leased Line Creation Work Flow"> + <bpmn:outgoing>SequenceFlow_03s744c</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="ScriptTask_1tc44ge" name="PreProcess Incoming Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_03s744c</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_07e12rt</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def css= new DoCloudLeasedLineCreate() +css.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:subProcess id="SubProcess_1yv9i68" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="StartEvent_1omdx56"> + <bpmn:outgoing>SequenceFlow_1w67v6s</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_06xcioh" /> + </bpmn:startEvent> + <bpmn:endEvent id="EndEvent_1jx3026"> + <bpmn:incoming>SequenceFlow_08mlzwz</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="ScriptTask_1swzdpw" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1w67v6s</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_08mlzwz</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1w67v6s" sourceRef="StartEvent_1omdx56" targetRef="ScriptTask_1swzdpw" /> + <bpmn:sequenceFlow id="SequenceFlow_08mlzwz" sourceRef="ScriptTask_1swzdpw" targetRef="EndEvent_1jx3026" /> + </bpmn:subProcess> + <bpmn:endEvent id="EndEvent_05h01gx" name="End"> + <bpmn:incoming>Flow_06rrcwf</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="ScriptTask_1xxag1o" name="Prepare Init Service Operation Status" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_07e12rt</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0t094g7</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new DoCloudLeasedLineCreate() +runScript.prepareUpdateJobStatus(execution,"INPROGRESS","10","Create Cloud Leased Line started")</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_1ssh2l9" name="Prepare Update Resource Oper Status((finish)" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0kixzdj</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1qv8qw1</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new DoCloudLeasedLineCreate() +runScript.prepareUpdateJobStatus(execution,"FINISHED","100","Created CLL successfully")</bpmn:script> + </bpmn:scriptTask> + <bpmn:endEvent id="EndEvent_1oouvuh" name="End" /> + <bpmn:sequenceFlow id="SequenceFlow_03s744c" sourceRef="StartEvent_1nbljfd" targetRef="ScriptTask_1tc44ge" /> + <bpmn:sequenceFlow id="SequenceFlow_07e12rt" sourceRef="ScriptTask_1tc44ge" targetRef="ScriptTask_1xxag1o" /> + <bpmn:sequenceFlow id="SequenceFlow_0t094g7" sourceRef="ScriptTask_1xxag1o" targetRef="Activity_14an583" /> + <bpmn:sequenceFlow id="SequenceFlow_1qv8qw1" sourceRef="ScriptTask_1ssh2l9" targetRef="Activity_1xko5pk" /> + <bpmn:scriptTask id="ScriptTask_19uxoi8" name="Update AAI Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_1865m9a</bpmn:incoming> + <bpmn:incoming>Flow_15mdc4q</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0kixzdj</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +execution.setVariable("orchestrationStatus", "created") +def runScript = new DoCloudLeasedLineCreate() +runScript.updateAAIOrchStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0kixzdj" sourceRef="ScriptTask_19uxoi8" targetRef="ScriptTask_1ssh2l9" /> + <bpmn:serviceTask id="Activity_14an583" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0t094g7</bpmn:incoming> + <bpmn:outgoing>Flow_1k88aak</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1k88aak" sourceRef="Activity_14an583" targetRef="Activity_1tiyq9t" /> + <bpmn:serviceTask id="Activity_1xko5pk" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1qv8qw1</bpmn:incoming> + <bpmn:outgoing>Flow_06rrcwf</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_06rrcwf" sourceRef="Activity_1xko5pk" targetRef="EndEvent_05h01gx" /> + <bpmn:scriptTask id="Activity_1tiyq9t" name="create Service Instance in AAI" scriptFormat="groovy"> + <bpmn:incoming>Flow_1k88aak</bpmn:incoming> + <bpmn:outgoing>Flow_0xqfi6l</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new DoCloudLeasedLineCreate() +dcsi.createServiceInstance(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_09pfclp" name="Create Allottedsource in AAI" scriptFormat="groovy"> + <bpmn:incoming>Flow_0xqfi6l</bpmn:incoming> + <bpmn:outgoing>Flow_1wzmy62</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new DoCloudLeasedLineCreate() +dcsi.createAllottedResource(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_1h7dpdn" name="Enable SDNC?"> + <bpmn:incoming>Flow_1wzmy62</bpmn:incoming> + <bpmn:outgoing>Flow_08u0q5g</bpmn:outgoing> + <bpmn:outgoing>Flow_15mdc4q</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:scriptTask id="Activity_01xdxaj" name="PreProcess SDNC Create Cloud Leased Line Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_08u0q5g</bpmn:incoming> + <bpmn:outgoing>Flow_1xqkjy9</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new DoCloudLeasedLineCreate() +dcsi.preprocessSdncCreateCllRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_01m0xuh" name="Call SDNC Adapter: Create CLL" calledElement="sdncAdapter"> + <bpmn:extensionElements> + <camunda:in source="CLL_SDNCRequest" target="sdncAdapterWorkflowRequest" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:in source="msoRequestId" target="mso-request-id" /> + <camunda:in source="sliceServiceInstanceId" target="mso-service-instance-id" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="sdncAdapterResponse" target="CLL_SDNCAdapterResponse" /> + <camunda:out source="SDNCA_SuccessIndicator" target="SDNCA_SuccessIndicator" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1xqkjy9</bpmn:incoming> + <bpmn:outgoing>Flow_0vvbiux</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_01eibkt" name="Postprocess Create CLL Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_0vvbiux</bpmn:incoming> + <bpmn:outgoing>Flow_1865m9a</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +String response = execution.getVariable("CLL_SDNCAdapterResponse") + +def dcsi = new DoCloudLeasedLineCreate() +dcsi.validateSDNCResponse(execution, response, "allocate")</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0xqfi6l" sourceRef="Activity_1tiyq9t" targetRef="Activity_09pfclp" /> + <bpmn:sequenceFlow id="Flow_1wzmy62" sourceRef="Activity_09pfclp" targetRef="Gateway_1h7dpdn" /> + <bpmn:sequenceFlow id="Flow_1xqkjy9" name="" sourceRef="Activity_01xdxaj" targetRef="Activity_01m0xuh" /> + <bpmn:sequenceFlow id="Flow_0vvbiux" name="" sourceRef="Activity_01m0xuh" targetRef="Activity_01eibkt" /> + <bpmn:sequenceFlow id="Flow_08u0q5g" name="YES" sourceRef="Gateway_1h7dpdn" targetRef="Activity_01xdxaj"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("enableSdnc" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1865m9a" sourceRef="Activity_01eibkt" targetRef="ScriptTask_19uxoi8" /> + <bpmn:sequenceFlow id="Flow_15mdc4q" name="NO" sourceRef="Gateway_1h7dpdn" targetRef="ScriptTask_19uxoi8" /> + </bpmn:process> + <bpmn:message id="Message_0c4b2r5" name="SliceServiceTask" /> + <bpmn:error id="Error_03akl5v" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn:error id="Error_0p2naox" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCloudLeasedLineCreate"> + <bpmndi:BPMNEdge id="Flow_15mdc4q_di" bpmnElement="Flow_15mdc4q"> + <di:waypoint x="765" y="274" /> + <di:waypoint x="1110" y="274" /> + <di:waypoint x="1110" y="480" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="926" y="253" width="17" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1865m9a_di" bpmnElement="Flow_1865m9a"> + <di:waypoint x="960" y="520" /> + <di:waypoint x="1060" y="520" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_08u0q5g_di" bpmnElement="Flow_08u0q5g"> + <di:waypoint x="740" y="299" /> + <di:waypoint x="740" y="380" /> + <di:waypoint x="480" y="380" /> + <di:waypoint x="480" y="470" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="745" y="332" width="23" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0vvbiux_di" bpmnElement="Flow_0vvbiux"> + <di:waypoint x="730" y="520" /> + <di:waypoint x="839" y="520" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1xqkjy9_di" bpmnElement="Flow_1xqkjy9"> + <di:waypoint x="540" y="520" /> + <di:waypoint x="609" y="520" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1wzmy62_di" bpmnElement="Flow_1wzmy62"> + <di:waypoint x="580" y="274" /> + <di:waypoint x="715" y="274" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0xqfi6l_di" bpmnElement="Flow_0xqfi6l"> + <di:waypoint x="370" y="274" /> + <di:waypoint x="480" y="274" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_06rrcwf_di" bpmnElement="Flow_06rrcwf"> + <di:waypoint x="1330" y="690" /> + <di:waypoint x="1430" y="690" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1k88aak_di" bpmnElement="Flow_1k88aak"> + <di:waypoint x="750" y="121" /> + <di:waypoint x="770" y="121" /> + <di:waypoint x="770" y="198" /> + <di:waypoint x="320" y="198" /> + <di:waypoint x="320" y="230" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0kixzdj_di" bpmnElement="SequenceFlow_0kixzdj"> + <di:waypoint x="1110" y="560" /> + <di:waypoint x="1110" y="650" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1"> + <di:waypoint x="1160" y="690" /> + <di:waypoint x="1230" y="690" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0t094g7_di" bpmnElement="SequenceFlow_0t094g7"> + <di:waypoint x="568" y="121" /> + <di:waypoint x="650" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_07e12rt_di" bpmnElement="SequenceFlow_07e12rt"> + <di:waypoint x="385" y="121" /> + <di:waypoint x="468" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_03s744c_di" bpmnElement="SequenceFlow_03s744c"> + <di:waypoint x="214" y="121" /> + <di:waypoint x="285" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1nbljfd_di" bpmnElement="StartEvent_1nbljfd"> + <dc:Bounds x="178" y="103" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="171" y="146" width="71" height="53" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1tc44ge_di" bpmnElement="ScriptTask_1tc44ge"> + <dc:Bounds x="285" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="SubProcess_1yv9i68_di" bpmnElement="SubProcess_1yv9i68" isExpanded="true"> + <dc:Bounds x="685" y="1080" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_08mlzwz_di" bpmnElement="SequenceFlow_08mlzwz"> + <di:waypoint x="1079" y="1184" /> + <di:waypoint x="1353" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1w67v6s_di" bpmnElement="SequenceFlow_1w67v6s"> + <di:waypoint x="751" y="1184" /> + <di:waypoint x="979" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1omdx56_di" bpmnElement="StartEvent_1omdx56"> + <dc:Bounds x="715" y="1166" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1jx3026_di" bpmnElement="EndEvent_1jx3026"> + <dc:Bounds x="1353" y="1166" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1swzdpw_di" bpmnElement="ScriptTask_1swzdpw"> + <dc:Bounds x="979" y="1144" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_05h01gx_di" bpmnElement="EndEvent_05h01gx"> + <dc:Bounds x="1430" y="672" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1438" y="715" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1xxag1o_di" bpmnElement="ScriptTask_1xxag1o"> + <dc:Bounds x="468" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1ssh2l9_di" bpmnElement="ScriptTask_1ssh2l9"> + <dc:Bounds x="1060" y="650" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1oouvuh_di" bpmnElement="EndEvent_1oouvuh"> + <dc:Bounds x="1562" y="482" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1570" y="525" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_19uxoi8_di" bpmnElement="ScriptTask_19uxoi8"> + <dc:Bounds x="1060" y="480" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_14an583_di" bpmnElement="Activity_14an583"> + <dc:Bounds x="650" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1xko5pk_di" bpmnElement="Activity_1xko5pk"> + <dc:Bounds x="1230" y="650" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1tiyq9t_di" bpmnElement="Activity_1tiyq9t"> + <dc:Bounds x="270" y="234" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_09pfclp_di" bpmnElement="Activity_09pfclp"> + <dc:Bounds x="480" y="234" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1h7dpdn_di" bpmnElement="Gateway_1h7dpdn" isMarkerVisible="true"> + <dc:Bounds x="715" y="249" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="702" y="233" width="75" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_01xdxaj_di" bpmnElement="Activity_01xdxaj"> + <dc:Bounds x="419" y="473" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_01m0xuh_di" bpmnElement="Activity_01m0xuh"> + <dc:Bounds x="609" y="473" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_01eibkt_di" bpmnElement="Activity_01eibkt"> + <dc:Bounds x="839" y="473" width="121" height="94" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCloudLeasedLineDelete.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCloudLeasedLineDelete.bpmn new file mode 100644 index 0000000000..4f84317945 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCloudLeasedLineDelete.bpmn @@ -0,0 +1,235 @@ +<?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: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" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1wio50w" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="DoCloudLeasedLineDelete" name="DoCloudLeasedLineDelete" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1nbljfd" name="Create Cloud Leased Line Deletion Work Flow"> + <bpmn:outgoing>SequenceFlow_03s744c</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:subProcess id="SubProcess_1yv9i68" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="StartEvent_1omdx56"> + <bpmn:outgoing>SequenceFlow_1w67v6s</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_06xcioh" /> + </bpmn:startEvent> + <bpmn:endEvent id="EndEvent_1jx3026"> + <bpmn:incoming>SequenceFlow_08mlzwz</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="ScriptTask_1swzdpw" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1w67v6s</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_08mlzwz</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1w67v6s" sourceRef="StartEvent_1omdx56" targetRef="ScriptTask_1swzdpw" /> + <bpmn:sequenceFlow id="SequenceFlow_08mlzwz" sourceRef="ScriptTask_1swzdpw" targetRef="EndEvent_1jx3026" /> + </bpmn:subProcess> + <bpmn:endEvent id="EndEvent_05h01gx" name="End"> + <bpmn:incoming>Flow_0ca4l8d</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="ScriptTask_1ssh2l9" name="Prepare Update Resource Oper Status((finish)" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1jygjln</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1qv8qw1</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new DoCloudLeasedLineDelete() +runScript.prepareUpdateJobStatus(execution,"FINISHED","100","Deleted CLL successfully")</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_03s744c" sourceRef="StartEvent_1nbljfd" targetRef="ScriptTask_1tc44ge" /> + <bpmn:sequenceFlow id="SequenceFlow_1qv8qw1" sourceRef="ScriptTask_1ssh2l9" targetRef="Activity_0rgeefb" /> + <bpmn:scriptTask id="Activity_1tw8eyy" name="PreProcess SDNC Delete CLL Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_0sj0mtu</bpmn:incoming> + <bpmn:outgoing>Flow_0cpctye</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new DoCloudLeasedLineDelete() +runScript.preprocessSdncDeleteCllRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0cpctye" sourceRef="Activity_1tw8eyy" targetRef="Activity_0p20esb" /> + <bpmn:callActivity id="Activity_0p20esb" name="Call SDNC Adapter: Delete CLL" calledElement="sdncAdapter"> + <bpmn:extensionElements> + <camunda:in source="CLL_SDNCRequest" target="sdncAdapterWorkflowRequest" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:in source="msoRequestId" target="mso-request-id" /> + <camunda:in source="sliceServiceInstanceId" target="mso-service-instance-id" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="sdncAdapterResponse" target="CLL_SDNCAdapterResponse" /> + <camunda:out source="SDNCA_SuccessIndicator" target="SDNCA_SuccessIndicator" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0cpctye</bpmn:incoming> + <bpmn:outgoing>Flow_0fuabjs</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_0fuabjs" sourceRef="Activity_0p20esb" targetRef="Activity_0phv8e5" /> + <bpmn:scriptTask id="Activity_0phv8e5" name="Postprocess SDNC Delete CLL Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_0fuabjs</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1jdb2oq</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +String response = execution.getVariable("CLL_SDNCAdapterResponse") + +def runScript = new DoCloudLeasedLineDelete() +runScript.validateSDNCResponse(execution, response, "deallocate")</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_013rjwc" name="Delete Service Instance (CLL) in AAI" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1jdb2oq</bpmn:incoming> + <bpmn:incoming>Flow_0dirb5b</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1jygjln</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new DoCloudLeasedLineDelete() +runScript.deleteServiceInstance(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1jdb2oq" sourceRef="Activity_0phv8e5" targetRef="Activity_013rjwc" /> + <bpmn:scriptTask id="ScriptTask_1tc44ge" name="PreProcess Incoming Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_03s744c</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_07e12rt</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new DoCloudLeasedLineDelete() +runScript.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_07e12rt" sourceRef="ScriptTask_1tc44ge" targetRef="Gateway_1spi9lo" /> + <bpmn:sequenceFlow id="SequenceFlow_1jygjln" sourceRef="Activity_013rjwc" targetRef="ScriptTask_1ssh2l9" /> + <bpmn:serviceTask id="Activity_0rgeefb" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1qv8qw1</bpmn:incoming> + <bpmn:outgoing>Flow_0ca4l8d</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0ca4l8d" sourceRef="Activity_0rgeefb" targetRef="EndEvent_05h01gx" /> + <bpmn:exclusiveGateway id="Gateway_1spi9lo" name="Enable SDNC?"> + <bpmn:incoming>SequenceFlow_07e12rt</bpmn:incoming> + <bpmn:outgoing>Flow_0sj0mtu</bpmn:outgoing> + <bpmn:outgoing>Flow_0dirb5b</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_0sj0mtu" name="Yes" sourceRef="Gateway_1spi9lo" targetRef="Activity_1tw8eyy"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("enableSdnc" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0dirb5b" name="No" sourceRef="Gateway_1spi9lo" targetRef="Activity_013rjwc" /> + </bpmn:process> + <bpmn:message id="Message_0c4b2r5" name="SliceServiceTask" /> + <bpmn:error id="Error_03akl5v" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn:error id="Error_0p2naox" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCloudLeasedLineDelete"> + <bpmndi:BPMNEdge id="Flow_0dirb5b_di" bpmnElement="Flow_0dirb5b"> + <di:waypoint x="480" y="146" /> + <di:waypoint x="480" y="370" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="483" y="166" width="14" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0sj0mtu_di" bpmnElement="Flow_0sj0mtu"> + <di:waypoint x="505" y="121" /> + <di:waypoint x="569" y="121" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="529" y="103" width="19" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ca4l8d_di" bpmnElement="Flow_0ca4l8d"> + <di:waypoint x="1030" y="410" /> + <di:waypoint x="1152" y="410" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1jygjln_di" bpmnElement="SequenceFlow_1jygjln"> + <di:waypoint x="530" y="410" /> + <di:waypoint x="660" y="410" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_07e12rt_di" bpmnElement="SequenceFlow_07e12rt"> + <di:waypoint x="385" y="121" /> + <di:waypoint x="455" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1jdb2oq_di" bpmnElement="SequenceFlow_1jdb2oq"> + <di:waypoint x="1130" y="121" /> + <di:waypoint x="1220" y="121" /> + <di:waypoint x="1220" y="260" /> + <di:waypoint x="480" y="260" /> + <di:waypoint x="480" y="370" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0fuabjs_di" bpmnElement="Flow_0fuabjs"> + <di:waypoint x="910" y="121" /> + <di:waypoint x="1009" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0cpctye_di" bpmnElement="Flow_0cpctye"> + <di:waypoint x="690" y="121" /> + <di:waypoint x="789" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1"> + <di:waypoint x="760" y="410" /> + <di:waypoint x="930" y="410" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_03s744c_di" bpmnElement="SequenceFlow_03s744c"> + <di:waypoint x="214" y="121" /> + <di:waypoint x="285" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1nbljfd_di" bpmnElement="StartEvent_1nbljfd"> + <dc:Bounds x="178" y="103" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="169" y="146" width="70" height="53" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="SubProcess_1yv9i68_di" bpmnElement="SubProcess_1yv9i68" isExpanded="true"> + <dc:Bounds x="685" y="1080" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_08mlzwz_di" bpmnElement="SequenceFlow_08mlzwz"> + <di:waypoint x="1079" y="1184" /> + <di:waypoint x="1353" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1w67v6s_di" bpmnElement="SequenceFlow_1w67v6s"> + <di:waypoint x="751" y="1184" /> + <di:waypoint x="979" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1omdx56_di" bpmnElement="StartEvent_1omdx56"> + <dc:Bounds x="715" y="1166" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1jx3026_di" bpmnElement="EndEvent_1jx3026"> + <dc:Bounds x="1353" y="1166" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1swzdpw_di" bpmnElement="ScriptTask_1swzdpw"> + <dc:Bounds x="979" y="1144" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_05h01gx_di" bpmnElement="EndEvent_05h01gx"> + <dc:Bounds x="1152" y="392" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1160" y="435" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1ssh2l9_di" bpmnElement="ScriptTask_1ssh2l9"> + <dc:Bounds x="660" y="370" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1tw8eyy_di" bpmnElement="Activity_1tw8eyy"> + <dc:Bounds x="569" y="74" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0p20esb_di" bpmnElement="Activity_0p20esb"> + <dc:Bounds x="789" y="74" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0phv8e5_di" bpmnElement="Activity_0phv8e5"> + <dc:Bounds x="1009" y="74" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_013rjwc_di" bpmnElement="Activity_013rjwc"> + <dc:Bounds x="430" y="370" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1tc44ge_di" bpmnElement="ScriptTask_1tc44ge"> + <dc:Bounds x="285" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0rgeefb_di" bpmnElement="Activity_0rgeefb"> + <dc:Bounds x="930" y="370" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1spi9lo_di" bpmnElement="Gateway_1spi9lo" isMarkerVisible="true"> + <dc:Bounds x="455" y="96" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="443" y="73" width="75" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCloudLeasedLineModify.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCloudLeasedLineModify.bpmn new file mode 100644 index 0000000000..1c2ce98f09 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCloudLeasedLineModify.bpmn @@ -0,0 +1,252 @@ +<?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: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" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1wio50w" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="DoCloudLeasedLineModify" name="DoCloudLeasedLineModify" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1nbljfd" name="Create Modify Cloud Leased LIne Work Flow"> + <bpmn:outgoing>SequenceFlow_03s744c</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:subProcess id="SubProcess_1yv9i68" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="StartEvent_1omdx56"> + <bpmn:outgoing>SequenceFlow_1w67v6s</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_06xcioh" /> + </bpmn:startEvent> + <bpmn:endEvent id="EndEvent_1jx3026"> + <bpmn:incoming>SequenceFlow_08mlzwz</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="ScriptTask_1swzdpw" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1w67v6s</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_08mlzwz</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1w67v6s" sourceRef="StartEvent_1omdx56" targetRef="ScriptTask_1swzdpw" /> + <bpmn:sequenceFlow id="SequenceFlow_08mlzwz" sourceRef="ScriptTask_1swzdpw" targetRef="EndEvent_1jx3026" /> + </bpmn:subProcess> + <bpmn:endEvent id="EndEvent_05h01gx" name="End"> + <bpmn:incoming>Flow_1akxvak</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="ScriptTask_1ssh2l9" name="Prepare Update Resource Oper Status((finish)" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0kixzdj</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1qv8qw1</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new DoCloudLeasedLineModify() +runScript.prepareUpdateJobStatus(execution,"FINISHED","100","Modified CLL successfully")</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_03s744c" sourceRef="StartEvent_1nbljfd" targetRef="ScriptTask_1tc44ge" /> + <bpmn:sequenceFlow id="SequenceFlow_1qv8qw1" sourceRef="ScriptTask_1ssh2l9" targetRef="Activity_0ziz3ti" /> + <bpmn:scriptTask id="ScriptTask_19uxoi8" name="Update AAI Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0h5rwlh</bpmn:incoming> + <bpmn:incoming>Flow_0b3rxne</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0kixzdj</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +execution.setVariable("orchestrationStatus", "modified") +def runScript = new DoCloudLeasedLineModify() +runScript.updateAAIOrchStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0kixzdj" sourceRef="ScriptTask_19uxoi8" targetRef="ScriptTask_1ssh2l9" /> + <bpmn:scriptTask id="Activity_0phv8e5" name="Modify CLL instance in AAI" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_07e12rt</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1jdb2oq</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +def runScript = new DoCloudLeasedLineModify() +runScript.updateServiceInstanceInAAI(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1jdb2oq" sourceRef="Activity_0phv8e5" targetRef="Gateway_1o68a9z" /> + <bpmn:scriptTask id="ScriptTask_1tc44ge" name="PreProcess Incoming Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_03s744c</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_07e12rt</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new DoCloudLeasedLineModify() +runScript.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_07e12rt" sourceRef="ScriptTask_1tc44ge" targetRef="Activity_0phv8e5" /> + <bpmn:scriptTask id="Activity_0h1vr2l" name="PreProcess SDNC Modify CLL Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_0cm9i4m</bpmn:incoming> + <bpmn:outgoing>Flow_1dvo5ih</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new DoCloudLeasedLineModify() +runScript.preprocessSdncModifyCllRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1dvo5ih" sourceRef="Activity_0h1vr2l" targetRef="Activity_14ab476" /> + <bpmn:callActivity id="Activity_14ab476" name="Call SDNC Adapter: Modify CLL" calledElement="sdncAdapter"> + <bpmn:extensionElements> + <camunda:in source="CLL_SDNCRequest" target="sdncAdapterWorkflowRequest" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:in source="msoRequestId" target="mso-request-id" /> + <camunda:in source="sliceServiceInstanceId" target="mso-service-instance-id" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="sdncAdapterResponse" target="CLL_SDNCAdapterResponse" /> + <camunda:out source="SDNCA_SuccessIndicator" target="SDNCA_SuccessIndicator" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1dvo5ih</bpmn:incoming> + <bpmn:outgoing>Flow_139j3yd</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_139j3yd" sourceRef="Activity_14ab476" targetRef="Activity_1vtz33q" /> + <bpmn:scriptTask id="Activity_1vtz33q" name="Postprocess SDNC Modify CLL Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_139j3yd</bpmn:incoming> + <bpmn:outgoing>Flow_0h5rwlh</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +String response = execution.getVariable("CLL_SDNCAdapterResponse") + +def runScript = new DoCloudLeasedLineModify() +runScript.validateSDNCResponse(execution, response, "modify")</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0h5rwlh" sourceRef="Activity_1vtz33q" targetRef="ScriptTask_19uxoi8" /> + <bpmn:serviceTask id="Activity_0ziz3ti" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1qv8qw1</bpmn:incoming> + <bpmn:outgoing>Flow_1akxvak</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1akxvak" sourceRef="Activity_0ziz3ti" targetRef="EndEvent_05h01gx" /> + <bpmn:exclusiveGateway id="Gateway_1o68a9z" name="Enable SDNC?"> + <bpmn:incoming>SequenceFlow_1jdb2oq</bpmn:incoming> + <bpmn:outgoing>Flow_0cm9i4m</bpmn:outgoing> + <bpmn:outgoing>Flow_0b3rxne</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_0cm9i4m" name="Yes" sourceRef="Gateway_1o68a9z" targetRef="Activity_0h1vr2l"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("enableSdnc" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0b3rxne" name="No" sourceRef="Gateway_1o68a9z" targetRef="ScriptTask_19uxoi8" /> + </bpmn:process> + <bpmn:message id="Message_0c4b2r5" name="SliceServiceTask" /> + <bpmn:error id="Error_03akl5v" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn:error id="Error_0p2naox" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCloudLeasedLineModify"> + <bpmndi:BPMNEdge id="Flow_0b3rxne_di" bpmnElement="Flow_0b3rxne"> + <di:waypoint x="690" y="146" /> + <di:waypoint x="690" y="360" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="698" y="203" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0cm9i4m_di" bpmnElement="Flow_0cm9i4m"> + <di:waypoint x="715" y="121" /> + <di:waypoint x="789" y="121" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="743" y="103" width="19" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1akxvak_di" bpmnElement="Flow_1akxvak"> + <di:waypoint x="1230" y="400" /> + <di:waypoint x="1372" y="400" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0h5rwlh_di" bpmnElement="Flow_0h5rwlh"> + <di:waypoint x="1350" y="121" /> + <di:waypoint x="1430" y="121" /> + <di:waypoint x="1430" y="280" /> + <di:waypoint x="690" y="280" /> + <di:waypoint x="690" y="360" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_139j3yd_di" bpmnElement="Flow_139j3yd"> + <di:waypoint x="1110" y="121" /> + <di:waypoint x="1229" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1dvo5ih_di" bpmnElement="Flow_1dvo5ih"> + <di:waypoint x="910" y="121" /> + <di:waypoint x="989" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_07e12rt_di" bpmnElement="SequenceFlow_07e12rt"> + <di:waypoint x="390" y="121" /> + <di:waypoint x="479" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1jdb2oq_di" bpmnElement="SequenceFlow_1jdb2oq"> + <di:waypoint x="600" y="121" /> + <di:waypoint x="665" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0kixzdj_di" bpmnElement="SequenceFlow_0kixzdj"> + <di:waypoint x="740" y="400" /> + <di:waypoint x="860" y="400" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1"> + <di:waypoint x="960" y="400" /> + <di:waypoint x="1130" y="400" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_03s744c_di" bpmnElement="SequenceFlow_03s744c"> + <di:waypoint x="208" y="121" /> + <di:waypoint x="290" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1nbljfd_di" bpmnElement="StartEvent_1nbljfd"> + <dc:Bounds x="172" y="103" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="163" y="146" width="77" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="SubProcess_1yv9i68_di" bpmnElement="SubProcess_1yv9i68" isExpanded="true"> + <dc:Bounds x="735" y="1080" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_08mlzwz_di" bpmnElement="SequenceFlow_08mlzwz"> + <di:waypoint x="1129" y="1184" /> + <di:waypoint x="1403" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1w67v6s_di" bpmnElement="SequenceFlow_1w67v6s"> + <di:waypoint x="801" y="1184" /> + <di:waypoint x="1029" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1omdx56_di" bpmnElement="StartEvent_1omdx56"> + <dc:Bounds x="765" y="1166" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1jx3026_di" bpmnElement="EndEvent_1jx3026"> + <dc:Bounds x="1403" y="1166" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1swzdpw_di" bpmnElement="ScriptTask_1swzdpw"> + <dc:Bounds x="1029" y="1144" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_05h01gx_di" bpmnElement="EndEvent_05h01gx"> + <dc:Bounds x="1372" y="382" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1380" y="425" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1ssh2l9_di" bpmnElement="ScriptTask_1ssh2l9"> + <dc:Bounds x="860" y="360" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_19uxoi8_di" bpmnElement="ScriptTask_19uxoi8"> + <dc:Bounds x="640" y="360" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0phv8e5_di" bpmnElement="Activity_0phv8e5"> + <dc:Bounds x="479" y="74" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1tc44ge_di" bpmnElement="ScriptTask_1tc44ge"> + <dc:Bounds x="290" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0h1vr2l_di" bpmnElement="Activity_0h1vr2l"> + <dc:Bounds x="789" y="74" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_14ab476_di" bpmnElement="Activity_14ab476"> + <dc:Bounds x="989" y="74" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1vtz33q_di" bpmnElement="Activity_1vtz33q"> + <dc:Bounds x="1229" y="74" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ziz3ti_di" bpmnElement="Activity_0ziz3ti"> + <dc:Bounds x="1130" y="360" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1o68a9z_di" bpmnElement="Gateway_1o68a9z" isMarkerVisible="true"> + <dc:Bounds x="665" y="96" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="653" y="73" width="75" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> 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/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/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 bbb32b52be..39a980d7c8 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -46,6 +46,7 @@ <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> + <version>5.2.14.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> @@ -107,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/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/JerseyConfiguration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java index d69c395f96..031e9eee2a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java @@ -65,6 +65,7 @@ public class JerseyConfiguration extends ResourceConfig { register(NodeHealthcheckHandler.class); register(ServiceInstances.class); register(Onap3gppServiceInstances.class); + register(ServiceIntentApiHandler.class); register(TasksHandler.class); register(CloudOrchestration.class); register(CloudResourcesOrchestration.class); 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-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceIntentApiHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceIntentApiHandler.java new file mode 100644 index 0000000000..be63c5fb9a --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceIntentApiHandler.java @@ -0,0 +1,431 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2021 Huawei Technologies. + * ================================================================================ + * 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.apihandlerinfra; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import org.apache.http.HttpStatus; +import org.onap.logging.filter.base.ErrorCode; +import org.onap.so.apihandler.camundabeans.CamundaResponse; +import org.onap.so.apihandler.common.CamundaClient; +import org.onap.so.apihandler.common.ErrorNumbers; +import org.onap.so.apihandler.common.RequestClientParameter; +import org.onap.so.apihandler.common.ResponseBuilder; +import org.onap.so.apihandler.common.ResponseHandler; +import org.onap.so.apihandlerinfra.exceptions.ApiException; +import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException; +import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException; +import org.onap.so.apihandlerinfra.exceptions.ValidateException; +import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; +import org.onap.so.apihandlerinfra.serviceintentinstancebeans.ServiceIntentCommonRequest; +import org.onap.so.apihandlerinfra.serviceintentinstancebeans.ServiceIntentCreationRequest; +import org.onap.so.apihandlerinfra.serviceintentinstancebeans.ServiceIntentDeletionRequest; +import org.onap.so.apihandlerinfra.serviceintentinstancebeans.ServiceIntentModificationRequest; +import org.onap.so.constants.Status; +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.ServiceRecipe; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.client.RequestsDbClient; +import org.onap.so.logger.LogConstants; +import org.onap.so.logger.LoggingAnchor; +import org.onap.so.logger.MessageEnum; +import org.onap.so.serviceinstancebeans.ModelType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.sql.Timestamp; +import java.util.HashMap; +import java.util.function.Function; + +/** + * This class serves as the entry point for Service Intent APIs. Unlike User Intent, which describes Intent using + * natural languages, Service Intent describes Intent through technology-agnostic and model-driven APIs. The Service + * Intent APIs have the following format: {service-Intent-Root}/{operation}, where {operation} may be "create", + * "delete", "modify", etc. And the parameters of the Intent service instance are specified in the payloads of the APIs. + * <p> + * For scalability, these APIs are designed to be generic, and thus support all the service Intent use-cases. i.e., The + * actual intent use-case/application, e.g., Cloud Leased Line, is differentiated by the "serviceType" parameter in the + * payload, rather than by specific APIs. Thus, this class does not need to grow when we add new Intent use-cases or + * applications. + * <p> + */ +@Component +@Path("/onap/so/infra/serviceIntent") +@OpenAPIDefinition(info = @Info(title = "/onap/so/infra/serviceIntent", + description = "API Requests for Intent services and " + "applications")) +public class ServiceIntentApiHandler { + + private static final Logger logger = LoggerFactory.getLogger(ServiceIntentApiHandler.class); + + private static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; + + private static final String END_OF_THE_TRANSACTION = "End of the transaction, the final response is: "; + + private static final String SAVE_TO_DB = "save instance to db"; + + private static final String URI_PREFIX = "/serviceIntent/"; + + @Autowired + private MsoRequest msoRequest; + + @Autowired + private CatalogDbClient catalogDbClient; + + @Autowired + private RequestsDbClient requestsDbClient; + + @Autowired + private RequestHandlerUtils requestHandlerUtils; + + @Autowired + private ResponseBuilder builder; + + @Autowired + private CamundaClient camundaClient; + + @Autowired + private ResponseHandler responseHandler; + + // @Value("${serviceIntent.config.file}") + // private String serviceIntentConfigFile; + + /** + * POST Requests for create Service Intent Instance on a version provided + * + * @throws ApiException + */ + + @POST + @Path("/{version:[vV][1]}/create") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Operation(description = "Create a SI Instance on a version provided", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + public Response createServiceIntentInstance(ServiceIntentCreationRequest request, + @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + return processServiceIntentRequest(request, Action.createInstance, version, requestId, null, + requestHandlerUtils.getRequestUri(requestContext, URI_PREFIX)); + } + + /** + * PUT Requests for Service Intent Modification on a version provided + * + * @throws ApiException + */ + + @PUT + @Path("/{version:[vV][1]}/modify") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Operation(description = "Modify a SI Instance on a version provided", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + public Response modifyServiceIntentInstance(ServiceIntentModificationRequest request, + @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", request.getServiceInstanceID()); + return processServiceIntentRequest(request, Action.updateInstance, version, requestId, instanceIdMap, + requestHandlerUtils.getRequestUri(requestContext, URI_PREFIX)); + } + + /** + * DELETE Requests for Service Intent Instance on a specified version + * + * @throws ApiException + */ + + @DELETE + @Path("/{version:[vV][1]}/delete") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Operation(description = "Terminate/Delete a SI Service Instance on a version provided", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + public Response deleteServiceIntentInstance(ServiceIntentDeletionRequest request, + @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", request.getServiceInstanceID()); + return processServiceIntentRequest(request, Action.deleteInstance, version, requestId, instanceIdMap, + requestHandlerUtils.getRequestUri(requestContext, URI_PREFIX)); + } + + /** + * Process Service Intent request and send request to corresponding workflow + * + * @param request + * @param action + * @param version + * @return + * @throws ApiException + */ + private Response processServiceIntentRequest(ServiceIntentCommonRequest request, Action action, String version, + String requestId, HashMap<String, String> instanceIdMap, String requestUri) throws ApiException { + String defaultServiceModelName = "COMMON_SI_DEFAULT"; + String requestScope = ModelType.service.name(); + String apiVersion = version.substring(1); + String serviceRequestJson = toString.apply(request); + + String instanceName = null; + String modelUuid = null; + String serviceInstanceId = null; + + try { + if (action == Action.createInstance) { + instanceName = ((ServiceIntentCreationRequest) request).getName(); + modelUuid = ((ServiceIntentCreationRequest) request).getModelUuid(); + } else if (action == Action.updateInstance) { + instanceName = ((ServiceIntentModificationRequest) request).getName(); + serviceInstanceId = ((ServiceIntentModificationRequest) request).getServiceInstanceID(); + } else if (action == Action.deleteInstance) { + serviceInstanceId = ((ServiceIntentDeletionRequest) request).getServiceInstanceID(); + } + } catch (Exception e) { + logger.error("ERROR: processCllServiceRequest: Exception: ", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, + MsoException.ServiceException, "processCllServiceRequest error", ErrorNumbers.SVC_BAD_PARAMETER, + null, version); + return response; + } + + if (serviceRequestJson != null) { + InfraActiveRequests currentActiveReq = createRequestObject(request, action, requestId, Status.IN_PROGRESS, + requestScope, serviceRequestJson); + + requestHandlerUtils.checkForDuplicateRequests(action, instanceIdMap, requestScope, currentActiveReq, + instanceName); + try { + requestsDbClient.save(currentActiveReq); + } catch (Exception e) { + logger.error("Exception occurred", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) + .errorInfo(errorLoggerInfo).build(); + } + + RecipeLookupResult recipeLookupResult; + try { + recipeLookupResult = getServiceInstanceOrchestrationURI(modelUuid, action, defaultServiceModelName); + } catch (Exception e) { + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.AvailabilityError.getValue(), "Exception while communicate with Catalog DB", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "No " + "communication to catalog DB " + e.getMessage(), + ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + if (recipeLookupResult == null) { + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.DataError.getValue(), "No recipe found in DB"); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "Recipe does " + "not exist in catalog DB", + ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + String serviceInstanceType = request.getSubscriptionServiceType(); + RequestClientParameter parameter; + try { + parameter = new RequestClientParameter.Builder().setRequestId(requestId).setBaseVfModule(false) + .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.name()) + .setServiceInstanceId(serviceInstanceId).setServiceType(serviceInstanceType) + .setRequestDetails(serviceRequestJson).setApiVersion(version).setALaCarte(false) + .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).setApiVersion(apiVersion).build(); + } catch (Exception e) { + logger.error("Exception occurred", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new ValidateException.Builder("Unable to generate RequestClientParameter object" + e.getMessage(), + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo) + .build(); + } + return postBPELRequest(currentActiveReq, parameter, recipeLookupResult.getOrchestrationURI(), requestScope); + } else { + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, + MsoException.ServiceException, "JsonProcessingException occurred - " + "serviceRequestJson is null", + ErrorNumbers.SVC_BAD_PARAMETER, null, version); + return response; + } + } + + /** + * Getting recipes from catalogDb + * + * @param serviceModelUUID the service model version uuid + * @param action the action for the service + * @param defaultServiceModelName default service name + * @return the service recipe result + */ + private RecipeLookupResult getServiceInstanceOrchestrationURI(String serviceModelUUID, Action action, + String defaultServiceModelName) { + + RecipeLookupResult recipeLookupResult = getServiceURI(serviceModelUUID, action, defaultServiceModelName); + + if (recipeLookupResult != null) { + logger.debug("Orchestration URI is: " + recipeLookupResult.getOrchestrationURI() + ", recipe Timeout is: " + + Integer.toString(recipeLookupResult.getRecipeTimeout())); + } else { + logger.debug("No matching recipe record found"); + } + return recipeLookupResult; + } + + /** + * Getting recipes from catalogDb If Service recipe is not set, use default recipe, if set , use special recipe. + * + * @param serviceModelUUID the service version uuid + * @param action the action of the service. + * @param defaultServiceModelName default service name + * @return the service recipe result. + */ + private RecipeLookupResult getServiceURI(String serviceModelUUID, Action action, String defaultServiceModelName) { + + Service defaultServiceRecord = + catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName); + // set recipe as default generic recipe + ServiceRecipe recipe = + catalogDbClient.getFirstByServiceModelUUIDAndAction(defaultServiceRecord.getModelUUID(), action.name()); + // check the service special recipe + if (null != serviceModelUUID && !serviceModelUUID.isEmpty()) { + ServiceRecipe serviceSpecialRecipe = + catalogDbClient.getFirstByServiceModelUUIDAndAction(serviceModelUUID, action.name()); + if (null != serviceSpecialRecipe) { + // set service special recipe. + recipe = serviceSpecialRecipe; + } + } + + if (recipe == null) { + return null; + } + return new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout(), recipe.getParamXsd()); + + } + + Function<Object, String> toString = serviceRequest -> { + ObjectMapper mapper = new ObjectMapper(); + String requestAsString = null; + try { + requestAsString = mapper.writeValueAsString(serviceRequest); + } catch (JsonProcessingException e) { + logger.debug("Exception while converting service request object to String {}", e); + } + return requestAsString; + }; + + private InfraActiveRequests createRequestObject(ServiceIntentCommonRequest request, Action action, String requestId, + Status status, String requestScope, String requestJson) { + InfraActiveRequests aq = new InfraActiveRequests(); + try { + String serviceInstanceName = null; + String serviceInstanceId = null; + String serviceType = request.getServiceType(); + if (action.name().equals("createInstance")) { + serviceInstanceName = ((ServiceIntentCreationRequest) request).getName(); + aq.setServiceInstanceName(serviceInstanceName); + } else if (action.name().equals("updateInstance")) { + serviceInstanceName = ((ServiceIntentModificationRequest) request).getName(); + serviceInstanceId = ((ServiceIntentModificationRequest) request).getServiceInstanceID(); + aq.setServiceInstanceName(serviceInstanceName); + aq.setServiceInstanceId(serviceInstanceId); + } else if (action.name().equals("deleteInstance")) { + serviceInstanceId = ((ServiceIntentDeletionRequest) request).getServiceInstanceID(); + aq.setServiceInstanceId(serviceInstanceId); + } + + aq.setRequestId(requestId); + aq.setRequestAction(action.toString()); + aq.setRequestUrl(MDC.get(LogConstants.HTTP_URL)); + Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis()); + aq.setStartTime(startTimeStamp); + aq.setRequestScope(requestScope); + aq.setRequestBody(requestJson); + aq.setRequestStatus(status.toString()); + aq.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); + aq.setServiceType(serviceType); + } catch (Exception e) { + logger.error("Exception when creation record request", e); + + if (!status.equals(Status.FAILED)) { + throw e; + } + } + return aq; + } + + private Response postBPELRequest(InfraActiveRequests currentActiveReq, RequestClientParameter parameter, + String orchestrationURI, String requestScope) throws ApiException { + ResponseEntity<String> response = + requestHandlerUtils.postRequest(currentActiveReq, parameter, orchestrationURI); + logger.debug("BPEL response : " + response); + int bpelStatus = responseHandler.setStatus(response.getStatusCodeValue()); + String jsonResponse; + try { + responseHandler.acceptedResponse(response); + CamundaResponse camundaResponse = responseHandler.getCamundaResponse(response); + String responseBody = camundaResponse.getResponse(); + if ("Success".equalsIgnoreCase(camundaResponse.getMessage())) { + jsonResponse = responseBody; + } else { + BPMNFailureException bpmnException = + new BPMNFailureException.Builder(String.valueOf(bpelStatus) + responseBody, bpelStatus, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).build(); + requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, bpmnException.getMessage()); + throw bpmnException; + } + } catch (ApiException e) { + requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, e.getMessage()); + throw e; + } + return builder.buildResponse(HttpStatus.SC_ACCEPTED, parameter.getRequestId(), jsonResponse, + parameter.getApiVersion()); + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/serviceintentinstancebeans/ServiceIntentCommonRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/serviceintentinstancebeans/ServiceIntentCommonRequest.java new file mode 100644 index 0000000000..f27f88c428 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/serviceintentinstancebeans/ServiceIntentCommonRequest.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies. + * ================================================================================ + * 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.apihandlerinfra.serviceintentinstancebeans; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.HashMap; +import java.util.Map; + +/** + * Model class for common parameter of Service Intent request + */ +public class ServiceIntentCommonRequest { + + @JsonProperty("globalSubscriberId") + private String globalSubscriberId; + + @JsonProperty("subscriptionServiceType") + private String subscriptionServiceType; + + @JsonProperty("additionalProperties") + private Map<String, Object> additionalProperties = new HashMap<>(); + + @JsonProperty("serviceType") + private String serviceType; + + public String getGlobalSubscriberId() { + return globalSubscriberId; + } + + public void setGlobalSubscriberId(String globalSubscriberId) { + this.globalSubscriberId = globalSubscriberId; + } + + public String getSubscriptionServiceType() { + return subscriptionServiceType; + } + + public void setSubscriptionServiceType(String subscriptionServiceType) { + this.subscriptionServiceType = subscriptionServiceType; + } + + public Map<String, Object> getAdditionalProperties() { + return additionalProperties; + } + + public void setAdditionalProperties(Map<String, Object> additionalProperties) { + this.additionalProperties = additionalProperties; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + @Override + public String toString() { + return "ServiceIntentCommonRequest [globalSubscriberId=" + globalSubscriberId + ", subscriptionServiceType=" + + subscriptionServiceType + ", serviceType=" + serviceType + ", additionalProperties=" + + additionalProperties + "]"; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/serviceintentinstancebeans/ServiceIntentCreationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/serviceintentinstancebeans/ServiceIntentCreationRequest.java new file mode 100644 index 0000000000..bc711a00dc --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/serviceintentinstancebeans/ServiceIntentCreationRequest.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies. + * ================================================================================ + * 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.apihandlerinfra.serviceintentinstancebeans; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Model class for Service Intent Creation request + */ +public class ServiceIntentCreationRequest extends ServiceIntentCommonRequest { + + @JsonProperty("name") + private String name; + + @JsonProperty("modelInvariantUuid") + private String modelInvariantUuid; + + @JsonProperty("modelUuid") + private String modelUuid; + + @JsonProperty("sst") + private String sST; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getModelInvariantUuid() { + return modelInvariantUuid; + } + + public void setModelInvariantUuid(String modelInvariantUuid) { + this.modelInvariantUuid = modelInvariantUuid; + } + + public String getModelUuid() { + return modelUuid; + } + + public void setModelUuid(String modelUuid) { + this.modelUuid = modelUuid; + } + + public String getsST() { + return sST; + } + + public void setsST(String sST) { + this.sST = sST; + } + + @Override + public String toString() { + return "ServiceIntentCreationRequest [name=" + name + ", modelInvariantUuid=" + modelInvariantUuid + + ", modelUuid=" + modelUuid + ", globalSubscriberId=" + getGlobalSubscriberId() + + ", subscriptionServiceType=" + getSubscriptionServiceType() + ", serviceType=" + getServiceType() + + ", additionalProperties=" + getAdditionalProperties() + "]"; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/serviceintentinstancebeans/ServiceIntentDeletionRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/serviceintentinstancebeans/ServiceIntentDeletionRequest.java new file mode 100644 index 0000000000..c463c7bae4 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/serviceintentinstancebeans/ServiceIntentDeletionRequest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies. + * ================================================================================ + * 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.apihandlerinfra.serviceintentinstancebeans; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Model class for service intent instance terminate request + */ +public class ServiceIntentDeletionRequest extends ServiceIntentCommonRequest { + + @JsonProperty("serviceInstanceID") + private String serviceInstanceID; + + public String getServiceInstanceID() { + return serviceInstanceID; + } + + public void setServiceInstanceID(String serviceInstanceID) { + this.serviceInstanceID = serviceInstanceID; + } + + @Override + public String toString() { + return "ServiceIntentDeletionRequest [serviceInstanceID=" + getServiceInstanceID() + ", globalSubscriberId=" + + getGlobalSubscriberId() + ", subscriptionServiceType=" + getSubscriptionServiceType() + + ", serviceType=" + getServiceType() + ", additionalProperties=" + getAdditionalProperties() + "]"; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/serviceintentinstancebeans/ServiceIntentModificationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/serviceintentinstancebeans/ServiceIntentModificationRequest.java new file mode 100644 index 0000000000..17d6dc84ab --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/serviceintentinstancebeans/ServiceIntentModificationRequest.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2021 Huawei Technologies. + * ================================================================================ + * 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.apihandlerinfra.serviceintentinstancebeans; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Model class for Service Intent Update request + */ +public class ServiceIntentModificationRequest extends ServiceIntentCommonRequest { + + @JsonProperty("name") + private String name; + + @JsonProperty("serviceInstanceID") + private String serviceInstanceID; + + public String getServiceInstanceID() { + return serviceInstanceID; + } + + public void setServiceInstanceID(String serviceInstanceID) { + this.serviceInstanceID = serviceInstanceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "ServiceIntentModificationRequest [name=" + name + ", serviceInstanceID=" + getServiceInstanceID() + + ", globalSubscriberId=" + getGlobalSubscriberId() + ", subscriptionServiceType=" + + getSubscriptionServiceType() + ", serviceType=" + getServiceType() + ", additionalProperties=" + + getAdditionalProperties() + "]"; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceIntentApiHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceIntentApiHandlerTest.java new file mode 100644 index 0000000000..059c2bc057 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceIntentApiHandlerTest.java @@ -0,0 +1,156 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ================================================================================ + * 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.apihandlerinfra; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.http.HttpStatus; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.ServiceRecipe; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.web.util.UriComponentsBuilder; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static org.junit.Assert.assertEquals; +import static org.onap.logging.filter.base.Constants.HttpHeaders.ONAP_PARTNER_NAME; +import static org.onap.logging.filter.base.Constants.HttpHeaders.ONAP_REQUEST_ID; +import static org.onap.logging.filter.base.Constants.HttpHeaders.TRANSACTION_ID; +import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID; + +public class ServiceIntentApiHandlerTest extends BaseTest { + + private static final String ROOT_URI = "/onap/so/infra/serviceIntent/"; + + private static final ObjectMapper MAPPER = new ObjectMapper(); + + @Autowired + private Onap3gppServiceInstances objUnderTest; + + @Before + public void init() throws JsonProcessingException { + + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setServiceModelUUID(defaultService.getModelUUID()); + serviceRecipe.setRecipeTimeout(180); + serviceRecipe.setOrchestrationUri("/mso/async/services/commonServiceIntentTest"); + + wireMockServer.stubFor(get(urlPathEqualTo("/service/search/findFirstByModelNameOrderByModelVersionDesc")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(MAPPER.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlPathEqualTo("/serviceRecipe/search/findFirstByServiceModelUUIDAndAction")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(MAPPER.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK))); + wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/")).willReturn(aResponse() + .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK))); + Mockito.doReturn(null).when(requestsDbClient).getInfraActiveRequestbyRequestId(Mockito.any()); + } + + public String inputStream(String JsonInput) throws IOException { + JsonInput = "src/test/resources/ServiceIntentTest" + JsonInput; + return new String(Files.readAllBytes(Paths.get(JsonInput))); + } + + public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod) { + HttpHeaders headers = new HttpHeaders(); + headers.set("Accept", MediaType.APPLICATION_JSON); + headers.set("Content-Type", MediaType.APPLICATION_JSON); + headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name"); + headers.set(TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); + headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); + headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); + headers.set(ONAP_PARTNER_NAME, "VID"); + headers.set(REQUESTOR_ID, "xxxxxx"); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath)); + HttpEntity<String> request = new HttpEntity<>(requestJson, headers); + + return restTemplate.exchange(builder.toUriString(), reqMethod, request, String.class); + } + + @Test + public void createServiceInstanceTest() throws IOException { + String uri = ROOT_URI + "v1/create"; + wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/commonServiceIntentTest")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/BPMN_response.json").withStatus(HttpStatus.SC_ACCEPTED))); + + String expectedResponse = + "{\"jobId\":\"db245365e79c47ed88fcd60caa8f6549\",\"status\":\"\",\"statusDescription\":{}}"; + ResponseEntity<String> response = sendRequest(inputStream("/create-cll-payload.json"), uri, HttpMethod.POST); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + String actualResponse = response.getBody(); + assertEquals(expectedResponse, actualResponse); + } + + @Test + public void updateServiceInstanceTest() throws IOException { + String uri = ROOT_URI + "v1/modify"; + wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/commonServiceIntentTest")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/BPMN_response.json").withStatus(HttpStatus.SC_ACCEPTED))); + + String expectedResponse = + "{\"jobId\":\"db245365e79c47ed88fcd60caa8f6549\",\"status\":\"\",\"statusDescription\":{}}"; + ResponseEntity<String> response = sendRequest(inputStream("/modify-cll-payload.json"), uri, HttpMethod.PUT); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + String actualResponse = response.getBody(); + assertEquals(expectedResponse, actualResponse); + } + + @Test + public void deleteServiceInstanceTest() throws IOException { + String uri = ROOT_URI + "v1/delete"; + wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/commonServiceIntentTest")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/BPMN_response.json").withStatus(HttpStatus.SC_ACCEPTED))); + String expectedResponse = + "{\"jobId\":\"db245365e79c47ed88fcd60caa8f6549\",\"status\":\"\",\"statusDescription\":{}}"; + ResponseEntity<String> response = sendRequest(inputStream("/delete-cll-payload.json"), uri, HttpMethod.DELETE); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + String actualResponse = response.getBody(); + assertEquals(expectedResponse, actualResponse); + } + + +} + + diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceIntentTest/create-cll-payload.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceIntentTest/create-cll-payload.json new file mode 100644 index 0000000000..6018392abd --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceIntentTest/create-cll-payload.json @@ -0,0 +1,29 @@ +{ + "name": "cloud-leased-line-101", + "modelInvariantUuid": "6790ab0e-034f-11eb-adc1-0242ac120002", + "modelUuid": "6790ab0e-034f-11eb-adc1-0242ac120002", + "globalSubscriberId": "IBNCustomer", + "subscriptionServiceType": "IBN", + "serviceType": "CLL", + "additionalProperties": { + "enableSdnc": "false", + "serviceInstanceID": "cll-101", + "transportNetworks": [ + { + "id": "cll-101-network-001", + "sla": { + "latency": 2, + "maxBandwidth": 3000 + }, + "connectionLinks": [ + { + "name": "cll-link-1", + "transportEndpointA": "tranportEp_UNI_ID_311_1", + "transportEndpointB": "tranportEp_ROOT_ID_512_1" + } + ] + } + ] + } +} + diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceIntentTest/delete-cll-payload.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceIntentTest/delete-cll-payload.json new file mode 100644 index 0000000000..f21f4e3cea --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceIntentTest/delete-cll-payload.json @@ -0,0 +1,9 @@ +{ + "serviceInstanceID": "cll-101", + "globalSubscriberId": "IBNCustomer", + "subscriptionServiceType": "IBN", + "serviceType": "CLL", + "additionalProperties": { + "enableSdnc": "false" + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceIntentTest/modify-cll-payload.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceIntentTest/modify-cll-payload.json new file mode 100644 index 0000000000..3611adaf3b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceIntentTest/modify-cll-payload.json @@ -0,0 +1,29 @@ +{ + "serviceInstanceID": "cll-101", + "name": "cloud-leased-line-101", + "modelInvariantUuid": "6790ab0e-034f-11eb-adc1-0242ac120002", + "modelUuid": "6790ab0e-034f-11eb-adc1-0242ac120002", + "globalSubscriberId": "IBNCustomer", + "subscriptionServiceType": "IBN", + "serviceType": "CLL", + "additionalProperties": { + "enableSdnc": "false", + "transportNetworks": [ + { + "id": "cll-101-network-001", + "sla": { + "latency": 2, + "maxBandwidth": 8000 + }, + "connectionLinks": [ + { + "name": "cll-link-1", + "transportEndpointA": "tranportEp_UNI_ID_311_1", + "transportEndpointB": "tranportEp_ROOT_ID_512_1" + } + ] + } + ] + } +} + 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> @@ -488,7 +488,7 @@ <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> - <version>2.9.8</version> + <version>2.12.1</version> </dependency> </dependencies> </plugin> @@ -884,13 +884,13 @@ <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> - <version>1.12</version> + <version>1.15</version> <scope>compile</scope> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> - <version>2.5</version> + <version>2.8.0</version> <scope>compile</scope> </dependency> <dependency> |