From d621d2baca674f8e0491acf3f7d1088787f975fd Mon Sep 17 00:00:00 2001 From: Abhishek Patil Date: Wed, 12 Apr 2023 18:51:19 +0530 Subject: Code changes in BPMN infra for RAN Slice Use case New module so-bomn-moi is created. New bpmn flows : AssignRANNssiBB ActivateRANNssiBB ModifyRANNssiBB DeleteRANNssiBB Issue-ID: SO-4039 Signed-off-by: Patil Change-Id: Ifad4e0a65dc810a753d30123a84c08081bcfd987 --- .../onap/so/bpmn/common/scripts/OofUtils.groovy | 24 ++ .../servicedecomposition/entities/ResourceKey.java | 6 +- .../servicedecomposition/tasks/BBInputSetup.java | 76 +++- .../onap/so/client/cds/GeneratePayloadForCds.java | 8 + .../onap/so/client/cds/NssiCDSRequestProvider.java | 284 +++++++++++++ .../org/onap/so/client/cds/PayloadConstants.java | 1 + bpmn/mso-infrastructure-bpmn/pom.xml | 5 + bpmn/pom.xml | 1 + .../BuildingBlock/ExecuteBuildingBlock.bpmn | 443 ++++++++++++--------- .../bpmn/subprocess/ExecuteBuildingBlockTest.java | 5 + bpmn/so-bpmn-moi/pom.xml | 173 ++++++++ .../so/bpmn/moi/tasks/AssignRANNssiBBTasks.java | 335 ++++++++++++++++ .../so/bpmn/moi/tasks/DeleteRANNssiBBTask.java | 73 ++++ .../org/onap/so/bpmn/moi/tasks/EnrichGBBTask.java | 208 ++++++++++ .../so/bpmn/moi/tasks/ModifyRANNssiBBTask.java | 186 +++++++++ .../onap/so/bpmn/moi/util/AAISliceProfileUtil.java | 279 +++++++++++++ .../moi/util/SliceProfileAaiToMoiMapperUtil.java | 94 +++++ .../main/resources/process/ActivateRANNssiBB.bpmn | 39 ++ .../main/resources/process/AssignRANNssiBB.bpmn | 99 +++++ .../main/resources/process/DeleteRANNssiBB.bpmn | 39 ++ .../src/main/resources/process/EnrichGBB.bpmn | 74 ++++ .../main/resources/process/ModifyRANNssiBB.bpmn | 39 ++ .../bpmn/moi/tasks/AssignRANNssiBBTasksTest.java | 162 ++++++++ .../so/bpmn/moi/tasks/DeleteRANNssiBBTaskTest.java | 101 +++++ .../onap/so/bpmn/moi/tasks/EnrichGBBTaskTest.java | 41 ++ .../so/bpmn/moi/tasks/ModifyRANNssiBBTaskTest.java | 121 ++++++ .../flowspecific/tasks/ControllerExecution.java | 8 + .../flowspecific/tasks/NssiCDSProcessingBB.java | 87 ++++ .../workflow/tasks/WorkflowAction.java | 9 +- .../workflow/tasks/WorkflowActionConstants.java | 1 + .../ebb/loader/NetworkSliceSubnetEBBLoader.java | 60 +++ .../so/client/orchestration/ApiHandlerClient.java | 4 +- 32 files changed, 2888 insertions(+), 197 deletions(-) create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/NssiCDSRequestProvider.java create mode 100644 bpmn/so-bpmn-moi/pom.xml create mode 100644 bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/AssignRANNssiBBTasks.java create mode 100644 bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/DeleteRANNssiBBTask.java create mode 100644 bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/EnrichGBBTask.java create mode 100644 bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/ModifyRANNssiBBTask.java create mode 100644 bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/util/AAISliceProfileUtil.java create mode 100644 bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/util/SliceProfileAaiToMoiMapperUtil.java create mode 100644 bpmn/so-bpmn-moi/src/main/resources/process/ActivateRANNssiBB.bpmn create mode 100644 bpmn/so-bpmn-moi/src/main/resources/process/AssignRANNssiBB.bpmn create mode 100644 bpmn/so-bpmn-moi/src/main/resources/process/DeleteRANNssiBB.bpmn create mode 100644 bpmn/so-bpmn-moi/src/main/resources/process/EnrichGBB.bpmn create mode 100644 bpmn/so-bpmn-moi/src/main/resources/process/ModifyRANNssiBB.bpmn create mode 100644 bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/AssignRANNssiBBTasksTest.java create mode 100644 bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/DeleteRANNssiBBTaskTest.java create mode 100644 bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/EnrichGBBTaskTest.java create mode 100644 bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/ModifyRANNssiBBTaskTest.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NssiCDSProcessingBB.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/NetworkSliceSubnetEBBLoader.java diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy index 69c1c9f8ac..0e6cb64751 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy @@ -547,6 +547,30 @@ class OofUtils { return response.toString() } + public String buildSelectNSSTRequest(String requestId,String messageType, Map profileInfo) { + def transactionId = requestId + logger.debug( "transactionId is: " + transactionId) + String correlator = requestId + String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator + ObjectMapper objectMapper = new ObjectMapper() + String json = objectMapper.writeValueAsString(profileInfo) + StringBuilder response = new StringBuilder() + response.append( + "{\n" + + " \"requestInfo\": {\n" + + " \"transactionId\": \"${transactionId}\",\n" + + " \"requestId\": \"${requestId}\",\n" + + " \"sourceId\": \"so\",\n" + + " \"timeout\": 600,\n" + + " \"callbackUrl\": \"${callbackUrl}\"\n" + + " },\n") + response.append(" \"SliceProfile\":") + response.append(json) + response.append("\n}\n") + return response.toString() + } + + public String buildSelectNSIRequest(String requestId, String nstInfo,String messageType, Map profileInfo){ def transactionId = requestId diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java index aa5da4c790..57d00efb7d 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java @@ -39,5 +39,9 @@ public enum ResourceKey { VNF_INSTANCE_NAME, VF_MODULE_INSTANCE_NAME, CHILD_SERVICE_INSTANCE_ID, - CHILD_SERVICE_INSTANCE_NAME + CHILD_SERVICE_INSTANCE_NAME, + ServiceInstance, + ModelInfoServiceInstance, + operationalState, + administrativeState } 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 178612c4bd..b38bd25c66 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 @@ -75,6 +75,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.entities.ServiceModel; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException; @@ -189,6 +190,13 @@ public class BBInputSetup implements JavaDelegate { boolean homing = Boolean.TRUE.equals(executeBB.isHoming()); Map lookupKeyMap = new HashMap<>(); outputBB = this.getGBB(executeBB, lookupKeyMap, requestAction, aLaCarte, resourceId, vnfType); + logger.debug("setting Homing"); + if (executeBB.getBuildingBlock().getBpmnFlowName().contains("AssignRANNssiBB")) { + execution.setVariable("homing", true); + } else { + execution.setVariable("homing", false); + } + ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationFeature.INDENT_OUTPUT); logger.debug("GeneralBB: " + mapper.writeValueAsString(outputBB)); @@ -240,6 +248,11 @@ public class BBInputSetup implements JavaDelegate { requestDetails = bbInputSetupUtils.getRequestDetails(requestId); } if (requestDetails.getModelInfo() == null) { + if (requestAction.contains("RanSlice")) { + logger.debug(">>> RequestAction: {}", executeBB.getRequestAction()); + + return this.getGBBRanSlicing(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId); + } return this.getGBBCM(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId); } else { ModelType modelType = requestDetails.getModelInfo().getModelType(); @@ -347,7 +360,7 @@ public class BBInputSetup implements JavaDelegate { List genericVnfs = serviceInstance.getVnfs(); String vnfId = lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID); - if (vnfId != null) { + if (vnfId != null && !vnfId.isEmpty()) { org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId); GenericVnf genericVnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf); genericVnfs.add(genericVnf); @@ -394,6 +407,67 @@ public class BBInputSetup implements JavaDelegate { return this.populateGBBWithSIAndAdditionalInfo(parameter); } + protected GeneralBuildingBlock getGBBRanSlicing(ExecuteBuildingBlock executeBB, RequestDetails requestDetails, + Map lookupKeyMap, String requestAction, String resourceId) throws Exception { + org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = null; + String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID); + + executeBB.setHoming(true); + Customer customer = new Customer(); + + String subscriberId = executeBB.getRequestDetails().getSubscriberInfo().getGlobalSubscriberId(); + customer.setGlobalCustomerId(subscriberId); + + String subscriberName = executeBB.getRequestDetails().getSubscriberInfo().getSubscriberName(); + customer.setSubscriberName(subscriberName); + + String subscriptionType = executeBB.getRequestDetails().getRequestParameters().getSubscriptionServiceType(); + + ServiceSubscription serviceSubscription = new ServiceSubscription(); + serviceSubscription.setServiceType(subscriptionType); + + customer.setServiceSubscription(serviceSubscription); + + String bbName = executeBB.getBuildingBlock().getBpmnFlowName(); + + serviceInstanceAAI = getServiceInstanceAAI(requestDetails, customer, serviceInstanceId, false, bbName); + + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId(serviceInstanceId); + logger.debug(">>>>> serviceInstanceAAI: {}", serviceInstanceAAI); + if (serviceInstanceAAI != null) { + String modelVersionId = serviceInstanceAAI.getModelVersionId(); + + Service service = bbInputSetupUtils.getCatalogServiceByModelUUID(modelVersionId); + + // Check if there is any existing method for mapping + String modelInvariantId = serviceInstanceAAI.getModelInvariantId(); + String modelVersion = service.getModelVersion(); + String serviceType = service.getServiceType(); + String serviceRole = service.getServiceRole(); + String controllerActor = service.getControllerActor(); + String blueprintName = service.getBlueprintName(); + String blueprintVersion = service.getBlueprintVersion(); + + ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); + modelInfoServiceInstance.setServiceType(serviceType); + modelInfoServiceInstance.setServiceRole(serviceRole); + modelInfoServiceInstance.setControllerActor(controllerActor); + modelInfoServiceInstance.setBlueprintName(blueprintName); + modelInfoServiceInstance.setBlueprintVersion(blueprintVersion); + modelInfoServiceInstance.setModelInvariantUuid(modelInvariantId); + modelInfoServiceInstance.setModelUuid(modelVersionId); + modelInfoServiceInstance.setModelVersion(modelVersion); + + serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); + } + BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestDetails(requestDetails) + .setServiceInstance(serviceInstance).setExecuteBB(executeBB).setRequestAction(requestAction) + .setCustomer(customer).build(); + return this.populateGBBWithSIAndAdditionalInfo(parameter); + + } + protected void populateObjectsOnAssignAndCreateFlows(BBInputSetupParameter parameter) throws Exception { parameter.setModelInfo(parameter.getRequestDetails().getModelInfo()); parameter.setInstanceName(parameter.getRequestDetails().getRequestInfo().getInstanceName()); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/GeneratePayloadForCds.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/GeneratePayloadForCds.java index fb79880572..12d5d06b53 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/GeneratePayloadForCds.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/GeneratePayloadForCds.java @@ -56,6 +56,10 @@ public class GeneratePayloadForCds { @Autowired private PnfCDSRequestProvider pnfCDSRequestProvider; + @Autowired + private NssiCDSRequestProvider nssiCDSRequestProvider; + + /** * Build properties like (blueprint name, version, action etc..) along with the request payload for vnf, vf-module * and service. @@ -145,6 +149,10 @@ public class GeneratePayloadForCds { case PayloadConstants.PNF_SCOPE: requestProvider = pnfCDSRequestProvider; break; + + case PayloadConstants.NSSI_SCOPE: + requestProvider = nssiCDSRequestProvider; + break; default: throw new PayloadGenerationException("No scope defined with " + scope); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/NssiCDSRequestProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/NssiCDSRequestProvider.java new file mode 100644 index 0000000000..d283092e0a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/NssiCDSRequestProvider.java @@ -0,0 +1,284 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2022 Deutsche telekom + * ================================================================================ + * 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.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.JsonObject; +import java.util.ArrayList; +import org.onap.aai.domain.yang.ServiceInstances; +import org.onap.aaiclient.client.aai.entities.CustomQuery; +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.aai.entities.uri.NodesSingleUri; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; +import org.onap.aaiclient.client.graphinventory.Format; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.InjectionHelper; +import org.onap.so.bpmn.core.json.JsonUtils; +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.BBObjectNotFoundException; +import org.onap.so.client.exception.PayloadGenerationException; +import org.onap.so.moi.Attributes; +import org.onap.so.moi.Snssai; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import static org.onap.so.client.cds.PayloadConstants.PROPERTIES; +import static org.onap.so.client.cds.PayloadConstants.SEPARATOR; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class NssiCDSRequestProvider implements CDSRequestProvider { + + private static final Logger LOGGER = LoggerFactory.getLogger(NssiCDSRequestProvider.class); + + private String blueprintName; + private String blueprintVersion; + private BuildingBlockExecution execution; + + private static final String DELETE_SLICE_PROFILE_ACTION = "delete-sliceprofile"; + private static final String CREATE_SLICE_PROFILE_ACTION = "create-sliceprofile"; + private static final String MODIFY_SLICE_PROFILE_ACTION = "modify-sliceprofile"; + private static final String SERVICE_INSTANCE_KEY = "service-instance"; + private static final String SERVICE_INSTANCE_ID_KEY = "service-instance-id"; + private static final String NSSI = "nssi"; + private static final String NSSI_ID = "nssiId"; + private static final String NSSI_NAME = "nssiName"; + private static final String NSI_NAME = "nsiName"; + private static final String NSI_ID = "nsiId"; + private static final String SLICE_PROFILE_INSTANCE_ID = "sliceProfileInstanceId"; + private static final String SLICE_INSTANCE_FROM_PROFILE_ID_CUSTOM_QUERY = + "related-to?startingNodeType=slice-profile&relatedToNodeType=service-instance"; + private static final String ENVIRONMENT_CONTEXT_QUERY_PARAM = "environment-context"; + private static final String AAI_SUPPORTED_SLICE_PROFILE = + "latency|maxNumberofUEs|coverageAreaTAList|areaTrafficCapDL|resourceSharingLevel|serviceType|uEMobilityLevel|expDataRateUL|expDataRateDL"; + private static final ObjectMapper mapper = new ObjectMapper(); + + JsonUtils jsonUtil = new JsonUtils(); + + @Autowired + private ExtractPojosForBB extractPojosForBB; + + @Autowired + private InjectionHelper injectionHelper; + + @Override + public String getBlueprintName() { + return blueprintName; + } + + @Override + public String getBlueprintVersion() { + return blueprintVersion; + } + + @Override + public void setExecutionObject(T executionObject) { + execution = (BuildingBlockExecution) executionObject; + } + + @Override + public Optional buildRequestPayload(String action) throws PayloadGenerationException { + JsonObject cdsPropertyObject = null; + + final GeneralBuildingBlock buildingBlock = execution.getGeneralBuildingBlock(); + List> userParamsFromRequest = + buildingBlock.getRequestContext().getRequestParameters().getUserParams(); + + try { + ServiceInstance serviceInstance = + extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); + // get values from service Instance + blueprintName = serviceInstance.getModelInfoServiceInstance().getBlueprintName(); + blueprintVersion = serviceInstance.getModelInfoServiceInstance().getBlueprintVersion(); + + } catch (Exception e) { + throw new PayloadGenerationException("Failed to buildPropertyObjectForNssi", e); + } + + cdsPropertyObject = setCreateSliceProfileRequestValues(action, buildingBlock); + + return Optional.of(buildRequestJsonObject(cdsPropertyObject, action)); + } + + private JsonObject setCreateSliceProfileRequestValues(String action, GeneralBuildingBlock buildingBlock) { + + JsonObject cdsRequestObject = new JsonObject(); + + ServiceInstance serviceInstance = null; + try { + serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); + } catch (BBObjectNotFoundException e) { + e.printStackTrace(); + } + + List> userParamsFromRequest = + buildingBlock.getRequestContext().getRequestParameters().getUserParams(); + + Attributes attributes = null; + + for (Map userParamData : userParamsFromRequest) { + if (userParamData.get(NSSI) != null) { + attributes = mapper.convertValue(userParamData.get(NSSI), Attributes.class); + } + } + // Value to come as a request == Hardcoded for now + String nssiId = serviceInstance.getServiceInstanceId(); + String nssiName = getNssiName(nssiId); + String nsiId = "nssi-id"; + String nsiName = "nssi-name"; + + cdsRequestObject.addProperty(NSSI_ID, nssiId); + + if (!DELETE_SLICE_PROFILE_ACTION.equals(action)) { + cdsRequestObject.addProperty(NSSI_NAME, nssiName); + cdsRequestObject.addProperty(NSI_NAME, nsiName); + } + + String sliceProfileInstanceId = null; + if (CREATE_SLICE_PROFILE_ACTION.equalsIgnoreCase(action)) { + Snssai snssai = attributes.getSliceProfileList().get(0).getPlmnInfoList().get(0).getSnssai(); + String sNssaiString = snssai.getSst() + SEPARATOR + snssai.getSd(); + sliceProfileInstanceId = getSliceProfileInstanceIdForNssi(sNssaiString); + } else { + String sliceProfileId = attributes.getSliceProfileList().get(0).getSliceProfileId(); + sliceProfileInstanceId = getSliceProfileInstanceFromSliceProfileId(sliceProfileId); + } + + cdsRequestObject.addProperty(SLICE_PROFILE_INSTANCE_ID, sliceProfileInstanceId); + + cdsRequestObject.addProperty(NSI_ID, nsiId); + /* + * JsonObject nssiPropertyObject = setSliceProfileProperties(getSliceProfilesFromUserParams(buildingBlock)); + * cdsRequestObject.add(action + SEPARATOR + PROPERTIES, nssiPropertyObject); + */ + return cdsRequestObject; + } + + private Map getSliceProfilesFromUserParams(GeneralBuildingBlock gBB) { + + + List> mapUserParams = gBB.getRequestContext().getRequestParameters().getUserParams(); + + Map sliceProfileMap = null; + try { + String userParamsJson = mapper.writeValueAsString(mapUserParams.get(0)); + String rANSliceSubnetProfile = + jsonUtil.getJsonParamValue(userParamsJson, "nssi.sliceProfileList", "RANSliceSubnetProfile"); + + if (rANSliceSubnetProfile != null) { + sliceProfileMap = mapper.readValue(rANSliceSubnetProfile, Map.class); + } + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return sliceProfileMap; + } + + // May be needed later + + /* + * private JsonObject setSliceProfileProperties(Map userParamsMap) { JsonObject + * sliceProfilePropertiesNotPresentInAai = new JsonObject(); + * + * if (userParamsMap != null) { userParamsMap.forEach((k, v) -> { if (!AAI_SUPPORTED_SLICE_PROFILE.contains((String) + * k)) { sliceProfilePropertiesNotPresentInAai.addProperty(k, v.toString()); } }); } + * + * return sliceProfilePropertiesNotPresentInAai; } + */ + + private String getSliceProfileInstanceFromSliceProfileId(String sliceProfileId) { + + List startNodes = new ArrayList<>(); + startNodes.add( + AAIUriFactory.createNodesUri(AAIFluentTypeBuilder.Types.SLICE_PROFILE.getFragment(sliceProfileId))); + + CustomQuery customQuery = new CustomQuery(startNodes, SLICE_INSTANCE_FROM_PROFILE_ID_CUSTOM_QUERY); + + String results = injectionHelper.getAaiQueryClient().query(Format.RESOURCE, customQuery); + + if (results == null || results.isEmpty()) { + throw new RuntimeException("Slice Profile Instance Not found"); + } + + Map>> serviceInstancesMap = null; + try { + serviceInstancesMap = mapper.readValue(results, Map.class); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + Map serviceInstance = + (Map) serviceInstancesMap.get("results").get(0).get(SERVICE_INSTANCE_KEY); + + return (String) serviceInstance.get(SERVICE_INSTANCE_ID_KEY); + } + + private String getSliceProfileInstanceIdForNssi(String sNssai) { + + String sliceProfileInstanceId = null; + + try { + AAIPluralResourceUri uriSI = + AAIUriFactory.createNodesUri(AAIFluentTypeBuilder.Types.SERVICE_INSTANCES.getFragment()) + .queryParam(ENVIRONMENT_CONTEXT_QUERY_PARAM, sNssai); + Optional sliceProfileInstancesOptional = + injectionHelper.getAaiClient().get(ServiceInstances.class, uriSI); + + if (sliceProfileInstancesOptional.isPresent()) { + sliceProfileInstanceId = + sliceProfileInstancesOptional.get().getServiceInstance().get(0).getServiceInstanceId(); + } + } catch (Exception e) { + LOGGER.error("Error in getting sliceProfile Instance" + e.getMessage()); + } + return sliceProfileInstanceId; + } + + private String getNssiName(String nssiId) { + + String nssiName = null; + + try { + NodesSingleUri uriSI = + AAIUriFactory.createNodesUri(AAIFluentTypeBuilder.Types.SERVICE_INSTANCE.getFragment(nssiId)); + Optional sliceProfileInstancesOptional = + injectionHelper.getAaiClient().get(org.onap.aai.domain.yang.ServiceInstance.class, uriSI); + + if (sliceProfileInstancesOptional.isPresent()) { + nssiName = sliceProfileInstancesOptional.get().getServiceInstanceName(); + } + } catch (Exception e) { + LOGGER.error("Error in getting Nssi Instance" + e.getMessage()); + } + return nssiName; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PayloadConstants.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PayloadConstants.java index 019e336325..60e34e0834 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PayloadConstants.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PayloadConstants.java @@ -33,6 +33,7 @@ public final class PayloadConstants { public static final String REQUEST = "request"; public static final String PROPERTIES = "properties"; public static final String SCOPE = "scope"; + public static final String NSSI_SCOPE = "nssi"; public static final String ACTION = "action"; public static final String MODE = "mode"; public static final String SEPARATOR = "-"; diff --git a/bpmn/mso-infrastructure-bpmn/pom.xml b/bpmn/mso-infrastructure-bpmn/pom.xml index aae59fb751..0ec7f46c81 100644 --- a/bpmn/mso-infrastructure-bpmn/pom.xml +++ b/bpmn/mso-infrastructure-bpmn/pom.xml @@ -260,6 +260,11 @@ so-bpmn-infrastructure-flows ${project.version} + + org.onap.so + so-bpmn-moi + ${project.version} + com.h2database h2 diff --git a/bpmn/pom.xml b/bpmn/pom.xml index b9eb7a9e7b..b5b34778a6 100644 --- a/bpmn/pom.xml +++ b/bpmn/pom.xml @@ -30,6 +30,7 @@ so-bpmn-building-blocks so-bpmn-infrastructure-flows mso-infrastructure-bpmn + so-bpmn-moi diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn index fd650b9d50..9628b6f936 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_0rq4c5r @@ -18,7 +18,7 @@ SequenceFlow_01h9qmz - + SequenceFlow_0rq4c5r SequenceFlow_0uzwjrq @@ -29,7 +29,8 @@ - SequenceFlow_0uzwjrq + Flow_17e9fnw + Flow_1x0zdf6 SequenceFlow_0je0y25 @@ -155,6 +156,41 @@ SequenceFlow_01h9qmz SequenceFlow_12a4hhf + + SequenceFlow_0uzwjrq + Flow_17e9fnw + Flow_0o7fpuq + + + + + + + + + + + + + + + + + + + + + + + + + Flow_0o7fpuq + Flow_1x0zdf6 + + + ${execution.getVariable("homing")} + + @@ -165,285 +201,310 @@ - - - - - - - - - - + + - + - - - - - - + + + + + + - + - - - - + + + + + + - + - - - - + + + + + + + + + + + + - + - - - - + + + - + - - - - + + + - + - - - - + + + + + + - + - - - - + + + - + - - - + + + - + - - - - - + + - - + + - + - - + + - - + + + + + + + + - + - - - - - - + + + - + - - - + + + - + - - - + + + - + - - - - - + + + - + - - - - - + + + - + - - - + + + - + - - - + + + - + - - + + - - - + + + - + - - - + + + - + - - - + + + + + - + - - - + + + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - + + - - + + + + + + + + + + + + + + + + + + - + - - - + + + + - + - - - + + + + - + - - - - - - + + + + - + - - - + + + + - + - - - + + + + - + - - - - - - + + + + + + - + - - - - - - - - - - - - + + + + - + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ExecuteBuildingBlockTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ExecuteBuildingBlockTest.java index aec118b7fb..c2363b78c5 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ExecuteBuildingBlockTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ExecuteBuildingBlockTest.java @@ -47,6 +47,7 @@ public class ExecuteBuildingBlockTest extends BaseBPMNTest { variables.put("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.CONTINUE); variables.put("flowToBeCalled", "MockFlow"); + variables.put("homing", false); mockSubprocess("MockFlow", "My Mock Process Name", "GenericStub"); @@ -64,6 +65,7 @@ public class ExecuteBuildingBlockTest extends BaseBPMNTest { @Test public void test_sunnyDayExecuteBuildingBlock_silentSuccess() throws Exception { variables.put("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS); + variables.put("homing", false); ProcessInstance pi = runtimeService.startProcessInstanceByKey("ExecuteBuildingBlock", variables); assertThat(pi).isNotNull(); @@ -79,6 +81,7 @@ public class ExecuteBuildingBlockTest extends BaseBPMNTest { public void test_rainyDayExecuteBuildingBlock_rollbackOrAbort() throws Exception { doThrow(new BpmnError("7000", "TESTING ERRORS")).when(bbInputSetup).execute(any(DelegateExecution.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("ExecuteBuildingBlock", variables); + variables.put("homing", false); assertThat(pi).isNotNull(); assertThat(pi).isStarted() .hasPassedInOrder("Start_ExecuteBuildingBlock", "Task_BBInputSetup", "StartEvent_0tmcs9g", @@ -96,6 +99,7 @@ public class ExecuteBuildingBlockTest extends BaseBPMNTest { variables.put("handlingCode", "Retry"); variables.put("RetryCount", 5); + variables.put("homing", false); ProcessInstance pi = runtimeService.startProcessInstanceByKey("ExecuteBuildingBlock", variables); assertThat(pi).isNotNull(); @@ -116,6 +120,7 @@ public class ExecuteBuildingBlockTest extends BaseBPMNTest { variables.put("handlingCode", "Retry"); variables.put("RetryCount", 4); variables.put("RetryDuration", "PT1S"); + variables.put("homing", false); ProcessInstance pi = runtimeService.startProcessInstanceByKey("ExecuteBuildingBlock", variables); assertThat(pi).isNotNull(); diff --git a/bpmn/so-bpmn-moi/pom.xml b/bpmn/so-bpmn-moi/pom.xml new file mode 100644 index 0000000000..d2153fa623 --- /dev/null +++ b/bpmn/so-bpmn-moi/pom.xml @@ -0,0 +1,173 @@ + + + + bpmn + org.onap.so + 1.12.2-SNAPSHOT + + 4.0.0 + org.onap.so + so-bpmn-moi + SO BPMN MOI + jar + + + 11 + 11 + + + + + org.camunda.bpm.springboot + camunda-bpm-spring-boot-starter + test + + + org.springframework.cloud + spring-cloud-contract-wiremock + test + + + org.springframework.boot + spring-boot-starter-test + test + + + org.camunda.bpm.extension.mockito + camunda-bpm-mockito + test + + + org.camunda.connect + camunda-connect-connectors-all + + + commons-beanutils + commons-beanutils + + + + com.h2database + h2 + test + + + org.codehaus.groovy + groovy-xml + + + org.codehaus.groovy + groovy-json + + + org.codehaus.groovy + groovy-jsr223 + + + org.codehaus.groovy + groovy-test + test + + + org.onap.so + MSOCoreBPMN + ${project.version} + + + org.onap.so + mso-catalog-db + ${project.version} + + + org.onap.so + mso-requests-db + ${project.version} + + + org.onap.so.adapters + mso-adapters-rest-interface + ${project.version} + + + commons-lang + commons-lang + 2.6 + + + org.onap.appc.client + client-lib + ${appc.client.version} + + + org.mockito + mockito-core + + + org.powermock + powermock-module-junit4 + + + org.powermock + powermock-api-mockito + + + + + org.onap.appc.client + client-kit + ${appc.client.version} + + + org.mockito + mockito-core + + + + + org.glassfish.jersey.core + jersey-client + + + org.glassfish.jersey.inject + jersey-hk2 + 2.26 + + + org.glassfish.jersey.media + jersey-media-json-jackson + + + org.springframework.boot + spring-boot-starter-test + test + + + uk.co.blackpepper.bowman + bowman-client + ${bowman.client.version} + + + pl.pragmatists + JUnitParams + test + + + ch.vorburger.mariaDB4j + mariaDB4j + test + + + org.assertj + assertj-core + 3.11.1 + test + + + org.onap.so + MSOCommonBPMN + ${project.version} + compile + + + diff --git a/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/AssignRANNssiBBTasks.java b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/AssignRANNssiBBTasks.java new file mode 100644 index 0000000000..1ef073ca68 --- /dev/null +++ b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/AssignRANNssiBBTasks.java @@ -0,0 +1,335 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2022 Deutsche telekom + * ================================================================================ + * 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.moi.tasks; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.aai.domain.yang.*; +import org.onap.aaiclient.client.aai.AAIRestClientImpl; +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.BuildingBlockExecution; +import org.onap.so.bpmn.common.InjectionHelper; +import org.onap.so.bpmn.moi.util.AAISliceProfileUtil; +import org.onap.so.bpmn.moi.util.SliceProfileAaiToMoiMapperUtil; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; +import org.onap.so.moi.Attributes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.util.*; +import java.util.stream.Collectors; + +@Component +public class AssignRANNssiBBTasks { + + private static final Logger LOGGER = LoggerFactory.getLogger(AssignRANNssiBBTasks.class); + + @Autowired + private InjectionHelper injectionHelper; + + private ObjectMapper mapper = new ObjectMapper(); + + private AAIRestClientImpl aaiRestClient = new AAIRestClientImpl(); + + @Autowired + AAISliceProfileUtil aaiSliceProfileUtil; + + @Autowired + private SliceProfileAaiToMoiMapperUtil mapperUtil; + + public void createNssi(BuildingBlockExecution execution) throws Exception { + + + GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock(); + + String serviceInstanceId = gBB.getServiceInstance().getServiceInstanceId(); + + ModelInfoServiceInstance modelInfoServiceInstance = gBB.getServiceInstance().getModelInfoServiceInstance(); + + // for NON-SHARED check if its Already present + if (checkNSSI(execution)) { + if (aaiSliceProfileUtil.getServiceInstance(execution).isPresent()) { + throw new RuntimeException("Invalid NSSI, Slice subnet already exists"); + } + } + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId(serviceInstanceId); + serviceInstance.setServiceInstanceName("ran_" + serviceInstanceId); + serviceInstance.setOrchestrationStatus("Assigned"); + serviceInstance.setServiceType("nssi"); + serviceInstance.setModelInvariantId(modelInfoServiceInstance.getModelInvariantUuid()); + serviceInstance.setModelVersionId(modelInfoServiceInstance.getModelUuid()); + serviceInstance.setOperationalStatus("LOCKED"); + + Customer customer = getCustomer(execution); + + AAIResourceUri serviceInstanceURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId()) + .serviceSubscription( + customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType()) + .serviceInstance(serviceInstance.getServiceInstanceId())); + + injectionHelper.getAaiClient().createIfNotExists(serviceInstanceURI, Optional.of(serviceInstance)); + + } + + private boolean checkNSSI(BuildingBlockExecution execution) { + + Optional serviceInstance = aaiSliceProfileUtil.getServiceInstance(execution); + + + GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock(); + + String serviceInstanceId = gBB.getServiceInstance().getServiceInstanceId(); + + List> mapUserParams = gBB.getRequestContext().getRequestParameters().getUserParams(); + + + Attributes attributes = null; + + for (Map userParamData : mapUserParams) { + if (userParamData.get("nssi") != null) { + Map mapParam = (Map) userParamData.get("nssi"); + attributes = mapper.convertValue(mapParam, Attributes.class); + } + } + if (attributes.getSliceProfileList().get(0).getRANSliceSubnetProfile().getResourceSharingLevel() + .equalsIgnoreCase("NON-SHARED")) + return true; + else + return false; + } + + + public void createSliceProfileInstance(BuildingBlockExecution execution) { + GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock(); + + String serviceInstanceId = gBB.getServiceInstance().getServiceInstanceId(); + + Customer customer = getCustomer(execution); + + List> mapUserParams = gBB.getRequestContext().getRequestParameters().getUserParams(); + + + Attributes attributes = null; + + for (Map userParamData : mapUserParams) { + if (userParamData.get("nssi") != null) { + Map mapParam = (Map) userParamData.get("nssi"); + attributes = mapper.convertValue(mapParam, Attributes.class); + } + } + // Create SliceProfile Instance + ServiceInstance sliceProfileServiceInstance = new ServiceInstance(); + String sliceProfileInstanceId = UUID.randomUUID().toString(); + sliceProfileServiceInstance.setServiceInstanceId(sliceProfileInstanceId); + sliceProfileServiceInstance.setServiceInstanceName("slice-profile-" + serviceInstanceId); + sliceProfileServiceInstance.setServiceRole("slice-profile"); + + sliceProfileServiceInstance = + mapperUtil.fillSliceProfileInstanceFromMoiRequest(attributes, sliceProfileServiceInstance); + + AAIResourceUri serviceInstanceURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId()) + .serviceSubscription( + customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType()) + .serviceInstance(sliceProfileServiceInstance.getServiceInstanceId())); + + injectionHelper.getAaiClient().createIfNotExists(serviceInstanceURI, Optional.of(sliceProfileServiceInstance)); + + List> sliceProfilesData = gBB.getRequestContext().getRequestParameters().getUserParams(); + + // sliceProfile + SliceProfile sliceProfile = mapperUtil.extractAaiSliceProfileFromMoiRequest(attributes); + String sliceProfileId = UUID.randomUUID().toString(); + sliceProfile.setProfileId(sliceProfileId); + + AAIResourceUri sliceProfileURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId()) + .serviceSubscription( + customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType()) + .serviceInstance(sliceProfileInstanceId).sliceProfile(sliceProfile.getProfileId())); + + injectionHelper.getAaiClient().createIfNotExists(sliceProfileURI, Optional.of(sliceProfile)); + + execution.setVariable("sliceProfileServiceInstanceId", sliceProfileServiceInstance.getServiceInstanceId()); + } + + public void allotResources(BuildingBlockExecution execution) { + + GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock(); + + String sliceProfileServiceInstanceId = execution.getVariable("sliceProfileServiceInstanceId"); + + LOGGER.debug("sliceProfileServiceInstanceId: {}", sliceProfileServiceInstanceId); + + Customer customer = getCustomer(execution); + + org.onap.aai.domain.yang.v23.AllottedResource allottedResource = + new org.onap.aai.domain.yang.v23.AllottedResource(); + + UUID allottedResourceUuid = UUID.randomUUID(); + allottedResource.setId(allottedResourceUuid.toString()); + + AAIResourceUri allotedResourceURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId()) + .serviceSubscription( + customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType()) + .serviceInstance(sliceProfileServiceInstanceId).allottedResource(allottedResource.getId())); + + injectionHelper.getAaiClient().createIfNotExists(allotedResourceURI, Optional.of(allottedResource)); + + execution.setVariable("allottedResourceUuid", allottedResource.getId()); + + } + + + public void addSliceProfileToNssi(BuildingBlockExecution execution) { + LOGGER.info("Entering into addSliceProfileToNssi"); + + String sliceProfileServiceInstanceId = execution.getVariable("sliceProfileServiceInstanceId"); + String allottedResourceUuid = execution.getVariable("allottedResourceUuid"); + GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock(); + String serviceInstanceId = gBB.getServiceInstance().getServiceInstanceId(); + + Customer customer = getCustomer(execution); + + + AAIResourceUri nssiUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId()) + .serviceSubscription( + customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType()) + .serviceInstance(serviceInstanceId)); + + AAIResourceUri allotedResourceURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId()) + .serviceSubscription( + customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType()) + .serviceInstance(sliceProfileServiceInstanceId).allottedResource(allottedResourceUuid)); + + try { + injectionHelper.getAaiClient().connect(allotedResourceURI, nssiUri); + } catch (Exception e) { + LOGGER.error(">>>>> Error in creating Relationship: {} ", e); + } + } + + public void activateNssi(BuildingBlockExecution execution) { + GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock(); + String serviceInstanceId = gBB.getServiceInstance().getServiceInstanceId(); + + Customer customer = getCustomer(execution); + + AAIResourceUri serviceInstanceURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId()) + .serviceSubscription( + customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType()) + .serviceInstance(serviceInstanceId)); + + Optional serviceInstanceReturned = + injectionHelper.getAaiClient().get(ServiceInstance.class, serviceInstanceURI); + + ServiceInstance serviceInstance = null; + if (serviceInstanceReturned.isPresent()) { + serviceInstance = serviceInstanceReturned.get(); + serviceInstance.setOperationalStatus("UNLOCKED"); + serviceInstance.setOrchestrationStatus("Active"); + + try { + injectionHelper.getAaiClient().update(serviceInstanceURI, serviceInstance); + } catch (Exception e) { + LOGGER.error("Nssi couldnot be activated: {}", e); + } + } else { + LOGGER.debug("Service Instance not present with Id: {}", serviceInstanceId); + } + + // SliceProfile + List sliceProfileList = new ArrayList(); + ServiceInstance serviceInstanceObj; + List listOfNssiRelationship = serviceInstance.getRelationshipList().getRelationship(); + + List listOfNssiRelationshipAR = listOfNssiRelationship.stream() + .filter(relationship -> relationship.getRelatedTo().equalsIgnoreCase("allotted-resource")) + .collect(Collectors.toList()); + + for (Relationship relationship : listOfNssiRelationshipAR) { + org.onap.so.moi.SliceProfile sliceProfile = new org.onap.so.moi.SliceProfile(); + for (RelationshipData relationshipData : relationship.getRelationshipData()) { + if (relationshipData.getRelationshipKey().equalsIgnoreCase("service-instance.service-instance-id")) { + String sliceProfileInstanceId = relationshipData.getRelationshipValue(); + + Optional sliceProfileServiceInstance = + aaiRestClient.getServiceInstanceById(sliceProfileInstanceId, "5G", "5GCustomer"); + if (sliceProfileServiceInstance.isPresent()) { + ServiceInstance sliceProflieInstance = sliceProfileServiceInstance.get(); + sliceProflieInstance.setOperationalStatus("UNLOCKED"); + sliceProflieInstance.setOrchestrationStatus("ACTIVE"); + + AAIResourceUri sliceProfileInstanceURI = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId()) + .serviceSubscription(customer.getServiceSubscriptions().getServiceSubscription() + .get(0).getServiceType()) + .serviceInstance(sliceProflieInstance.getServiceInstanceId())); + try { + injectionHelper.getAaiClient().update(sliceProfileInstanceURI, sliceProflieInstance); + } catch (Exception e) { + LOGGER.error("SliceProfile couldnot be activated: {}", e); + } + } else { + LOGGER.debug("Slice Profile Instance not present with Id: {}", serviceInstanceId); + } + + + } + } + + } + } + + + private Customer getCustomer(BuildingBlockExecution execution) { + + GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock(); + + String serviceType = gBB.getCustomer().getServiceSubscription().getServiceType(); + + String globalCustomerId = gBB.getCustomer().getGlobalCustomerId(); + + ServiceSubscription serviceSubscription = new ServiceSubscription(); + serviceSubscription.setServiceType(serviceType); + + ServiceSubscriptions serviceSubscriptions = new ServiceSubscriptions(); + serviceSubscriptions.getServiceSubscription().add(serviceSubscription); + + Customer customer = new Customer(); + customer.setGlobalCustomerId(globalCustomerId); + customer.setServiceSubscriptions(serviceSubscriptions); + + return customer; + + } + +} diff --git a/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/DeleteRANNssiBBTask.java b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/DeleteRANNssiBBTask.java new file mode 100644 index 0000000000..f464ed23f3 --- /dev/null +++ b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/DeleteRANNssiBBTask.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2022 Deutsche telekom + * ================================================================================ + * 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.moi.tasks; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.aaiclient.client.aai.AAIRestClientImpl; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.InjectionHelper; +import org.onap.so.bpmn.moi.util.AAISliceProfileUtil; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + + +@Component +public class DeleteRANNssiBBTask { + private static final Logger LOGGER = LoggerFactory.getLogger(DeleteRANNssiBBTask.class); + + @Autowired + private InjectionHelper injectionHelper; + + @Autowired + AAISliceProfileUtil aaiSliceProfileUtil; + + private AAIRestClientImpl aaiRestClient = new AAIRestClientImpl(); + + private static final ObjectMapper mapper = new ObjectMapper(); + + + public void deleteNssi(BuildingBlockExecution execution) throws JsonProcessingException { + GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock(); + List> sliceProfilesData = gBB.getRequestContext().getRequestParameters().getUserParams(); + String sliceProfileIdFromRequest = mapUserParamsToSliceProfile(sliceProfilesData); + aaiSliceProfileUtil.deleteSliceProfile(execution, sliceProfileIdFromRequest); + } + + + + private String mapUserParamsToSliceProfile(List> sliceProfilesData) + throws JsonProcessingException { + Map mapParam = (Map) sliceProfilesData.get(0).get("nssi"); + List list = (ArrayList) mapParam.get("sliceProfileList"); + Map idMap = (Map) list.get(0); + String sliceProfileId = (String) idMap.get("sliceProfileId"); + return sliceProfileId; + } + +} diff --git a/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/EnrichGBBTask.java b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/EnrichGBBTask.java new file mode 100644 index 0000000000..4247b242bf --- /dev/null +++ b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/EnrichGBBTask.java @@ -0,0 +1,208 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2022 Deutsche telekom + * ================================================================================ + * 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.moi.tasks; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.bpmn.common.InjectExecution; +import org.onap.so.bpmn.common.scripts.ExceptionUtil; +import org.onap.so.bpmn.common.scripts.OofUtils; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.moi.Attributes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Component +public class EnrichGBBTask { + + private static final String EXECUTE_BB_VAR_NAME = "buildingBlock"; + private static final String GBB_INPUT_VAR_NAME = "gBBInput"; + + ExceptionUtil exceptionUtil = new ExceptionUtil(); + JsonUtils jsonUtil = new JsonUtils(); + + @Autowired + CatalogDbClient catalogDbClient; + + InjectExecution injectExecution = new InjectExecution(); + + + private static final Logger LOGGER = LoggerFactory.getLogger(EnrichGBBTask.class); + private static final ObjectMapper mapper = new ObjectMapper(); + OofUtils oofUtils = new OofUtils(null); + + public void prepareOofRequest(DelegateExecution execution) throws Exception { + + String msoReqId = (String) execution.getVariable("mso-request-id"); + + + BuildingBlockExecution gBuildingBlockExecution = + (BuildingBlockExecution) execution.getVariable("gBuildingBlockExecution"); + + DelegateExecutionImpl gbbEx = injectExecution.execute(execution, + (DelegateExecutionImpl) execution.getVariable("gBuildingBlockExecution")); + + + GeneralBuildingBlock generalBuildingBlock = (GeneralBuildingBlock) execution.getVariable("gBBInput"); + + List> mapUserParams = + generalBuildingBlock.getRequestContext().getRequestParameters().getUserParams(); + + Attributes attributes = null; + + for (Map userParamData : mapUserParams) { + if (userParamData.get("nssi") != null) { + Map mapParam = (Map) userParamData.get("nssi"); + LOGGER.info(">>> mapParam: {}", mapParam); + attributes = mapper.convertValue(mapParam, Attributes.class); + } + } + // Attributes attributes = new ObjectMapper().convertValue(attrMap, Attributes.class); + Integer latency = attributes.getSliceProfileList().get(0).getRANSliceSubnetProfile().getLatency(); + Integer areaTrafficCapDL = + attributes.getSliceProfileList().get(0).getRANSliceSubnetProfile().getAreaTrafficCapDL(); + + + String requestId = generalBuildingBlock.getRequestContext().getMsoRequestId(); + + // API Path + String apiPath = "/api/oof/v1/selection/nsst"; + LOGGER.debug("API path for NSST Selection: " + apiPath); + execution.setVariable("NSST_apiPath", apiPath); + + // Setting correlator as requestId + execution.setVariable("NSST_correlator", requestId); + + // Setting messageType for all Core slice as an + String messageType = "an"; + execution.setVariable("NSST_messageType", messageType); + + String timeout = "PT30M"; + execution.setVariable("NSST_timeout", timeout); + + Map profileInfo = new HashMap<>(); + profileInfo.put("latency", latency); + profileInfo.put("areaTrafficCapDL", areaTrafficCapDL); + + String oofRequest = oofUtils.buildSelectNSTRequest(requestId, messageType, profileInfo); + LOGGER.debug("**** OOfRequest for NSST Selection: " + oofRequest); + execution.setVariable("NSST_oofRequest", oofRequest); + } + + + public void processOOFAsyncResponse(DelegateExecution execution) { + GeneralBuildingBlock generalBuildingBlock = (GeneralBuildingBlock) execution.getVariable("gBBInput"); + + LOGGER.debug(">>>> generalBuildingBlock Initial: {}", generalBuildingBlock); + + LOGGER.debug(" **** Enter EnrichGBB ::: processOOFAsyncResponse ****"); + String OOFResponse = (String) execution.getVariable("NSST_asyncCallbackResponse"); + String requestStatus = jsonUtil.getJsonValue(OOFResponse, "requestStatus"); + LOGGER.debug("NSST OOFResponse is: " + OOFResponse); + execution.setVariable("OOFResponse", OOFResponse); + String solutions = ""; + if (requestStatus.equals("completed")) { + List solutionsList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(OOFResponse, "solutions")); + if (solutionsList != null && !solutionsList.isEmpty()) { + solutions = (String) solutionsList.get(0); + } + } else { + String statusMessage = jsonUtil.getJsonValue(OOFResponse, "statusMessage"); + LOGGER.error("received failed status from oof " + statusMessage); + LOGGER.debug("received failed status from oof " + statusMessage); + } + + LOGGER.debug(">>>>>> solutions: {}", solutions); + + String nsstId = jsonUtil.getJsonValue(solutions, "UUID"); + LOGGER.info(">>> nsstId:{} ", nsstId); + + Service service = catalogDbClient.getServiceByModelUUID(nsstId); + + LOGGER.info("Service from CatalogDB: {}", service); + + LOGGER.debug(">>> Map Incoming Values to GBB"); + + ServiceInstance serviceInstance = generalBuildingBlock.getServiceInstance(); + + ModelInfoServiceInstance modelInfoServiceInstanceFromGBB = serviceInstance.getModelInfoServiceInstance(); + + if (modelInfoServiceInstanceFromGBB == null) { + String modelInvariantId = service.getModelInvariantUUID(); + String modelVersion = service.getModelVersion(); + String serviceType = service.getServiceType(); + String serviceRole = service.getServiceRole(); + String controllerActor = service.getControllerActor(); + String blueprintName = service.getBlueprintName(); + String blueprintVersion = service.getBlueprintVersion(); + + ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); + modelInfoServiceInstance.setModelUuid("ad2233a2-6e3f-42cf-8c60-04e614031383"); + modelInfoServiceInstance.setModelInvariantUuid("38730fb9-bfbb-4a78-88f8-b4f6823197b6"); + modelInfoServiceInstance.setModelVersion("1.0"); + modelInfoServiceInstance.setServiceRole("AN"); + modelInfoServiceInstance.setServiceType("eMBB"); + modelInfoServiceInstance.setBlueprintVersion("1.0.0"); + modelInfoServiceInstance.setControllerActor("CDS"); + modelInfoServiceInstance.setBlueprintName("Hello_World_CBA"); + modelInfoServiceInstance.setServiceType(serviceType); + modelInfoServiceInstance.setServiceRole(serviceRole); + modelInfoServiceInstance.setControllerActor(controllerActor); + modelInfoServiceInstance.setBlueprintName(blueprintName); + modelInfoServiceInstance.setBlueprintVersion(blueprintVersion); + modelInfoServiceInstance.setModelInvariantUuid(modelInvariantId); + modelInfoServiceInstance.setModelUuid(nsstId); + modelInfoServiceInstance.setModelVersion(modelVersion); + + serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); + + serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); + + + } + + LOGGER.info(">>> ServiceInstance: {}", serviceInstance); + + generalBuildingBlock.setServiceInstance(serviceInstance); + + LOGGER.debug("generalBuildingBlock: {}", generalBuildingBlock); + + execution.setVariable(GBB_INPUT_VAR_NAME, generalBuildingBlock); + BuildingBlockExecution gBuildingBlockExecution1 = new DelegateExecutionImpl(execution); + execution.setVariable("gBuildingBlockExecution", gBuildingBlockExecution1); + + // execution.setVariable("gBuildingBlockExecution", gBBExecution); + LOGGER.debug(" **** Exit EnrichBB ::: processOOFAsyncResponse ****"); + } +} diff --git a/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/ModifyRANNssiBBTask.java b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/ModifyRANNssiBBTask.java new file mode 100644 index 0000000000..eba35673e1 --- /dev/null +++ b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/ModifyRANNssiBBTask.java @@ -0,0 +1,186 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2022 Deutsche telekom + * ================================================================================ + * 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.moi.tasks; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aai.domain.yang.SliceProfile; +import org.onap.aaiclient.client.aai.AAIRestClientImpl; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.InjectionHelper; +import org.onap.so.bpmn.moi.util.AAISliceProfileUtil; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.moi.PlmnInfo; +import org.onap.so.moi.RANSliceSubnetProfile; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; + + +@Component +public class ModifyRANNssiBBTask { + private static final Logger LOGGER = LoggerFactory.getLogger(ModifyRANNssiBBTask.class); + + @Autowired + private InjectionHelper injectionHelper; + + @Autowired + private AAISliceProfileUtil aaiSliceProfileUtil; + + private AAIRestClientImpl aaiRestClient = new AAIRestClientImpl(); + + private static final ObjectMapper mapper = new ObjectMapper(); + + + public void modifyNssi(BuildingBlockExecution execution) throws JsonProcessingException { + LOGGER.info("Modify NSSI"); + GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock(); + + String serviceInstanceId = gBB.getServiceInstance().getServiceInstanceId(); + List> sliceProfilesData = gBB.getRequestContext().getRequestParameters().getUserParams(); + + SliceProfile updatedSliceProfile = mapUserParamsToSliceProfile(sliceProfilesData); + String sliceProfileIdFromRequest = getSliceProfileIdFromReq(sliceProfilesData); + aaiSliceProfileUtil.updateSliceProfile(execution, sliceProfileIdFromRequest, updatedSliceProfile); + + + + } + + private ServiceInstance mapUserParamsToServiceInstance(ServiceInstance sliceProfileServiceInstanceObj, + List> sliceProfilesData) { + Map mapParam = (Map) sliceProfilesData.get(0).get("nssi"); + LOGGER.info(">>> mapParam: {}", mapParam); + + // update administrative State + String administrativeState = (String) mapParam.get("administrativeState"); + LOGGER.info(">>> administrativeState: {}", administrativeState); + sliceProfileServiceInstanceObj.setOperationalStatus(administrativeState); + + List list = (ArrayList) mapParam.get("sliceProfileList"); + LOGGER.info(">>> sliceProfile List: {}", list); + Map idMap = (Map) list.get(0); + LOGGER.info("Keys of Id Map {} ", idMap.keySet()); + + // PlmnInfoList + for (String key : idMap.keySet()) { + if (key.equalsIgnoreCase("plmnInfoList")) { + PlmnInfo plmnInfo = mapper.convertValue(mapParam, PlmnInfo.class); + LOGGER.info("PlmnInfo {}", plmnInfo.getPlmnId().getMcc() + "-" + plmnInfo.getPlmnId().getMnc()); + LOGGER.info("Snssai {} ", plmnInfo.getSnssai().getSst() + "-" + plmnInfo.getSnssai().getSd()); + sliceProfileServiceInstanceObj.setServiceInstanceLocationId( + plmnInfo.getPlmnId().getMcc() + "-" + plmnInfo.getPlmnId().getMnc()); + sliceProfileServiceInstanceObj + .setEnvironmentContext(plmnInfo.getSnssai().getSst() + "-" + plmnInfo.getSnssai().getSd()); + } + } + return sliceProfileServiceInstanceObj; + } + + SliceProfile mapUserParamsToSliceProfile(List> sliceProfilesData) + throws JsonProcessingException { + SliceProfile sliceProfile = new SliceProfile(); + Map mapParam = (Map) sliceProfilesData.get(0).get("nssi"); + LOGGER.info(">>> mapParam in map: {}", mapParam); + + List list = (ArrayList) mapParam.get("sliceProfileList"); + + Map idMap = (Map) list.get(0); + + String sliceProfileId = (String) idMap.get("sliceProfileId"); + + sliceProfile.setProfileId(sliceProfileId); + RANSliceSubnetProfile ranSliceSubnetProfile = mapper.convertValue(mapParam, RANSliceSubnetProfile.class); + + + for (String key : idMap.keySet()) { + if (key.equalsIgnoreCase("RANSliceSubnetProfile")) { + RANSliceSubnetProfile RANSliceSubnetProfile = + mapper.convertValue(mapParam, RANSliceSubnetProfile.class); + LOGGER.info("RANSliceSubnetProfile inside {}", RANSliceSubnetProfile); + Map ranMap = (Map) idMap.get(key); + ranMap.forEach((k, v) -> { + LOGGER.info("Key : {}", k); + switch (k) { + case "coverageAreaTAList": + Integer coverageAreaTAList = (Integer) ranMap.get(k); + LOGGER.info("coverageAreaTAList {}", coverageAreaTAList); + sliceProfile.setCoverageAreaTAList(coverageAreaTAList.toString()); + break; + + case "latency": + Integer latency = (Integer) ranMap.get(k); + LOGGER.info("latency {}", latency); + sliceProfile.setLatency(latency); + break; + + case "dLLatency": + Integer dLLatency = (Integer) ranMap.get(k); + LOGGER.info("dLLatency {}", dLLatency); + sliceProfile.setLatency(dLLatency); + break; + + case "areaTrafficCapDL": + Integer areaTrafficCapDL = (Integer) ranMap.get(k); + LOGGER.info("areaTrafficCapDL {}", areaTrafficCapDL); + sliceProfile.setAreaTrafficCapDL(areaTrafficCapDL); + break; + + case "resourceSharingLevel": + String resourceSharingLevel = (String) ranMap.get(k); + LOGGER.info("resourceSharingLevel {}", resourceSharingLevel); + sliceProfile.setResourceSharingLevel(resourceSharingLevel); + break; + + case "maxNumberofUEs": + Integer maxNumberofUEs = (Integer) ranMap.get(k); + LOGGER.info("maxNumberofUEs {}", maxNumberofUEs); + sliceProfile.setMaxNumberOfUEs(maxNumberofUEs); + break; + + } + }); + } + } + return sliceProfile; + } + + private String getSliceProfileIdFromReq(List> sliceProfilesData) + throws JsonProcessingException { + Map mapParam = (Map) sliceProfilesData.get(0).get("nssi"); + + List list = (ArrayList) mapParam.get("sliceProfileList"); + + Map idMap = (Map) list.get(0); + String sliceProfileId = (String) idMap.get("sliceProfileId"); + + return sliceProfileId; + } + + +} diff --git a/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/util/AAISliceProfileUtil.java b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/util/AAISliceProfileUtil.java new file mode 100644 index 0000000000..a23fec8cc7 --- /dev/null +++ b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/util/AAISliceProfileUtil.java @@ -0,0 +1,279 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2022 Deutsche telekom + * ================================================================================ + * 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.moi.util; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.aai.domain.yang.*; +import org.onap.aaiclient.client.aai.AAIRestClientImpl; +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.BuildingBlockExecution; +import org.onap.so.bpmn.common.InjectionHelper; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + +@Component +public class AAISliceProfileUtil { + + private static final Logger LOGGER = LoggerFactory.getLogger(AAISliceProfileUtil.class); + + private static final ObjectMapper mapper = new ObjectMapper(); + + @Autowired + private InjectionHelper injectionHelper; + + private AAIRestClientImpl aaiRestClient = new AAIRestClientImpl(); + + + public Optional getServiceInstance(BuildingBlockExecution execution) { + GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock(); + String serviceInstanceId = gBB.getServiceInstance().getServiceInstanceId(); + Customer customer = getCustomer(execution); + + AAIResourceUri serviceInstanceURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId()) + .serviceSubscription( + customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType()) + .serviceInstance(serviceInstanceId)); + return injectionHelper.getAaiClient().get(ServiceInstance.class, serviceInstanceURI); + } + + public void deleteSliceProfile(BuildingBlockExecution execution, String profileId) { + Optional getServiceInstance = getServiceInstance(execution); + if (getServiceInstance.isPresent()) { + ServiceInstance serviceInstance = getServiceInstance.get(); + String NssiId = serviceInstance.getServiceInstanceId(); + LOGGER.info("NSSID {}", NssiId); + List listOfNssiRelationship = serviceInstance.getRelationshipList().getRelationship(); + + List listOfNssiRelationshipAR = listOfNssiRelationship.stream() + .filter(relationship -> relationship.getRelatedTo().equalsIgnoreCase("allotted-resource")) + .collect(Collectors.toList()); + int size = listOfNssiRelationshipAR.size(); + + List sliceProfileList; + LOGGER.info("ProfileID from Request: {}", profileId); + boolean isDeleted = false; + for (Relationship relationship : listOfNssiRelationshipAR) { + for (RelationshipData relationshipData : relationship.getRelationshipData()) { + if (relationshipData.getRelationshipKey() + .equalsIgnoreCase("service-instance.service-instance-id")) { + String sliceProfileInstanceId = relationshipData.getRelationshipValue(); + LOGGER.debug(">>> sliceProfileInstance: {}", sliceProfileInstanceId); + Optional sliceProfile1 = aaiRestClient + .getServiceInstanceByIdWithDepth(sliceProfileInstanceId, "5G", "5GCustomer"); + if (sliceProfile1.isPresent()) { + sliceProfileList = sliceProfile1.get().getSliceProfiles().getSliceProfile(); + LOGGER.info("sliceProfileList {}", sliceProfileList); + for (SliceProfile slice : sliceProfileList) { + if (slice.getProfileId().equalsIgnoreCase(profileId)) { + LOGGER.info("ProfileID matched Deleting slice profile"); + deleteSliceProfileFromAAI(sliceProfileInstanceId, size, execution, NssiId); + isDeleted = true; + break; + } + } + } + } + if (isDeleted) + break; + } + if (isDeleted) + break; + } + } + } + + public void updateSliceProfile(BuildingBlockExecution execution, String profileId, SliceProfile updatedSlice) { + GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock(); + List> sliceProfilesData = gBB.getRequestContext().getRequestParameters().getUserParams(); + LOGGER.info(">>> mapParam: {}", sliceProfilesData); + + Optional getServiceInstance = getServiceInstance(execution); + if (getServiceInstance.isPresent()) { + ServiceInstance serviceInstance = getServiceInstance.get(); + List listOfNssiRelationship = serviceInstance.getRelationshipList().getRelationship(); + + List listOfNssiRelationshipAR = listOfNssiRelationship.stream() + .filter(relationship -> relationship.getRelatedTo().equalsIgnoreCase("allotted-resource")) + .collect(Collectors.toList()); + + List sliceProfileList; + LOGGER.info("ProfileID : {}", profileId); + for (Relationship relationship : listOfNssiRelationshipAR) { + for (RelationshipData relationshipData : relationship.getRelationshipData()) { + if (relationshipData.getRelationshipKey() + .equalsIgnoreCase("service-instance.service-instance-id")) { + String sliceProfileInstanceId = relationshipData.getRelationshipValue(); + LOGGER.debug(">>> sliceProfileInstance: {}", sliceProfileInstanceId); + + Optional sliceProfile1 = aaiRestClient + .getServiceInstanceByIdWithDepth(sliceProfileInstanceId, "5G", "5GCustomer"); + + Optional sliceProfileInstanceNodepth = + aaiRestClient.getServiceInstanceById(sliceProfileInstanceId, "5G", "5GCustomer"); + + if (sliceProfile1.isPresent()) { + sliceProfileList = sliceProfile1.get().getSliceProfiles().getSliceProfile(); + int size = sliceProfileList.size(); + ServiceInstance updatedSliceInstance = sliceProfileInstanceNodepth.get(); + + for (SliceProfile slice : sliceProfileList) { + if (slice.getProfileId().equalsIgnoreCase(profileId)) { + LOGGER.info("Profile ID matched... updating slice profile"); + updateSliceProfileInAAI(execution, sliceProfileInstanceId, updatedSlice); + + // for update in administrativeState + updatedSliceInstance = + mapUserParamsToServiceInstance(updatedSliceInstance, sliceProfilesData); + LOGGER.info(("Updating Slice-profile Instance")); + updateSliceProfileInstance(execution, updatedSliceInstance); + } + + } + } + } + + } + } + } + } + + public void updateSliceProfileInAAI(BuildingBlockExecution execution, String sliceProfileInstanceId, + SliceProfile sliceProfile1) { + Customer customer = getCustomer(execution); + AAIResourceUri updateSliceURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId()) + .serviceSubscription( + customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType()) + .serviceInstance(sliceProfileInstanceId).sliceProfile(sliceProfile1.getProfileId())); + try { + injectionHelper.getAaiClient().update(updateSliceURI, sliceProfile1); + } catch (Exception e) { + LOGGER.info("Error in updating Slice Profile {}", e); + } + } + + public void updateSliceProfileInstance(BuildingBlockExecution execution, ServiceInstance sliceProfileinstance) { + Customer customer = getCustomer(execution); + AAIResourceUri updateSliceURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId()) + .serviceSubscription( + customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType()) + .serviceInstance(sliceProfileinstance.getServiceInstanceId())); + try { + injectionHelper.getAaiClient().update(updateSliceURI, sliceProfileinstance); + } catch (Exception e) { + LOGGER.info("Error in updating Slice Profile instance {}", e); + } + } + + public void deleteSliceProfileFromAAI(String serviceInstanceID, int size, BuildingBlockExecution execution, + String NssiId) { + Customer customer = getCustomer(execution); + + AAIResourceUri deleteInstanceURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId()) + .serviceSubscription( + customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType()) + .serviceInstance(serviceInstanceID)); + try { + injectionHelper.getAaiClient().delete(deleteInstanceURI); + LOGGER.info("Slice Profile Instance with ID {} deleted", serviceInstanceID); + } catch (Exception e) { + LOGGER.info("Error in deleting Slice Profile instace {}", e); + } + LOGGER.info(">>>> Size : {}", size); + if (size == 1) { + AAIResourceUri serviceInstanceURI = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId()) + .serviceSubscription( + customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType()) + .serviceInstance(NssiId)); + // Delete NSSI + try { + injectionHelper.getAaiClient().delete(serviceInstanceURI); + LOGGER.info("deleted Slice Prfile as well ass NSSI {}", NssiId); + } catch (Exception e) { + LOGGER.info("Error in deleting NSSI {}", e); + } + + } + + } + + private Customer getCustomer(BuildingBlockExecution execution) { + + GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock(); + + String serviceType = gBB.getCustomer().getServiceSubscription().getServiceType(); + + String globalCustomerId = gBB.getCustomer().getGlobalCustomerId(); + + ServiceSubscription serviceSubscription = new ServiceSubscription(); + serviceSubscription.setServiceType(serviceType); + + ServiceSubscriptions serviceSubscriptions = new ServiceSubscriptions(); + serviceSubscriptions.getServiceSubscription().add(serviceSubscription); + + Customer customer = new Customer(); + customer.setGlobalCustomerId(globalCustomerId); + customer.setServiceSubscriptions(serviceSubscriptions); + + return customer; + + } + + private ServiceInstance mapUserParamsToServiceInstance(ServiceInstance sliceProfileServiceInstanceObj, + List> sliceProfilesData) { + Map mapParam = (Map) sliceProfilesData.get(0).get("nssi"); + LOGGER.info(">>> mapParam: {}", mapParam); + + // update administrative State + String administrativeState = (String) mapParam.get("administrativeState"); + if (administrativeState != null) { + LOGGER.info(">>> administrativeState: {}", administrativeState); + sliceProfileServiceInstanceObj.setOperationalStatus(administrativeState); + } + + String operationalState = (String) mapParam.get("operationalState"); + if (operationalState != null) { + LOGGER.info(">>> operationalState: {}", operationalState); + sliceProfileServiceInstanceObj.setOrchestrationStatus(operationalState); + } + List list = (ArrayList) mapParam.get("sliceProfileList"); + LOGGER.info(">>> sliceProfile List: {}", list); + Map idMap = (Map) list.get(0); + LOGGER.info("Keys of Id Map {} ", idMap.keySet()); + + return sliceProfileServiceInstanceObj; + } +} diff --git a/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/util/SliceProfileAaiToMoiMapperUtil.java b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/util/SliceProfileAaiToMoiMapperUtil.java new file mode 100644 index 0000000000..1cbdabf9c4 --- /dev/null +++ b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/util/SliceProfileAaiToMoiMapperUtil.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2022 Deutsche telekom + * ================================================================================ + * 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.moi.util; + +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aai.domain.yang.SliceProfile; +import org.onap.so.moi.Attributes; +import org.onap.so.moi.PlmnId; +import org.onap.so.moi.Snssai; +import org.springframework.stereotype.Component; + +@Component +public class SliceProfileAaiToMoiMapperUtil { + + public ServiceInstance fillSliceProfileInstanceFromMoiRequest(Attributes moiRequestAttributes, + ServiceInstance serviceInstance) { + + // org.onap.so.moi.SliceProfile moiSliceProfile = null; + + String serviceInstanceLocationId = null; + String environmentContext = null; + String serviceType = null; + String operationalState = "LOCKED"; + String orchistrationStatus = "Assigned"; + + for (org.onap.so.moi.SliceProfile moiSliceProfile : moiRequestAttributes.getSliceProfileList()) { + serviceInstanceLocationId = getPlmnId(moiSliceProfile.getPlmnInfoList().get(0).getPlmnId()); + environmentContext = getSnssai(moiSliceProfile.getPlmnInfoList().get(0).getSnssai()); + serviceType = moiSliceProfile.getRANSliceSubnetProfile().getServiceType(); + } + + serviceInstance.setServiceInstanceLocationId(serviceInstanceLocationId); + serviceInstance.setEnvironmentContext(environmentContext); + serviceInstance.setServiceType(serviceType); + serviceInstance.setOperationalStatus(operationalState); + return serviceInstance; + } + + String getSnssai(Snssai snssai) { + return snssai.getSst() + "-" + snssai.getSd(); + } + + String getPlmnId(PlmnId plmnId) { + return plmnId.getMcc() + "-" + plmnId.getMnc(); + } + + public SliceProfile extractAaiSliceProfileFromMoiRequest(Attributes moiRequestAttributes) { + + SliceProfile aaiSLiceProfile = null; + + for (org.onap.so.moi.SliceProfile sliceProfileMoi : moiRequestAttributes.getSliceProfileList()) { + aaiSLiceProfile = mapMoiSliceProfileToAaiSliceProfile(sliceProfileMoi); + } + + return aaiSLiceProfile; + } + + private SliceProfile mapMoiSliceProfileToAaiSliceProfile(org.onap.so.moi.SliceProfile moiSliceProfile) { + SliceProfile aaiSliceProfile = new SliceProfile(); + + Integer latency = moiSliceProfile.getRANSliceSubnetProfile().getLatency(); + Integer areaTrafficCapDL = moiSliceProfile.getRANSliceSubnetProfile().getAreaTrafficCapDL(); + Integer maxNumberOfUEs = moiSliceProfile.getRANSliceSubnetProfile().getMaxNumberofUEs(); + String resourceSharingLevel = moiSliceProfile.getRANSliceSubnetProfile().getResourceSharingLevel(); + Integer coverageAreaTAList = moiSliceProfile.getRANSliceSubnetProfile().getCoverageAreaTAList(); + + aaiSliceProfile.setLatency(latency); + aaiSliceProfile.setMaxNumberOfUEs(maxNumberOfUEs); + aaiSliceProfile.setResourceSharingLevel(resourceSharingLevel); + aaiSliceProfile.setCoverageAreaTAList(String.valueOf(coverageAreaTAList)); + aaiSliceProfile.setAreaTrafficCapDL(areaTrafficCapDL); + + return aaiSliceProfile; + } +} diff --git a/bpmn/so-bpmn-moi/src/main/resources/process/ActivateRANNssiBB.bpmn b/bpmn/so-bpmn-moi/src/main/resources/process/ActivateRANNssiBB.bpmn new file mode 100644 index 0000000000..8e5c2d18b6 --- /dev/null +++ b/bpmn/so-bpmn-moi/src/main/resources/process/ActivateRANNssiBB.bpmn @@ -0,0 +1,39 @@ + + + + + Flow_05e75ml + + + Flow_1wiu58e + + + + Flow_05e75ml + Flow_1wiu58e + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-moi/src/main/resources/process/AssignRANNssiBB.bpmn b/bpmn/so-bpmn-moi/src/main/resources/process/AssignRANNssiBB.bpmn new file mode 100644 index 0000000000..c452c6d0e7 --- /dev/null +++ b/bpmn/so-bpmn-moi/src/main/resources/process/AssignRANNssiBB.bpmn @@ -0,0 +1,99 @@ + + + + + Flow_07dyds8 + + + Flow_1jwhdm2 + + + + Flow_07dyds8 + Flow_1erbnfk + + + + + Flow_1svksq9 + Flow_1trcgyv + + + + + + Flow_1ut0avh + Flow_08asmxy + + + Flow_1trcgyv + Flow_1ut0avh + + + Flow_08asmxy + Flow_1jwhdm2 + + + + Flow_1erbnfk + Flow_1svksq9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-moi/src/main/resources/process/DeleteRANNssiBB.bpmn b/bpmn/so-bpmn-moi/src/main/resources/process/DeleteRANNssiBB.bpmn new file mode 100644 index 0000000000..6b84a55551 --- /dev/null +++ b/bpmn/so-bpmn-moi/src/main/resources/process/DeleteRANNssiBB.bpmn @@ -0,0 +1,39 @@ + + + + + Flow_07dyds8 + + + Flow_1trcgyv + + + + + Flow_07dyds8 + Flow_1trcgyv + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-moi/src/main/resources/process/EnrichGBB.bpmn b/bpmn/so-bpmn-moi/src/main/resources/process/EnrichGBB.bpmn new file mode 100644 index 0000000000..63ef7d4cfd --- /dev/null +++ b/bpmn/so-bpmn-moi/src/main/resources/process/EnrichGBB.bpmn @@ -0,0 +1,74 @@ + + + + + Flow_00l5u3m + + + + + + + + + + + + SequenceFlow_1r5aycw + Flow_1navrbe + + + + + + Flow_1xiq8re + + + + Flow_00l5u3m + SequenceFlow_1r5aycw + + + Flow_1navrbe + Flow_1xiq8re + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-moi/src/main/resources/process/ModifyRANNssiBB.bpmn b/bpmn/so-bpmn-moi/src/main/resources/process/ModifyRANNssiBB.bpmn new file mode 100644 index 0000000000..5e138ec8c5 --- /dev/null +++ b/bpmn/so-bpmn-moi/src/main/resources/process/ModifyRANNssiBB.bpmn @@ -0,0 +1,39 @@ + + + + + Flow_07dyds8 + + + Flow_1trcgyv + + + + + Flow_07dyds8 + Flow_1trcgyv + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/AssignRANNssiBBTasksTest.java b/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/AssignRANNssiBBTasksTest.java new file mode 100644 index 0000000000..aaf0b8901a --- /dev/null +++ b/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/AssignRANNssiBBTasksTest.java @@ -0,0 +1,162 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2022 Deutsche telekom + * ================================================================================ + * 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.moi.tasks; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.camunda.bpm.engine.delegate.BpmnError; +import org.onap.aai.domain.yang.Customer; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aai.domain.yang.ServiceSubscription; +import org.onap.aaiclient.client.aai.AAIRestClientImpl; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.InjectionHelper; +import org.onap.so.bpmn.moi.util.SliceProfileAaiToMoiMapperUtil; +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; +import java.util.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.*; +import static org.mockito.Mockito.times; + +@RunWith(MockitoJUnitRunner.Silent.class) + +public class AssignRANNssiBBTasksTest { + @Mock + protected InjectionHelper injectionHelper; + @Mock + protected ObjectMapper mapper = new ObjectMapper(); + @Mock + protected AAIRestClientImpl aaiRestClient = new AAIRestClientImpl(); + @Mock + protected SliceProfileAaiToMoiMapperUtil mapperUtil; + @Mock + GeneralBuildingBlock gBB; + @Mock + ServiceInstance serviceInstance; + @Mock + protected ExceptionBuilder exceptionUtil; + @Mock + AssignRANNssiBBTasks assignRANNssiBBTasks; + @Mock + private BuildingBlockExecution execution; + @Mock + private ModelInfoServiceInstance modelInfoServiceInstance; + @Mock + protected ExtractPojosForBB extractPojosForBBMock; + + + private String operationalState; + private String administrativeState; + + private String sliceProfileServiceInstanceId = "215"; + + private String serviceInstanceId = "123"; + + Customer customerA = new Customer(); + + @Mock + private AAIResourceUri allotedResourceURI; + String serviceType; + + String globalCustomerId; + + private UUID allottedResourceUuidUuid = UUID.randomUUID(); + + @Rule + public final ExpectedException exception = ExpectedException.none(); + private ServiceSubscription serviceSubscription; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void before() throws BBObjectNotFoundException { + + serviceInstance.setServiceInstanceId("123"); + modelInfoServiceInstance.setModelUuid("235"); + ServiceInstance serviceInstance = new ServiceInstance(); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.SERVICE_INSTANCE_ID))) + .thenReturn(serviceInstanceId); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.ServiceInstance))).thenReturn(serviceInstance); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.ModelInfoServiceInstance))) + .thenReturn(modelInfoServiceInstance); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.operationalState))).thenReturn(operationalState); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.administrativeState))) + .thenReturn(administrativeState); + serviceSubscription = new ServiceSubscription(); + serviceSubscription.setServiceType(serviceType); + doThrow(new BpmnError("BPMN Error")).when(exceptionUtil) + .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class)); + } + + @Test + public void createNssiTest() throws Exception { + doNothing().when(assignRANNssiBBTasks).createNssi(execution); + assignRANNssiBBTasks.createNssi(execution); + verify(assignRANNssiBBTasks, times(1)).createNssi(execution); + System.out.println("sucess"); + } + + @Test + public void createSliceProfileInstanceTest() { + doNothing().when(assignRANNssiBBTasks).createSliceProfileInstance(execution); + assignRANNssiBBTasks.createSliceProfileInstance(execution); + verify(assignRANNssiBBTasks, times(1)).createSliceProfileInstance(execution); + System.out.println("sucess"); + } + + @Test + public void allotResourcesTest() { + doNothing().when(assignRANNssiBBTasks).allotResources(execution); + assignRANNssiBBTasks.allotResources(execution); + verify(assignRANNssiBBTasks, times(1)).allotResources(execution); + } + + @Test + public void addSliceProfileToNssiTest() { + doNothing().when(assignRANNssiBBTasks).addSliceProfileToNssi(execution); + assignRANNssiBBTasks.addSliceProfileToNssi(execution); + verify(assignRANNssiBBTasks, times(1)).addSliceProfileToNssi(execution); + System.out.println("sucess"); + } + + @Test + public void activateNssiTest() { + doNothing().when(assignRANNssiBBTasks).activateNssi(execution); + assignRANNssiBBTasks.activateNssi(execution); + verify(assignRANNssiBBTasks, times(1)).activateNssi(execution); + } + +} diff --git a/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/DeleteRANNssiBBTaskTest.java b/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/DeleteRANNssiBBTaskTest.java new file mode 100644 index 0000000000..5dd0f340ba --- /dev/null +++ b/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/DeleteRANNssiBBTaskTest.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2022 Deutsche telekom + * ================================================================================ + * 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.moi.tasks; + +import com.fasterxml.jackson.core.JsonProcessingException; +import org.camunda.bpm.engine.delegate.BpmnError; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aai.domain.yang.ServiceSubscription; +import org.onap.aaiclient.client.aai.AAIRestClientImpl; +import org.onap.so.bpmn.common.BuildingBlockExecution; +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; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.*; +import static org.mockito.Mockito.times; + +@RunWith(MockitoJUnitRunner.Silent.class) + +public class DeleteRANNssiBBTaskTest { + + @Mock + BuildingBlockExecution execution; + @Mock + ModelInfoServiceInstance modelInfoServiceInstance; + @Mock + protected ExtractPojosForBB extractPojosForBBMock; + @Mock + protected ExceptionBuilder exceptionUtil; + @Mock + ServiceInstance serviceInstance; + private String operationalState; + private String administrativeState; + private String serviceInstanceId = "123"; + + private String sliceProfileServiceInstanceId = "123"; + + private AAIRestClientImpl aaiRestClient = new AAIRestClientImpl(); + + private GeneralBuildingBlock gBB = new GeneralBuildingBlock(); + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + @Mock + DeleteRANNssiBBTask deleteRANNssiBBTask; + + @Before + public void before() throws BBObjectNotFoundException { + + serviceInstance.setServiceInstanceId("123"); + modelInfoServiceInstance.setModelUuid("231"); + ServiceInstance serviceInstance = new ServiceInstance(); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.SERVICE_INSTANCE_ID))) + .thenReturn(serviceInstanceId); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.ServiceInstance))).thenReturn(serviceInstance); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.ModelInfoServiceInstance))) + .thenReturn(modelInfoServiceInstance); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.operationalState))).thenReturn(operationalState); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.administrativeState))) + .thenReturn(administrativeState); + doThrow(new BpmnError("BPMN Error")).when(exceptionUtil) + .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class)); + } + + @Test + public void deleteNssiTest() throws JsonProcessingException { + doNothing().when(deleteRANNssiBBTask).deleteNssi(execution); + deleteRANNssiBBTask.deleteNssi(execution); + verify(deleteRANNssiBBTask, times(1)).deleteNssi(execution); + + } +} diff --git a/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/EnrichGBBTaskTest.java b/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/EnrichGBBTaskTest.java new file mode 100644 index 0000000000..b48bb8cdee --- /dev/null +++ b/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/EnrichGBBTaskTest.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2022 Deutsche telekom + * ================================================================================ + * 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.moi.tasks; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import static org.junit.Assert.*; + +public class EnrichGBBTaskTest { + @Mock + DelegateExecution execution; + + @Before + public void setUp() throws Exception {} + + @Test + public void prepareOofRequest() {} + + @Test + public void processOOFAsyncResponse() {} +} diff --git a/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/ModifyRANNssiBBTaskTest.java b/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/ModifyRANNssiBBTaskTest.java new file mode 100644 index 0000000000..c946d3b56c --- /dev/null +++ b/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/ModifyRANNssiBBTaskTest.java @@ -0,0 +1,121 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2022 Deutsche telekom + * ================================================================================ + * 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.moi.tasks; + +import com.fasterxml.jackson.core.JsonProcessingException; +import junit.framework.TestCase; +import org.camunda.bpm.engine.delegate.BpmnError; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aai.domain.yang.ServiceSubscription; +import org.onap.aai.domain.yang.SliceProfile; +import org.onap.aaiclient.client.aai.AAIRestClientImpl; +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.BuildingBlockExecution; +import org.onap.so.bpmn.common.InjectionHelper; +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; +import org.onap.so.db.catalog.beans.OrchestrationStatus; +import java.util.*; +import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.*; +import static org.mockito.Mockito.times; + +@RunWith(MockitoJUnitRunner.Silent.class) + +public class ModifyRANNssiBBTaskTest { + @Mock + BuildingBlockExecution execution; + @Mock + ServiceInstance serviceInstance; + @Mock + private AAIResourceUri allotedResourceURI; + private org.onap.aai.domain.yang.Customer customer = new org.onap.aai.domain.yang.Customer(); + @Mock + private ModelInfoServiceInstance modelInfoServiceInstance; + @Mock + protected ExtractPojosForBB extractPojosForBBMock; + + @Mock + protected InjectionHelper injectionHelper; + + private String operationalState = "ENABLED"; + private String administrativeState = "UNLOCKED"; + private String serviceInstanceId = "123"; + private ServiceSubscription serviceSubscription; + @Mock + protected ExceptionBuilder exceptionUtil; + String serviceType; + + private String sliceProfileServiceInstanceId = "123"; + + private AAIRestClientImpl aaiRestClient = new AAIRestClientImpl(); + + @Mock + private GeneralBuildingBlock gBB = new GeneralBuildingBlock(); + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + @Mock + ModifyRANNssiBBTask modifyRANNssiBBTask = new ModifyRANNssiBBTask(); + + @Before + public void before() throws BBObjectNotFoundException { + serviceInstance.setServiceInstanceId("123"); + modelInfoServiceInstance.setModelUuid("235"); + ServiceInstance serviceInstance = new ServiceInstance(); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.SERVICE_INSTANCE_ID))) + .thenReturn(serviceInstanceId); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.ServiceInstance))).thenReturn(serviceInstance); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.ModelInfoServiceInstance))) + .thenReturn(modelInfoServiceInstance); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.operationalState))).thenReturn(operationalState); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.administrativeState))) + .thenReturn(administrativeState); + serviceSubscription = new ServiceSubscription(); + serviceSubscription.setServiceType(serviceType); + } + + @Test + public void modifyNssiTest() throws JsonProcessingException { + + doNothing().when(modifyRANNssiBBTask).modifyNssi(execution); + modifyRANNssiBBTask.modifyNssi(execution); + verify(modifyRANNssiBBTask, times(1)).modifyNssi(execution); + } +} + + 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 f2f3b5da08..12723b8183 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 @@ -94,6 +94,14 @@ public class ControllerExecution { ModelInfoServiceInstance modelInfoServiceInstance = gbb.getServiceInstance().getModelInfoServiceInstance(); controllerActor = Optional.ofNullable(modelInfoServiceInstance.getControllerActor()).orElse("CDS"); + } else if ("nssi".equalsIgnoreCase(scope)) { + GeneralBuildingBlock gbb = execution.getGeneralBuildingBlock(); + ModelInfoServiceInstance modelInfoServiceInstance = + gbb.getServiceInstance().getModelInfoServiceInstance(); + logger.info(">>>> modelInfoServiceInstance: {}", modelInfoServiceInstance); + ModelInfoServiceInstance modelInfoServiceInstance1 = execution.getVariable("nssiModelInfo"); + logger.info(">>>> ex1: {}", modelInfoServiceInstance1); + 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/NssiCDSProcessingBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NssiCDSProcessingBB.java new file mode 100644 index 0000000000..df9a0f60b1 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NssiCDSProcessingBB.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2022 Deutsche telekom + * ================================================================================ + * 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.flowspecific.tasks; + +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext; +import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable; +import org.onap.so.client.cds.AbstractCDSProcessingBBUtils; +import org.onap.so.client.cds.GeneratePayloadForCds; +import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; +import org.onap.so.client.exception.ExceptionBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * This class is used in context of Building Block flow for configuration of vnf/vfmodule/service. + * + * @param - BuildingBlockExecution + */ +@Component +public class NssiCDSProcessingBB implements ControllerRunnable { + private static final Logger logger = LoggerFactory.getLogger(NssiCDSProcessingBB.class); + private static final String EXECUTION_OBJECT = "executionObject"; + public static final String CDS_ACTOR = "cds"; + public static final String NSSI_SCOPE = "nssi"; + + @Autowired + private ExceptionBuilder exceptionBuilder; + + @Autowired + private AbstractCDSProcessingBBUtils cdsDispather; + + @Autowired + private GeneratePayloadForCds generatePayloadForCds; + + @Override + public Boolean understand(ControllerContext context) { + String scope = context.getControllerScope(); + return CDS_ACTOR.equalsIgnoreCase(context.getControllerActor()) && NSSI_SCOPE.equalsIgnoreCase(scope); + } + + @Override + public Boolean ready(ControllerContext context) { + return true; + } + + @Override + public void prepare(ControllerContext context) { + BuildingBlockExecution buildingBlockExecution = context.getExecution(); + try { + AbstractCDSPropertiesBean abstractCDSPropertiesBean = + generatePayloadForCds.buildCdsPropertiesBean(buildingBlockExecution); + buildingBlockExecution.setVariable(EXECUTION_OBJECT, abstractCDSPropertiesBean); + } catch (Exception ex) { + logger.error("An exception occurred when creating payload for CDS request", ex); + exceptionBuilder.buildAndThrowWorkflowException(buildingBlockExecution, 7000, ex); + } + } + + @Override + public void run(ControllerContext context) { + BuildingBlockExecution obj = context.getExecution(); + cdsDispather.constructExecutionServiceInputObjectBB(obj); + cdsDispather.sendRequestToCDSClientBB(obj); + } +} 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 64ae9cb5e0..82f44bc802 100755 --- 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 @@ -70,6 +70,7 @@ 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.infrastructure.workflow.tasks.ebb.loader.NetworkSliceSubnetEBBLoader; import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader.PnfEBBLoader; import org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader.ServiceEBBLoader; @@ -112,7 +113,7 @@ public class WorkflowAction { private static final String VNF_TYPE = "vnfType"; private static final String CONFIGURATION = "Configuration"; private static final String SUPPORTEDTYPES = - "vnfs|pnfs|cnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances|instanceGroups"; + "vnfs|pnfs|cnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances|instanceGroups|NetworkSliceSubnet"; private static final String HOMINGSOLUTION = "Homing_Solution"; private static final String SERVICE_TYPE_TRANSPORT = "TRANSPORT"; private static final String SERVICE_TYPE_BONDING = "BONDING"; @@ -144,6 +145,8 @@ public class WorkflowAction { private PnfEBBLoader pnfEBBLoader; @Autowired private ServiceEBBLoader serviceEBBLoader; + @Autowired + private NetworkSliceSubnetEBBLoader networkSliceSubnetEBBLoader; public void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils) { this.bbInputSetupUtils = bbInputSetupUtils; @@ -300,6 +303,8 @@ public class WorkflowAction { || isPNFCreate(resourceType, requestAction)) { resourceList = serviceEBBLoader.getResourceListForService(sIRequest, requestAction, execution, serviceInstanceId, resourceId, aaiResourceIds); + } else if (resourceType == WorkflowType.NETWORK_SLICE_SUBNET) { + resourceList = networkSliceSubnetEBBLoader.setNetworkSliceSubnetResource(resourceId); } else if (isPNFDelete(resourceType, requestAction)) { pnfEBBLoader.traverseAAIPnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), resourceId, aaiResourceIds); @@ -840,7 +845,7 @@ public class WorkflowAction { } protected String convertTypeFromPlural(String type) { - if (!type.matches(SUPPORTEDTYPES)) { + if (!type.matches(SUPPORTEDTYPES) || type.equals("NetworkSliceSubnet")) { return type; } else { if (type.equals(SERVICE_INSTANCES)) { 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 7ffd066de5..06afe9a20c 100755 --- 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 @@ -36,6 +36,7 @@ public final class WorkflowActionConstants { public static final String ASSIGN_INSTANCE = "assignInstance"; public static final String CHILD_SERVICE = "ChildService"; public static final String CONFIGURATION = "Configuration"; + public static final String NSSI = "Nssi"; public static final String CONTROLLER = "Controller"; public static final String CREATE_INSTANCE = "createInstance"; public static final String DEACTIVATE_INSTANCE = "deactivateInstance"; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/NetworkSliceSubnetEBBLoader.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/NetworkSliceSubnetEBBLoader.java new file mode 100644 index 0000000000..1d58a16fa2 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/NetworkSliceSubnetEBBLoader.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2022 DTAG + * ================================================================================ + * 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.workflow.tasks.ebb.loader; + +import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource; +import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; +import org.onap.so.client.exception.ExceptionBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import java.util.ArrayList; +import java.util.List; + +@Component +public class NetworkSliceSubnetEBBLoader { + + private static final Logger logger = LoggerFactory.getLogger(VnfEBBLoader.class); + + private final BBInputSetupUtils bbInputSetupUtils; + private final BBInputSetup bbInputSetup; + private final WorkflowActionExtractResourcesAAI workflowActionUtils; + private final ExceptionBuilder exceptionBuilder; + + NetworkSliceSubnetEBBLoader(BBInputSetupUtils bbInputSetupUtils, BBInputSetup bbInputSetup, + WorkflowActionExtractResourcesAAI workflowActionUtils, ExceptionBuilder exceptionBuilder) { + this.bbInputSetupUtils = bbInputSetupUtils; + this.bbInputSetup = bbInputSetup; + this.workflowActionUtils = workflowActionUtils; + this.exceptionBuilder = exceptionBuilder; + } + + + public List setNetworkSliceSubnetResource(String serviceId) { + Resource networkSliceSubnetResource = new Resource(WorkflowType.NETWORK_SLICE_SUBNET, serviceId, false, null); + List resourceList = new ArrayList<>(); + resourceList.add(networkSliceSubnetResource); + return resourceList; + } +} + diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/ApiHandlerClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/ApiHandlerClient.java index 132e618ba5..e92f68f5ff 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/ApiHandlerClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/ApiHandlerClient.java @@ -19,9 +19,9 @@ public class ApiHandlerClient { @Value("${mso.adapters.apihandler.serviceInstantiationEndpoint:/onap/so/infra/serviceInstantiation/v7/serviceInstances}") private String serviceInstantiationEndpoint; - @Value("${mso.adapters.apihandler.endpoint}") + @Value("${mso.adapters.apihandler.endpoint:http://localhost:8080}") private String baseUri; - @Value("${mso.adapters.apihandler.auth}") + @Value("${mso.adapters.apihandler.auth:Basic dGVzdDp0ZXN0Cg==}") private String auth; private RestTemplate restTemplate; -- cgit 1.2.3-korg