diff options
43 files changed, 3226 insertions, 242 deletions
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<String, Object> 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<String, Object> 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<ResourceKey, String> 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<GenericVnf> 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<ResourceKey, String> 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 <T> void setExecutionObject(T executionObject) { + execution = (BuildingBlockExecution) executionObject; + } + + @Override + public Optional<String> buildRequestPayload(String action) throws PayloadGenerationException { + JsonObject cdsPropertyObject = null; + + final GeneralBuildingBlock buildingBlock = execution.getGeneralBuildingBlock(); + List<Map<String, Object>> 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<Map<String, Object>> userParamsFromRequest = + buildingBlock.getRequestContext().getRequestParameters().getUserParams(); + + Attributes attributes = null; + + for (Map<String, Object> 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<String, Object> getSliceProfilesFromUserParams(GeneralBuildingBlock gBB) { + + + List<Map<String, Object>> mapUserParams = gBB.getRequestContext().getRequestParameters().getUserParams(); + + Map<String, Object> 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<String, Object> 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<AAIResourceUri> 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<String, List<Map<String, Object>>> serviceInstancesMap = null; + try { + serviceInstancesMap = mapper.readValue(results, Map.class); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + Map<String, Object> serviceInstance = + (Map<String, Object>) 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<ServiceInstances> 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<org.onap.aai.domain.yang.ServiceInstance> 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 476cb31f21..f3d688f587 100644 --- a/bpmn/mso-infrastructure-bpmn/pom.xml +++ b/bpmn/mso-infrastructure-bpmn/pom.xml @@ -261,6 +261,11 @@ <version>${project.version}</version> </dependency> <dependency> + <groupId>org.onap.so</groupId> + <artifactId>so-bpmn-moi</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> </dependency> diff --git a/bpmn/pom.xml b/bpmn/pom.xml index deb00eadef..4a7bfd894f 100644 --- a/bpmn/pom.xml +++ b/bpmn/pom.xml @@ -30,6 +30,7 @@ <module>so-bpmn-building-blocks</module> <module>so-bpmn-infrastructure-flows</module> <module>mso-infrastructure-bpmn</module> + <module>so-bpmn-moi</module> </modules> <!-- Define artifact versions for child modules --> <dependencyManagement> 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 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.6.0"> <bpmn:process id="ExecuteBuildingBlock" name="ExecuteBuildingBlock" isExecutable="true"> <bpmn:startEvent id="Start_ExecuteBuildingBlock" name="start"> <bpmn:outgoing>SequenceFlow_0rq4c5r</bpmn:outgoing> @@ -18,7 +18,7 @@ <bpmn:outgoing>SequenceFlow_01h9qmz</bpmn:outgoing> </bpmn:callActivity> <bpmn:sequenceFlow id="SequenceFlow_0rq4c5r" sourceRef="Start_ExecuteBuildingBlock" targetRef="Task_BBInputSetup" /> - <bpmn:sequenceFlow id="SequenceFlow_0uzwjrq" sourceRef="Task_BBInputSetup" targetRef="StatusPolicy" /> + <bpmn:sequenceFlow id="SequenceFlow_0uzwjrq" sourceRef="Task_BBInputSetup" targetRef="Gateway_0b4yrrl" /> <bpmn:serviceTask id="Task_BBInputSetup" name="BB Input Setup" camunda:expression="${BBInputSetup.execute(execution)}"> <bpmn:incoming>SequenceFlow_0rq4c5r</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0uzwjrq</bpmn:outgoing> @@ -29,7 +29,8 @@ <bpmn:sequenceFlow id="SequenceFlow_01h9qmz" sourceRef="Call_BBToExecute" targetRef="Task_PostValidate" /> <bpmn:sequenceFlow id="Continue" name="Continue" sourceRef="CheckOrchestrationStatusValidationResults" targetRef="Task_PreValidate" /> <bpmn:serviceTask id="StatusPolicy" name="StatusPolicy" camunda:expression="${OrchestrationStatusValidator.validateOrchestrationStatus(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_0uzwjrq</bpmn:incoming> + <bpmn:incoming>Flow_17e9fnw</bpmn:incoming> + <bpmn:incoming>Flow_1x0zdf6</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0je0y25</bpmn:outgoing> </bpmn:serviceTask> <bpmn:exclusiveGateway id="CheckOrchestrationStatusValidationResults" name="Check OrchestrationStatus Validation Results" default="Continue"> @@ -155,6 +156,41 @@ <bpmn:incoming>SequenceFlow_01h9qmz</bpmn:incoming> <bpmn:outgoing>SequenceFlow_12a4hhf</bpmn:outgoing> </bpmn:serviceTask> + <bpmn:exclusiveGateway id="Gateway_0b4yrrl" default="Flow_17e9fnw"> + <bpmn:incoming>SequenceFlow_0uzwjrq</bpmn:incoming> + <bpmn:outgoing>Flow_17e9fnw</bpmn:outgoing> + <bpmn:outgoing>Flow_0o7fpuq</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_17e9fnw" sourceRef="Gateway_0b4yrrl" targetRef="StatusPolicy" /> + <bpmn:callActivity id="Call_ExecuteBB" name="EnrichGBB" camunda:asyncBefore="true" calledElement="EnrichGBB"> + <bpmn:extensionElements> + <camunda:in source="buildingBlock" target="buildingBlock" /> + <camunda:out source="buildingBlock" target="buildingBlock" /> + <camunda:out source="handlingCode" target="handlingCode" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> + <camunda:in source="retryCount" target="retryCount" /> + <camunda:out source="WorkflowExceptionErrorMessage" target="WorkflowExceptionErrorMessage" /> + <camunda:in source="aLaCarte" target="aLaCarte" /> + <camunda:in source="orchestrationStatusValidationResult" target="orchestrationStatusValidationResult" /> + <camunda:out source="orchestrationStatusValidationResult" target="orchestrationStatusValidationResult" /> + <camunda:out source="RetryDuration" target="RetryDuration" /> + <camunda:in source="suppressRollback" target="suppressRollback" /> + <camunda:out source="StatusMessage" target="StatusMessage" /> + <camunda:in source="isRollback" target="isRollback" /> + <camunda:in source="rollbackTargetState" target="rollbackTargetState" /> + <camunda:out source="rollbackTargetState" target="rollbackTargetState" /> + <camunda:in source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> + <camunda:out source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> + <camunda:in source="gBBInput" target="gBBInput" /> + <camunda:out source="gBBInput" target="gBBInput" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0o7fpuq</bpmn:incoming> + <bpmn:outgoing>Flow_1x0zdf6</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_0o7fpuq" name="isHoming" sourceRef="Gateway_0b4yrrl" targetRef="Call_ExecuteBB"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("homing")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1x0zdf6" sourceRef="Call_ExecuteBB" targetRef="StatusPolicy" /> </bpmn:process> <bpmn:error id="Error_0tnktdw" name="Error" errorCode="java.lang.Exception" /> <bpmn:error id="Error_17zcdbk" name="Bpmn Error" /> @@ -165,285 +201,310 @@ <bpmn:error id="Error_0snha16" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ExecuteBuildingBlock"> - <bpmndi:BPMNEdge id="SequenceFlow_12a4hhf_di" bpmnElement="SequenceFlow_12a4hhf"> - <di:waypoint x="1056" y="180" /> - <di:waypoint x="1113" y="180" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="989.5" y="159" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_19wuics_di" bpmnElement="SequenceFlow_19wuics"> - <di:waypoint x="732" y="180" /> - <di:waypoint x="799" y="180" /> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="Start_ExecuteBuildingBlock"> + <dc:Bounds x="122" y="252" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="670.5" y="159" width="90" height="12" /> + <dc:Bounds x="131" y="288" width="22" height="14" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1j0vskt_di" bpmnElement="SequenceFlow_1j0vskt"> - <di:waypoint x="533" y="155" /> - <di:waypoint x="533" y="84" /> - <di:waypoint x="1163" y="84" /> - <di:waypoint x="1163" y="140" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_0n67obl_di" bpmnElement="Call_BBToExecute"> + <dc:Bounds x="860" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0ahsxzi_di" bpmnElement="End_ExecuteBuildingBlock"> + <dc:Bounds x="1332" y="252" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="814" y="63" width="73" height="14" /> + <dc:Bounds x="1341" y="292" width="19" height="14" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_16lmcxp_di" bpmnElement="SequenceFlow_16lmcxp"> - <di:waypoint x="1213" y="180" /> - <di:waypoint x="1271" y="180" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0brnbqx_di" bpmnElement="StatusPolicy"> + <dc:Bounds x="450" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_0f8ghh3_di" bpmnElement="CheckOrchestrationStatusValidationResults" isMarkerVisible="true"> + <dc:Bounds x="575" y="245" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1147" y="159" width="90" height="12" /> + <dc:Bounds x="560" y="299" width="86" height="53" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0je0y25_di" bpmnElement="SequenceFlow_0je0y25"> - <di:waypoint x="471" y="180" /> - <di:waypoint x="508" y="180" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1jcuk3b_di" bpmnElement="Task_BBInputSetup"> + <dc:Bounds x="162" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="SubProcess_0tv8zda_di" bpmnElement="SubProcess_0tv8zda" isExpanded="true"> + <dc:Bounds x="240" y="470" width="1020" height="432" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1tifgqh_di" bpmnElement="Task_QueryRainyDayTable"> + <dc:Bounds x="468" y="634" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_1aonzik_di" bpmnElement="ExclusiveGateway_1aonzik" isMarkerVisible="true"> + <dc:Bounds x="611" y="649" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="394.5" y="159" width="90" height="12" /> + <dc:Bounds x="601" y="611" width="70" height="27" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0kdjsnx_di" bpmnElement="Continue"> - <di:waypoint x="558" y="180" /> - <di:waypoint x="632" y="180" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_0qjyidb_di" bpmnElement="IntermediateCatchEvent_RetryTimer"> + <dc:Bounds x="1008" y="656" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="574" y="159" width="45" height="14" /> + <dc:Bounds x="1000" y="631" width="55" height="14" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_01h9qmz_di" bpmnElement="SequenceFlow_01h9qmz"> - <di:waypoint x="899" y="180" /> - <di:waypoint x="956" y="180" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_0ey4zpt_di" bpmnElement="ExclusiveGateway_0ey4zpt" isMarkerVisible="true"> + <dc:Bounds x="764" y="649" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="832.5" y="159" width="90" height="12" /> + <dc:Bounds x="760" y="624" width="63" height="14" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0uzwjrq_di" bpmnElement="SequenceFlow_0uzwjrq"> - <di:waypoint x="334" y="180" /> - <di:waypoint x="371" y="180" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1obvxht_di" bpmnElement="Task_SetRetryTimer"> + <dc:Bounds x="879" y="634" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0mvmk3i_di" bpmnElement="EndEvent_0mvmk3i"> + <dc:Bounds x="618" y="755" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="257.5" y="165" width="90" height="0" /> + <dc:Bounds x="567" y="624" width="0" height="0" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0rq4c5r_di" bpmnElement="SequenceFlow_0rq4c5r"> - <di:waypoint x="197" y="180" /> - <di:waypoint x="234" y="180" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1aww7yx_di" bpmnElement="EndEvent_1sez2lh"> + <dc:Bounds x="1082" y="656" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="120.5" y="165" width="90" height="0" /> + <dc:Bounds x="1093" y="696" width="19" height="14" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="Start_ExecuteBuildingBlock"> - <dc:Bounds x="161" y="162" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_05vw85n_di" bpmnElement="EndEvent_0ex9298"> + <dc:Bounds x="911" y="745" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="169" y="198" width="23" height="14" /> + <dc:Bounds x="921" y="785" width="19" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="CallActivity_0n67obl_di" bpmnElement="Call_BBToExecute"> - <dc:Bounds x="799" y="140" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_1jcuk3b_di" bpmnElement="Task_BBInputSetup"> - <dc:Bounds x="234" y="140" width="100" height="80" /> + <bpmndi:BPMNShape id="ServiceTask_11f2c91_di" bpmnElement="Task_QuerySecondaryPolicy"> + <dc:Bounds x="739" y="723" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="EndEvent_0ahsxzi_di" bpmnElement="End_ExecuteBuildingBlock"> - <dc:Bounds x="1271" y="162" width="36" height="36" /> + <bpmndi:BPMNShape id="StartEvent_0tmcs9g_di" bpmnElement="StartEvent_0tmcs9g"> + <dc:Bounds x="268" y="656" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1280" y="202" width="19" height="14" /> + <dc:Bounds x="127" y="521" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_0brnbqx_di" bpmnElement="StatusPolicy"> - <dc:Bounds x="371" y="140" width="100" height="80" /> + <bpmndi:BPMNShape id="ServiceTask_10v49qn_di" bpmnElement="Task_UpdateExtErrorSource"> + <dc:Bounds x="333" y="634" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ExclusiveGateway_0f8ghh3_di" bpmnElement="CheckOrchestrationStatusValidationResults" isMarkerVisible="true"> - <dc:Bounds x="508" y="155" width="50" height="50" /> + <bpmndi:BPMNShape id="ServiceTask_0ohzi8e_di" bpmnElement="Task_setHandlingCodeSuccessOnSkip"> + <dc:Bounds x="468" y="760" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_0szwp51_di" bpmnElement="PauseForManualTaskRainyDay"> + <dc:Bounds x="586" y="508" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1py1er4_di" bpmnElement="EndEvent_1py1er4"> + <dc:Bounds x="373" y="782" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="492" y="209" width="87" height="53" /> + <dc:Bounds x="382" y="818" width="19" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="SubProcess_0tv8zda_di" bpmnElement="SubProcess_0tv8zda" isExpanded="true"> - <dc:Bounds x="221" y="299" width="1020" height="432" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1g7oq3t_di" bpmnElement="SequenceFlow_1g7oq3t"> - <di:waypoint x="633" y="512" /> - <di:waypoint x="720" y="562" /> + <bpmndi:BPMNEdge id="SequenceFlow_0a62t4c_di" bpmnElement="SequenceFlow_0a62t4c"> + <di:waypoint x="568" y="674" /> + <di:waypoint x="611" y="674" /> <bpmndi:BPMNLabel> - <dc:Bounds x="698" y="533" width="41" height="14" /> + <dc:Bounds x="521" y="482" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1ynai9j_di" bpmnElement="SequenceFlow_1ynai9j"> - <di:waypoint x="449" y="629" /> - <di:waypoint x="390" y="629" /> + <bpmndi:BPMNEdge id="SequenceFlow_0h8v45y_di" bpmnElement="SequenceFlow_0h8v45y"> + <di:waypoint x="636" y="699" /> + <di:waypoint x="636" y="755" /> <bpmndi:BPMNLabel> - <dc:Bounds x="370" y="604" width="0" height="0" /> + <dc:Bounds x="644" y="720" width="84" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0xyd2zl_di" bpmnElement="SequenceFlow_0xyd2zl"> - <di:waypoint x="603" y="514" /> - <di:waypoint x="499" y="589" /> + <bpmndi:BPMNEdge id="SequenceFlow_0fwsjva_di" bpmnElement="SequenceFlow_0fwsjva"> + <di:waypoint x="661" y="674" /> + <di:waypoint x="764" y="674" /> <bpmndi:BPMNLabel> - <dc:Bounds x="556" y="549" width="22" height="14" /> + <dc:Bounds x="699" y="682" width="27" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1xh5ngw_di" bpmnElement="SequenceFlow_1xh5ngw"> - <di:waypoint x="603" y="492" /> - <di:waypoint x="512" y="423" /> - <di:waypoint x="512" y="377" /> - <di:waypoint x="567" y="377" /> + <bpmndi:BPMNEdge id="SequenceFlow_0ndt8ft_di" bpmnElement="SequenceFlow_0ndt8ft"> + <di:waypoint x="979" y="674" /> + <di:waypoint x="1008" y="674" /> <bpmndi:BPMNLabel> - <dc:Bounds x="517" y="400" width="37" height="14" /> + <dc:Bounds x="925" y="482" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_05le7o3_di" bpmnElement="SequenceFlow_05le7o3"> - <di:waypoint x="667" y="377" /> - <di:waypoint x="709" y="377" /> - <di:waypoint x="709" y="421" /> - <di:waypoint x="630" y="491" /> + <bpmndi:BPMNEdge id="SequenceFlow_07a1ytc_di" bpmnElement="SequenceFlow_07a1ytc"> + <di:waypoint x="1044" y="674" /> + <di:waypoint x="1082" y="674" /> <bpmndi:BPMNLabel> - <dc:Bounds x="674" y="399" width="0" height="0" /> + <dc:Bounds x="994" y="482" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_09synl9_di" bpmnElement="SequenceFlow_09synl9"> - <di:waypoint x="285" y="503" /> - <di:waypoint x="314" y="503" /> + <bpmndi:BPMNEdge id="SequenceFlow_1wbevp0_di" bpmnElement="SequenceFlow_1wbevp0"> + <di:waypoint x="814" y="674" /> + <di:waypoint x="879" y="674" /> <bpmndi:BPMNLabel> - <dc:Bounds x="250" y="482" width="0" height="0" /> + <dc:Bounds x="833" y="649" width="18" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0vdeqxv_di" bpmnElement="SequenceFlow_0vdeqxv"> - <di:waypoint x="414" y="503" /> - <di:waypoint x="449" y="503" /> + <bpmndi:BPMNEdge id="SequenceFlow_0541bid_di" bpmnElement="SequenceFlow_0541bid"> + <di:waypoint x="789" y="699" /> + <di:waypoint x="789" y="723" /> <bpmndi:BPMNLabel> - <dc:Bounds x="382" y="482" width="0" height="0" /> + <dc:Bounds x="801" y="700" width="13" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_12ps9at_di" bpmnElement="SequenceFlow_12ps9at"> - <di:waypoint x="820" y="592" /> - <di:waypoint x="892" y="592" /> + <di:waypoint x="839" y="763" /> + <di:waypoint x="911" y="763" /> <bpmndi:BPMNLabel> <dc:Bounds x="806" y="571" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0541bid_di" bpmnElement="SequenceFlow_0541bid"> - <di:waypoint x="770" y="528" /> - <di:waypoint x="770" y="552" /> + <bpmndi:BPMNEdge id="SequenceFlow_0vdeqxv_di" bpmnElement="SequenceFlow_0vdeqxv"> + <di:waypoint x="433" y="674" /> + <di:waypoint x="468" y="674" /> <bpmndi:BPMNLabel> - <dc:Bounds x="782" y="529" width="13" height="14" /> + <dc:Bounds x="382" y="482" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1wbevp0_di" bpmnElement="SequenceFlow_1wbevp0"> - <di:waypoint x="795" y="503" /> - <di:waypoint x="860" y="503" /> + <bpmndi:BPMNEdge id="SequenceFlow_09synl9_di" bpmnElement="SequenceFlow_09synl9"> + <di:waypoint x="304" y="674" /> + <di:waypoint x="333" y="674" /> <bpmndi:BPMNLabel> - <dc:Bounds x="814" y="478" width="17" height="14" /> + <dc:Bounds x="250" y="482" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_07a1ytc_di" bpmnElement="SequenceFlow_07a1ytc"> - <di:waypoint x="1025" y="503" /> - <di:waypoint x="1063" y="503" /> + <bpmndi:BPMNEdge id="SequenceFlow_05le7o3_di" bpmnElement="SequenceFlow_05le7o3"> + <di:waypoint x="686" y="548" /> + <di:waypoint x="728" y="548" /> + <di:waypoint x="728" y="592" /> + <di:waypoint x="649" y="662" /> <bpmndi:BPMNLabel> - <dc:Bounds x="994" y="482" width="0" height="0" /> + <dc:Bounds x="674" y="399" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0ndt8ft_di" bpmnElement="SequenceFlow_0ndt8ft"> - <di:waypoint x="960" y="503" /> - <di:waypoint x="989" y="503" /> + <bpmndi:BPMNEdge id="SequenceFlow_1xh5ngw_di" bpmnElement="SequenceFlow_1xh5ngw"> + <di:waypoint x="622" y="663" /> + <di:waypoint x="531" y="594" /> + <di:waypoint x="531" y="548" /> + <di:waypoint x="586" y="548" /> <bpmndi:BPMNLabel> - <dc:Bounds x="925" y="482" width="0" height="0" /> + <dc:Bounds x="536" y="571" width="37" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0fwsjva_di" bpmnElement="SequenceFlow_0fwsjva"> - <di:waypoint x="642" y="503" /> - <di:waypoint x="745" y="503" /> + <bpmndi:BPMNEdge id="SequenceFlow_0xyd2zl_di" bpmnElement="SequenceFlow_0xyd2zl"> + <di:waypoint x="622" y="685" /> + <di:waypoint x="518" y="760" /> <bpmndi:BPMNLabel> - <dc:Bounds x="680" y="511" width="27" height="14" /> + <dc:Bounds x="575" y="720" width="22" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0h8v45y_di" bpmnElement="SequenceFlow_0h8v45y"> - <di:waypoint x="617" y="528" /> - <di:waypoint x="617" y="584" /> + <bpmndi:BPMNEdge id="SequenceFlow_1ynai9j_di" bpmnElement="SequenceFlow_1ynai9j"> + <di:waypoint x="468" y="800" /> + <di:waypoint x="409" y="800" /> <bpmndi:BPMNLabel> - <dc:Bounds x="624" y="549" width="86" height="14" /> + <dc:Bounds x="370" y="604" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0a62t4c_di" bpmnElement="SequenceFlow_0a62t4c"> - <di:waypoint x="549" y="503" /> - <di:waypoint x="592" y="503" /> + <bpmndi:BPMNEdge id="SequenceFlow_1g7oq3t_di" bpmnElement="SequenceFlow_1g7oq3t"> + <di:waypoint x="652" y="683" /> + <di:waypoint x="739" y="733" /> <bpmndi:BPMNLabel> - <dc:Bounds x="521" y="482" width="0" height="0" /> + <dc:Bounds x="718" y="704" width="40" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_1tifgqh_di" bpmnElement="Task_QueryRainyDayTable"> - <dc:Bounds x="449" y="463" width="100" height="80" /> + <bpmndi:BPMNShape id="ServiceTask_0z9izx5_di" bpmnElement="Task_setHandlingCodeSuccess"> + <dc:Bounds x="1180" y="230" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ExclusiveGateway_1aonzik_di" bpmnElement="ExclusiveGateway_1aonzik" isMarkerVisible="true"> - <dc:Bounds x="592" y="478" width="50" height="50" /> + <bpmndi:BPMNShape id="ServiceTask_1pf5f6w_di" bpmnElement="Task_PreValidate"> + <dc:Bounds x="720" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_02w4792_di" bpmnElement="Task_PostValidate"> + <dc:Bounds x="1010" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_0b4yrrl_di" bpmnElement="Gateway_0b4yrrl" isMarkerVisible="true"> + <dc:Bounds x="325" y="245" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_03m7z4y_di" bpmnElement="Call_ExecuteBB"> + <dc:Bounds x="450" y="80" width="100" height="80" /> + <bpmndi:BPMNLabel /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0rq4c5r_di" bpmnElement="SequenceFlow_0rq4c5r"> + <di:waypoint x="140" y="252" /> + <di:waypoint x="140" y="210" /> + <di:waypoint x="212" y="210" /> + <di:waypoint x="212" y="230" /> <bpmndi:BPMNLabel> - <dc:Bounds x="582" y="440" width="70" height="27" /> + <dc:Bounds x="120.5" y="165" width="90" height="0" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="IntermediateCatchEvent_0qjyidb_di" bpmnElement="IntermediateCatchEvent_RetryTimer"> - <dc:Bounds x="989" y="485" width="36" height="36" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0uzwjrq_di" bpmnElement="SequenceFlow_0uzwjrq"> + <di:waypoint x="262" y="270" /> + <di:waypoint x="325" y="270" /> <bpmndi:BPMNLabel> - <dc:Bounds x="980" y="460" width="56" height="14" /> + <dc:Bounds x="257.5" y="165" width="90" height="0" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ExclusiveGateway_0ey4zpt_di" bpmnElement="ExclusiveGateway_0ey4zpt" isMarkerVisible="true"> - <dc:Bounds x="745" y="478" width="50" height="50" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_01h9qmz_di" bpmnElement="SequenceFlow_01h9qmz"> + <di:waypoint x="960" y="270" /> + <di:waypoint x="1010" y="270" /> <bpmndi:BPMNLabel> - <dc:Bounds x="741" y="453" width="63" height="14" /> + <dc:Bounds x="832.5" y="159" width="90" height="12" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_1obvxht_di" bpmnElement="Task_SetRetryTimer"> - <dc:Bounds x="860" y="463" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="EndEvent_0mvmk3i_di" bpmnElement="EndEvent_0mvmk3i"> - <dc:Bounds x="599" y="584" width="36" height="36" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0kdjsnx_di" bpmnElement="Continue"> + <di:waypoint x="625" y="270" /> + <di:waypoint x="720" y="270" /> <bpmndi:BPMNLabel> - <dc:Bounds x="567" y="624" width="0" height="0" /> + <dc:Bounds x="652" y="249" width="45" height="14" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="EndEvent_1aww7yx_di" bpmnElement="EndEvent_1sez2lh"> - <dc:Bounds x="1063" y="485" width="36" height="36" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0je0y25_di" bpmnElement="SequenceFlow_0je0y25"> + <di:waypoint x="550" y="270" /> + <di:waypoint x="575" y="270" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1074" y="525" width="19" height="14" /> + <dc:Bounds x="394.5" y="159" width="90" height="12" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="EndEvent_05vw85n_di" bpmnElement="EndEvent_0ex9298"> - <dc:Bounds x="892" y="574" width="36" height="36" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_16lmcxp_di" bpmnElement="SequenceFlow_16lmcxp"> + <di:waypoint x="1280" y="270" /> + <di:waypoint x="1332" y="270" /> <bpmndi:BPMNLabel> - <dc:Bounds x="902" y="614" width="19" height="14" /> + <dc:Bounds x="1147" y="159" width="90" height="12" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_11f2c91_di" bpmnElement="Task_QuerySecondaryPolicy"> - <dc:Bounds x="720" y="552" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="StartEvent_0tmcs9g_di" bpmnElement="StartEvent_0tmcs9g"> - <dc:Bounds x="249" y="485" width="36" height="36" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1j0vskt_di" bpmnElement="SequenceFlow_1j0vskt"> + <di:waypoint x="600" y="245" /> + <di:waypoint x="600" y="174" /> + <di:waypoint x="1230" y="174" /> + <di:waypoint x="1230" y="230" /> <bpmndi:BPMNLabel> - <dc:Bounds x="127" y="521" width="0" height="0" /> + <dc:Bounds x="881" y="153" width="73" height="14" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_10v49qn_di" bpmnElement="Task_UpdateExtErrorSource"> - <dc:Bounds x="314" y="463" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_0ohzi8e_di" bpmnElement="Task_setHandlingCodeSuccessOnSkip"> - <dc:Bounds x="449" y="589" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="CallActivity_0szwp51_di" bpmnElement="PauseForManualTaskRainyDay"> - <dc:Bounds x="567" y="337" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="EndEvent_1py1er4_di" bpmnElement="EndEvent_1py1er4"> - <dc:Bounds x="354" y="611" width="36" height="36" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_19wuics_di" bpmnElement="SequenceFlow_19wuics"> + <di:waypoint x="820" y="270" /> + <di:waypoint x="860" y="270" /> <bpmndi:BPMNLabel> - <dc:Bounds x="363" y="647" width="19" height="14" /> + <dc:Bounds x="670.5" y="159" width="90" height="12" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_0z9izx5_di" bpmnElement="Task_setHandlingCodeSuccess"> - <dc:Bounds x="1113" y="140" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_1pf5f6w_di" bpmnElement="Task_PreValidate"> - <dc:Bounds x="632" y="140" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_02w4792_di" bpmnElement="Task_PostValidate"> - <dc:Bounds x="956" y="140" width="100" height="80" /> - </bpmndi:BPMNShape> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_12a4hhf_di" bpmnElement="SequenceFlow_12a4hhf"> + <di:waypoint x="1110" y="270" /> + <di:waypoint x="1180" y="270" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="989.5" y="159" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_17e9fnw_di" bpmnElement="Flow_17e9fnw"> + <di:waypoint x="375" y="270" /> + <di:waypoint x="450" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0o7fpuq_di" bpmnElement="Flow_0o7fpuq"> + <di:waypoint x="350" y="245" /> + <di:waypoint x="350" y="120" /> + <di:waypoint x="450" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="292" y="167" width="47" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1x0zdf6_di" bpmnElement="Flow_1x0zdf6"> + <di:waypoint x="500" y="160" /> + <di:waypoint x="500" y="230" /> + </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/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-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java index 1a253887dd..f215d496cf 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java @@ -50,7 +50,8 @@ public class PnfEventReadyDmaapClient implements DmaapClient { private int topicListenerDelayInSeconds; private volatile ScheduledThreadPoolExecutor executor; private volatile boolean dmaapThreadListenerIsRunning; - private String topicName; + + @Autowired public PnfEventReadyDmaapClient(Environment env) { @@ -58,31 +59,19 @@ public class PnfEventReadyDmaapClient implements DmaapClient { pnfCorrelationIdToThreadMap = new ConcurrentHashMap<>(); topicListenerDelayInSeconds = env.getProperty("pnf.dmaap.topicListenerDelayInSeconds", Integer.class); executor = null; - topicName = env.getProperty("pnf.dmaap.topicName"); - String[] topic = topicName.split("\\s"); - String pnf_ready = null; - String pnf_update = null; - for (String t : topic) { - if (t.matches("(.*)PNF_READY(.*)")) { - pnf_ready = t; - } else if (t.matches("(.*)PNF_UPDATE(.*)")) { - pnf_update = t; - } else { - return; - } - } getRequestForpnfReady = new HttpGet(UriBuilder.fromUri(env.getProperty("pnf.dmaap.uriPathPrefix")) .scheme(env.getProperty("pnf.dmaap.protocol")).host(env.getProperty("pnf.dmaap.host")) - .port(env.getProperty("pnf.dmaap.port", Integer.class)).path(pnf_ready) - .path(env.getProperty("pnf.dmaap.consumerGroup")).path(env.getProperty("pnf.dmaap.consumerId")) - .build()); + .port(env.getProperty("pnf.dmaap.port", Integer.class)) + .path(env.getProperty("pnf.dmaap.pnfReadyTopicName")).path(env.getProperty("pnf.dmaap.consumerGroup")) + .path(env.getProperty("pnf.dmaap.consumerId")).build()); getRequestForPnfUpdate = new HttpGet(UriBuilder.fromUri(env.getProperty("pnf.dmaap.uriPathPrefix")) .scheme(env.getProperty("pnf.dmaap.protocol")).host(env.getProperty("pnf.dmaap.host")) - .port(env.getProperty("pnf.dmaap.port", Integer.class)).path(pnf_update) - .path(env.getProperty("pnf.dmaap.consumerGroup")).path(env.getProperty("pnf.dmaap.consumerId")) - .build()); + .port(env.getProperty("pnf.dmaap.port", Integer.class)) + .path(env.getProperty("pnf.dmaap.pnfUpdateTopicName")).path(env.getProperty("pnf.dmaap.consumerGroup")) + .path(env.getProperty("pnf.dmaap.consumerIdUpdate")).build()); } + @Override public synchronized void registerForUpdate(String pnfCorrelationId, Runnable informConsumer) { logger.debug("registering for pnf ready dmaap event for pnf correlation id: {}", pnfCorrelationId); @@ -162,3 +151,4 @@ public class PnfEventReadyDmaapClient implements DmaapClient { } } } + diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java index 5d98464be4..bbb6aad49b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java @@ -67,9 +67,11 @@ public class PnfEventReadyDmaapClientTest { private static final int PORT = 1234; private static final String PROTOCOL = "http"; private static final String URI_PATH_PREFIX = "eventsForTesting"; - private static final String TOPIC_NAME = "PNF_READY_Test PNF_UPDATE_Test"; - private static final String CONSUMER_ID = "consumerTestId"; - private static final String CONSUMER_GROUP = "consumerGroupTest"; + private static final String TOPIC_NAME = "unauthenticated.PNF_READY"; + private static final String TOPIC_NAME_UPDATE = "unauthenticated.PNF_UPDATE"; + private static final String CONSUMER_ID = "so-bpmn-infra-pnfready"; + private static final String CONSUMER_ID_UPDATE = "so-bpmn-infra-pnfupdate"; + private static final String CONSUMER_GROUP = "so-consumer"; private static final int TOPIC_LISTENER_DELAY_IN_SECONDS = 5; @Mock @@ -87,8 +89,10 @@ public class PnfEventReadyDmaapClientTest { when(env.getProperty(eq("pnf.dmaap.host"))).thenReturn(HOST); when(env.getProperty(eq("pnf.dmaap.protocol"))).thenReturn(PROTOCOL); when(env.getProperty(eq("pnf.dmaap.uriPathPrefix"))).thenReturn(URI_PATH_PREFIX); - when(env.getProperty(eq("pnf.dmaap.topicName"))).thenReturn(TOPIC_NAME); + when(env.getProperty(eq("pnf.dmaap.pnfReadyTopicName"))).thenReturn(TOPIC_NAME); + when(env.getProperty(eq("pnf.dmaap.pnfUpdateTopicName"))).thenReturn(TOPIC_NAME_UPDATE); when(env.getProperty(eq("pnf.dmaap.consumerId"))).thenReturn(CONSUMER_ID); + when(env.getProperty(eq("pnf.dmaap.consumerIdUpdate"))).thenReturn(CONSUMER_ID_UPDATE); when(env.getProperty(eq("pnf.dmaap.consumerGroup"))).thenReturn(CONSUMER_GROUP); when(env.getProperty(eq("pnf.dmaap.topicListenerDelayInSeconds"), eq(Integer.class))) .thenReturn(TOPIC_LISTENER_DELAY_IN_SECONDS); @@ -120,15 +124,9 @@ public class PnfEventReadyDmaapClientTest { assertEquals(captor1.getValue().getURI().getHost(), HOST); assertEquals(captor1.getValue().getURI().getPort(), PORT); assertEquals(captor1.getValue().getURI().getScheme(), PROTOCOL); - String[] topic = TOPIC_NAME.split("\\s"); - String pnf_update = null; - for (String t : topic) { - if (t.matches("(.*)PNF_UPDATE(.*)")) { - pnf_update = t; - assertEquals(captor1.getValue().getURI().getPath(), - "/" + URI_PATH_PREFIX + "/" + pnf_update + "/" + CONSUMER_GROUP + "/" + CONSUMER_ID + ""); - } - } + assertEquals(captor1.getValue().getURI().getPath(), + "/" + URI_PATH_PREFIX + "/" + TOPIC_NAME_UPDATE + "/" + CONSUMER_GROUP + "/" + CONSUMER_ID_UPDATE + ""); + verify(threadMockToNotifyCamundaFlow).run(); verify(executorMock).shutdown(); } @@ -146,15 +144,11 @@ public class PnfEventReadyDmaapClientTest { assertEquals(captor1.getValue().getURI().getHost(), HOST); assertEquals(captor1.getValue().getURI().getPort(), PORT); assertEquals(captor1.getValue().getURI().getScheme(), PROTOCOL); - String[] topic = TOPIC_NAME.split("\\s"); - String pnf_ready = null; - for (String t : topic) { - if (t.matches("(.*)PNF_READY(.*)")) { - pnf_ready = t; - assertEquals(captor1.getValue().getURI().getPath(), - "/" + URI_PATH_PREFIX + "/" + pnf_ready + "/" + CONSUMER_GROUP + "/" + CONSUMER_ID + ""); - } - } + + assertEquals(captor1.getValue().getURI().getPath(), + "/" + URI_PATH_PREFIX + "/" + TOPIC_NAME + "/" + CONSUMER_GROUP + "/" + CONSUMER_ID + ""); + + verify(threadMockToNotifyCamundaFlow).run(); verify(executorMock).shutdown(); } @@ -234,4 +228,3 @@ public class PnfEventReadyDmaapClientTest { } } - diff --git a/bpmn/so-bpmn-moi/pom.xml b/bpmn/so-bpmn-moi/pom.xml new file mode 100644 index 0000000000..4f1d777766 --- /dev/null +++ b/bpmn/so-bpmn-moi/pom.xml @@ -0,0 +1,173 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>bpmn</artifactId> + <groupId>org.onap.so</groupId> + <version>1.12.1-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.onap.so</groupId> + <artifactId>so-bpmn-moi</artifactId> + <name>SO BPMN MOI</name> + <packaging>jar</packaging> + + <properties> + <maven.compiler.source>11</maven.compiler.source> + <maven.compiler.target>11</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>org.camunda.bpm.springboot</groupId> + <artifactId>camunda-bpm-spring-boot-starter</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.cloud</groupId> + <artifactId>spring-cloud-contract-wiremock</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.camunda.bpm.extension.mockito</groupId> + <artifactId>camunda-bpm-mockito</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.camunda.connect</groupId> + <artifactId>camunda-connect-connectors-all</artifactId> + </dependency> + <dependency> + <groupId>commons-beanutils</groupId> + <artifactId>commons-beanutils</artifactId> + </dependency> + <dependency> + <!-- Needed for InMemoryH2Test --> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-xml</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-json</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-jsr223</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>MSOCoreBPMN</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>mso-catalog-db</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>mso-requests-db</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so.adapters</groupId> + <artifactId>mso-adapters-rest-interface</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.6</version> + </dependency> + <dependency> + <groupId>org.onap.appc.client</groupId> + <artifactId>client-lib</artifactId> + <version>${appc.client.version}</version> + <exclusions> + <exclusion> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </exclusion> + <exclusion> + <groupId>org.powermock</groupId> + <artifactId>powermock-module-junit4</artifactId> + </exclusion> + <exclusion> + <groupId>org.powermock</groupId> + <artifactId>powermock-api-mockito</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.onap.appc.client</groupId> + <artifactId>client-kit</artifactId> + <version>${appc.client.version}</version> + <exclusions> + <exclusion> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-client</artifactId> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.inject</groupId> + <artifactId>jersey-hk2</artifactId> + <version>2.26</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.media</groupId> + <artifactId>jersey-media-json-jackson</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>uk.co.blackpepper.bowman</groupId> + <artifactId>bowman-client</artifactId> + <version>${bowman.client.version}</version> + </dependency> + <dependency> + <groupId>pl.pragmatists</groupId> + <artifactId>JUnitParams</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>ch.vorburger.mariaDB4j</groupId> + <artifactId>mariaDB4j</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <version>3.11.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>MSOCommonBPMN</artifactId> + <version>${project.version}</version> + <scope>compile</scope> + </dependency> + </dependencies> +</project> 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> serviceInstance = aaiSliceProfileUtil.getServiceInstance(execution); + + + GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock(); + + String serviceInstanceId = gBB.getServiceInstance().getServiceInstanceId(); + + List<Map<String, Object>> mapUserParams = gBB.getRequestContext().getRequestParameters().getUserParams(); + + + Attributes attributes = null; + + for (Map<String, Object> userParamData : mapUserParams) { + if (userParamData.get("nssi") != null) { + Map<String, Object> mapParam = (Map<String, Object>) 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<Map<String, Object>> mapUserParams = gBB.getRequestContext().getRequestParameters().getUserParams(); + + + Attributes attributes = null; + + for (Map<String, Object> userParamData : mapUserParams) { + if (userParamData.get("nssi") != null) { + Map<String, Object> mapParam = (Map<String, Object>) 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<Map<String, Object>> 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<ServiceInstance> 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<org.onap.so.moi.SliceProfile> sliceProfileList = new ArrayList<org.onap.so.moi.SliceProfile>(); + ServiceInstance serviceInstanceObj; + List<Relationship> listOfNssiRelationship = serviceInstance.getRelationshipList().getRelationship(); + + List<Relationship> 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<ServiceInstance> 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<Map<String, Object>> sliceProfilesData = gBB.getRequestContext().getRequestParameters().getUserParams(); + String sliceProfileIdFromRequest = mapUserParamsToSliceProfile(sliceProfilesData); + aaiSliceProfileUtil.deleteSliceProfile(execution, sliceProfileIdFromRequest); + } + + + + private String mapUserParamsToSliceProfile(List<Map<String, Object>> sliceProfilesData) + throws JsonProcessingException { + Map<String, Object> mapParam = (Map<String, Object>) sliceProfilesData.get(0).get("nssi"); + List<Object> list = (ArrayList<Object>) mapParam.get("sliceProfileList"); + Map<String, Object> idMap = (Map<String, Object>) 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<Map<String, Object>> mapUserParams = + generalBuildingBlock.getRequestContext().getRequestParameters().getUserParams(); + + Attributes attributes = null; + + for (Map<String, Object> userParamData : mapUserParams) { + if (userParamData.get("nssi") != null) { + Map<String, Object> mapParam = (Map<String, Object>) 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<String, Object> 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<Map<String, Object>> sliceProfilesData = gBB.getRequestContext().getRequestParameters().getUserParams(); + + SliceProfile updatedSliceProfile = mapUserParamsToSliceProfile(sliceProfilesData); + String sliceProfileIdFromRequest = getSliceProfileIdFromReq(sliceProfilesData); + aaiSliceProfileUtil.updateSliceProfile(execution, sliceProfileIdFromRequest, updatedSliceProfile); + + + + } + + private ServiceInstance mapUserParamsToServiceInstance(ServiceInstance sliceProfileServiceInstanceObj, + List<Map<String, Object>> sliceProfilesData) { + Map<String, Object> mapParam = (Map<String, Object>) 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<Object> list = (ArrayList<Object>) mapParam.get("sliceProfileList"); + LOGGER.info(">>> sliceProfile List: {}", list); + Map<String, Object> idMap = (Map<String, Object>) 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<Map<String, Object>> sliceProfilesData) + throws JsonProcessingException { + SliceProfile sliceProfile = new SliceProfile(); + Map<String, Object> mapParam = (Map<String, Object>) sliceProfilesData.get(0).get("nssi"); + LOGGER.info(">>> mapParam in map: {}", mapParam); + + List<Object> list = (ArrayList<Object>) mapParam.get("sliceProfileList"); + + Map<String, Object> idMap = (Map<String, Object>) 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<String, Object> ranMap = (Map<String, Object>) 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<Map<String, Object>> sliceProfilesData) + throws JsonProcessingException { + Map<String, Object> mapParam = (Map<String, Object>) sliceProfilesData.get(0).get("nssi"); + + List<Object> list = (ArrayList<Object>) mapParam.get("sliceProfileList"); + + Map<String, Object> idMap = (Map<String, Object>) 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<ServiceInstance> 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<ServiceInstance> getServiceInstance = getServiceInstance(execution); + if (getServiceInstance.isPresent()) { + ServiceInstance serviceInstance = getServiceInstance.get(); + String NssiId = serviceInstance.getServiceInstanceId(); + LOGGER.info("NSSID {}", NssiId); + List<Relationship> listOfNssiRelationship = serviceInstance.getRelationshipList().getRelationship(); + + List<Relationship> listOfNssiRelationshipAR = listOfNssiRelationship.stream() + .filter(relationship -> relationship.getRelatedTo().equalsIgnoreCase("allotted-resource")) + .collect(Collectors.toList()); + int size = listOfNssiRelationshipAR.size(); + + List<SliceProfile> 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<ServiceInstance> 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<Map<String, Object>> sliceProfilesData = gBB.getRequestContext().getRequestParameters().getUserParams(); + LOGGER.info(">>> mapParam: {}", sliceProfilesData); + + Optional<ServiceInstance> getServiceInstance = getServiceInstance(execution); + if (getServiceInstance.isPresent()) { + ServiceInstance serviceInstance = getServiceInstance.get(); + List<Relationship> listOfNssiRelationship = serviceInstance.getRelationshipList().getRelationship(); + + List<Relationship> listOfNssiRelationshipAR = listOfNssiRelationship.stream() + .filter(relationship -> relationship.getRelatedTo().equalsIgnoreCase("allotted-resource")) + .collect(Collectors.toList()); + + List<SliceProfile> 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<ServiceInstance> sliceProfile1 = aaiRestClient + .getServiceInstanceByIdWithDepth(sliceProfileInstanceId, "5G", "5GCustomer"); + + Optional<ServiceInstance> 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<Map<String, Object>> sliceProfilesData) { + Map<String, Object> mapParam = (Map<String, Object>) 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<Object> list = (ArrayList<Object>) mapParam.get("sliceProfileList"); + LOGGER.info(">>> sliceProfile List: {}", list); + Map<String, Object> idMap = (Map<String, Object>) 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_10wwk7p" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.1.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.17.0"> + <bpmn:process id="ActivateRANNssiBB" name="ActivateRANNssiBB" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>Flow_05e75ml</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:endEvent id="Event_1ydoy4n"> + <bpmn:incoming>Flow_1wiu58e</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_05e75ml" sourceRef="StartEvent_1" targetRef="Activity_0xvx6k0" /> + <bpmn:serviceTask id="Activity_0xvx6k0" name="Activate Nssi" camunda:expression="${AssignRANNssiBBTasks.activateNssi(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>Flow_05e75ml</bpmn:incoming> + <bpmn:outgoing>Flow_1wiu58e</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1wiu58e" sourceRef="Activity_0xvx6k0" targetRef="Event_1ydoy4n" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ActivateRANNssiBB"> + <bpmndi:BPMNEdge id="Flow_1wiu58e_di" bpmnElement="Flow_1wiu58e"> + <di:waypoint x="370" y="100" /> + <di:waypoint x="452" y="100" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_05e75ml_di" bpmnElement="Flow_05e75ml"> + <di:waypoint x="188" y="100" /> + <di:waypoint x="270" y="100" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="152" y="82" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1ydoy4n_di" bpmnElement="Event_1ydoy4n"> + <dc:Bounds x="452" y="82" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0a88ka0_di" bpmnElement="Activity_0xvx6k0"> + <dc:Bounds x="270" y="60" width="100" height="80" /> + <bpmndi:BPMNLabel /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_18uqst7" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.1.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.17.0"> + <bpmn:process id="AssignRANNssiBB" name="AssignRANNssiBB" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>Flow_07dyds8</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:endEvent id="Event_1u6nifv"> + <bpmn:incoming>Flow_1jwhdm2</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_07dyds8" sourceRef="StartEvent_1" targetRef="Tast_PrepareOOFrequest" /> + <bpmn:serviceTask id="Tast_PrepareOOFrequest" name="Prepare OOF request" camunda:expression="${AssignRANNssiBBTasks.helloWorld(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>Flow_07dyds8</bpmn:incoming> + <bpmn:outgoing>Flow_1erbnfk</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1erbnfk" sourceRef="Tast_PrepareOOFrequest" targetRef="Activity_0crrz1x" /> + <bpmn:sequenceFlow id="Flow_1trcgyv" sourceRef="Task_createNSSIinAAI" targetRef="Task_CreateSliceProfileInstance" /> + <bpmn:serviceTask id="Task_createNSSIinAAI" name="Create NSSI in AAI" camunda:expression="${AssignRANNssiBBTasks.createNssi(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>Flow_1svksq9</bpmn:incoming> + <bpmn:outgoing>Flow_1trcgyv</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_08asmxy" sourceRef="Task_Createallotted-resourcesinAAI" targetRef="Task_AddSlice-profilerelationshipwithNSSI" /> + <bpmn:sequenceFlow id="Flow_1ut0avh" sourceRef="Task_CreateSliceProfileInstance" targetRef="Task_Createallotted-resourcesinAAI" /> + <bpmn:sequenceFlow id="Flow_1jwhdm2" sourceRef="Task_AddSlice-profilerelationshipwithNSSI" targetRef="Event_1u6nifv" /> + <bpmn:serviceTask id="Task_Createallotted-resourcesinAAI" name="Create allotted-resources in AAI" camunda:expression="${AssignRANNssiBBTasks.allotResources(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>Flow_1ut0avh</bpmn:incoming> + <bpmn:outgoing>Flow_08asmxy</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:serviceTask id="Task_CreateSliceProfileInstance" name="Create Slice Profile Instance" camunda:expression="${AssignRANNssiBBTasks.createSliceProfileInstance(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>Flow_1trcgyv</bpmn:incoming> + <bpmn:outgoing>Flow_1ut0avh</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:serviceTask id="Task_AddSlice-profilerelationshipwithNSSI" name="Add Slice-profile relationship with NSSI" camunda:expression="${AssignRANNssiBBTasks.addSliceProfileToNssi(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>Flow_08asmxy</bpmn:incoming> + <bpmn:outgoing>Flow_1jwhdm2</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1svksq9" sourceRef="Activity_0crrz1x" targetRef="Task_createNSSIinAAI" /> + <bpmn:serviceTask id="Activity_0crrz1x" name="Process OOF response" camunda:expression="${AssignRANNssiBBTasks.processOof(execution, InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>Flow_1erbnfk</bpmn:incoming> + <bpmn:outgoing>Flow_1svksq9</bpmn:outgoing> + </bpmn:serviceTask> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="AssignRANNssiBB"> + <bpmndi:BPMNEdge id="Flow_1svksq9_di" bpmnElement="Flow_1svksq9"> + <di:waypoint x="530" y="100" /> + <di:waypoint x="590" y="100" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1jwhdm2_di" bpmnElement="Flow_1jwhdm2"> + <di:waypoint x="1150" y="100" /> + <di:waypoint x="1202" y="100" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1ut0avh_di" bpmnElement="Flow_1ut0avh"> + <di:waypoint x="840" y="100" /> + <di:waypoint x="890" y="100" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_08asmxy_di" bpmnElement="Flow_08asmxy"> + <di:waypoint x="990" y="100" /> + <di:waypoint x="1050" y="100" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1trcgyv_di" bpmnElement="Flow_1trcgyv"> + <di:waypoint x="690" y="100" /> + <di:waypoint x="740" y="100" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1erbnfk_di" bpmnElement="Flow_1erbnfk"> + <di:waypoint x="360" y="100" /> + <di:waypoint x="430" y="100" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_07dyds8_di" bpmnElement="Flow_07dyds8"> + <di:waypoint x="188" y="100" /> + <di:waypoint x="260" y="100" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="152" y="82" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1u6nifv_di" bpmnElement="Event_1u6nifv"> + <dc:Bounds x="1202" y="82" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0m2rb7h_di" bpmnElement="Task_createNSSIinAAI"> + <dc:Bounds x="590" y="60" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_15uwt50_di" bpmnElement="Task_AddSlice-profilerelationshipwithNSSI"> + <dc:Bounds x="1050" y="60" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_182lm7y_di" bpmnElement="Task_Createallotted-resourcesinAAI"> + <dc:Bounds x="890" y="60" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0a88ka0_di" bpmnElement="Tast_PrepareOOFrequest"> + <dc:Bounds x="260" y="60" width="100" height="80" /> + <bpmndi:BPMNLabel /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ornhso_di" bpmnElement="Activity_0crrz1x"> + <dc:Bounds x="430" y="60" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1p2gzmo_di" bpmnElement="Task_CreateSliceProfileInstance"> + <dc:Bounds x="740" y="60" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_18uqst7" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.2.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.17.0"> + <bpmn:process id="DeleteRANNssiBB" name="DeleteRANNssiBB" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>Flow_07dyds8</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:endEvent id="Event_1u6nifv"> + <bpmn:incoming>Flow_1trcgyv</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_07dyds8" sourceRef="StartEvent_1" targetRef="DeleteSliceProfileList" /> + <bpmn:sequenceFlow id="Flow_1trcgyv" sourceRef="DeleteSliceProfileList" targetRef="Event_1u6nifv" /> + <bpmn:serviceTask id="DeleteSliceProfileList" name="Delete Slice Profile List" camunda:expression="${DeleteRANNssiBBTask.deleteNssi(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>Flow_07dyds8</bpmn:incoming> + <bpmn:outgoing>Flow_1trcgyv</bpmn:outgoing> + </bpmn:serviceTask> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeleteRANNssiBB"> + <bpmndi:BPMNEdge id="Flow_1trcgyv_di" bpmnElement="Flow_1trcgyv"> + <di:waypoint x="470" y="100" /> + <di:waypoint x="552" y="100" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_07dyds8_di" bpmnElement="Flow_07dyds8"> + <di:waypoint x="188" y="100" /> + <di:waypoint x="370" y="100" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_1u6nifv_di" bpmnElement="Event_1u6nifv"> + <dc:Bounds x="552" y="82" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0m2rb7h_di" bpmnElement="DeleteSliceProfileList"> + <dc:Bounds x="370" y="60" width="100" height="80" /> + <bpmndi:BPMNLabel /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="152" y="82" width="36" height="36" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_042zahe" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.1.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.17.0"> + <bpmn:process id="EnrichGBB" name="EnrichGBB" isExecutable="true" camunda:versionTag="1"> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>Flow_00l5u3m</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:callActivity id="Activity_0sqn8c7" name="Call DoHandleOofRequest" calledElement="DoHandleOofRequest"> + <bpmn:extensionElements> + <camunda:in source="NSST_apiPath" target="apiPath" /> + <camunda:in source="NSST_correlator" target="correlator" /> + <camunda:in source="NSST_messageType" target="messageType" /> + <camunda:in source="NSST_timeout" target="timeout" /> + <camunda:in source="NSST_oofRequest" target="oofRequest" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="asyncCallbackResponse" target="NSST_asyncCallbackResponse" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1r5aycw</bpmn:incoming> + <bpmn:outgoing>Flow_1navrbe</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_1r5aycw" sourceRef="ScriptTask_0ybe0w9" targetRef="Activity_0sqn8c7" /> + <bpmn:sequenceFlow id="Flow_1navrbe" sourceRef="Activity_0sqn8c7" targetRef="ScriptTask_1bg09vu" /> + <bpmn:sequenceFlow id="Flow_00l5u3m" sourceRef="StartEvent_1" targetRef="ScriptTask_0ybe0w9" /> + <bpmn:endEvent id="Event_1itf4bg"> + <bpmn:incoming>Flow_1xiq8re</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_1xiq8re" sourceRef="ScriptTask_1bg09vu" targetRef="Event_1itf4bg" /> + <bpmn:serviceTask id="ScriptTask_0ybe0w9" name="Prepare OOF request" camunda:expression="${EnrichGBBTask.prepareOofRequest(execution)}"> + <bpmn:incoming>Flow_00l5u3m</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1r5aycw</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:serviceTask id="ScriptTask_1bg09vu" name="Process OOF Async ressponse" camunda:expression="${EnrichGBBTask.processOOFAsyncResponse(execution)}"> + <bpmn:incoming>Flow_1navrbe</bpmn:incoming> + <bpmn:outgoing>Flow_1xiq8re</bpmn:outgoing> + </bpmn:serviceTask> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="EnrichGBB"> + <bpmndi:BPMNEdge id="Flow_1xiq8re_di" bpmnElement="Flow_1xiq8re"> + <di:waypoint x="760" y="120" /> + <di:waypoint x="832" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_00l5u3m_di" bpmnElement="Flow_00l5u3m"> + <di:waypoint x="158" y="120" /> + <di:waypoint x="310" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1navrbe_di" bpmnElement="Flow_1navrbe"> + <di:waypoint x="580" y="116" /> + <di:waypoint x="660" y="116" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1r5aycw_di" bpmnElement="SequenceFlow_1r5aycw"> + <di:waypoint x="410" y="120" /> + <di:waypoint x="480" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="470.5" y="163" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="BPMNShape_1aru9st" bpmnElement="Activity_0sqn8c7"> + <dc:Bounds x="480" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1itf4bg_di" bpmnElement="Event_1itf4bg"> + <dc:Bounds x="832" y="102" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1wzhzok_di" bpmnElement="ScriptTask_0ybe0w9"> + <dc:Bounds x="310" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1t8o2pj_di" bpmnElement="ScriptTask_1bg09vu"> + <dc:Bounds x="660" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="122" y="102" width="36" height="36" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_18uqst7" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.2.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.17.0"> + <bpmn:process id="Task_ModifyRANNssiBB" name="ModifyRANNssiBB" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>Flow_07dyds8</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:endEvent id="Event_1u6nifv"> + <bpmn:incoming>Flow_1trcgyv</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_07dyds8" sourceRef="StartEvent_1" targetRef="Task_ModifyDetailsinAAI" /> + <bpmn:sequenceFlow id="Flow_1trcgyv" sourceRef="Task_ModifyDetailsinAAI" targetRef="Event_1u6nifv" /> + <bpmn:serviceTask id="Task_ModifyDetailsinAAI" name="Modify Details in AAI" camunda:expression="${ModifyRANNssiBBTask.modifyNssi(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>Flow_07dyds8</bpmn:incoming> + <bpmn:outgoing>Flow_1trcgyv</bpmn:outgoing> + </bpmn:serviceTask> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Task_ModifyRANNssiBB"> + <bpmndi:BPMNEdge id="Flow_1trcgyv_di" bpmnElement="Flow_1trcgyv"> + <di:waypoint x="460" y="100" /> + <di:waypoint x="682" y="100" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_07dyds8_di" bpmnElement="Flow_07dyds8"> + <di:waypoint x="188" y="100" /> + <di:waypoint x="360" y="100" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="152" y="82" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1u6nifv_di" bpmnElement="Event_1u6nifv"> + <dc:Bounds x="682" y="82" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0m2rb7h_di" bpmnElement="Task_ModifyDetailsinAAI"> + <dc:Bounds x="360" y="60" width="100" height="80" /> + <bpmndi:BPMNLabel /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> 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<BuildingBlockExecution> { + 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<BuildingBlockExecution> context) { + String scope = context.getControllerScope(); + return CDS_ACTOR.equalsIgnoreCase(context.getControllerActor()) && NSSI_SCOPE.equalsIgnoreCase(scope); + } + + @Override + public Boolean ready(ControllerContext<BuildingBlockExecution> context) { + return true; + } + + @Override + public void prepare(ControllerContext<BuildingBlockExecution> 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<BuildingBlockExecution> 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<Resource> setNetworkSliceSubnetResource(String serviceId) { + Resource networkSliceSubnetResource = new Resource(WorkflowType.NETWORK_SLICE_SUBNET, serviceId, false, null); + List<Resource> 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; diff --git a/docs/api/apis/serviceInstances-api.rst b/docs/api/apis/serviceInstances-api.rst index 15ed3932fd..6f7e787207 100644 --- a/docs/api/apis/serviceInstances-api.rst +++ b/docs/api/apis/serviceInstances-api.rst @@ -25,6 +25,8 @@ links: - :ref:`delete_vf_module` - :ref:`create_vnf` - :ref:`delete_vnf` +- :ref:`create_cnf` +- :ref:`delete_cnf` - :ref:`get_orchestration_request_by_id` - :ref:`get_orchestration_request_all` - :ref:`healthCheck` @@ -941,6 +943,244 @@ UserParams Object |value |String |Value of the tag | +-------------------------+------------------+-------------------------------------------------+ +.. _create_cnf: + +Create CNF +++++++++++ + ++--------------------+-------------------------------------------------------------------------------------+ +|Interface Definition|Description | ++====================+=====================================================================================+ +|URI |/onap/so/infra/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}/cnfs | ++--------------------+-------------------------------------------------------------------------------------+ +|Operation Type |POST | ++--------------------+-------------------------------------------------------------------------------------+ +|Content-Type |application/json | ++--------------------+-------------------------------------------------------------------------------------+ + +Request Headers: + ++-------------------+---------+-----------------------------------------------------------------------------------------+ +|Header Name |Required |Description | ++===================+=========+=========================================================================================+ +|Authorization |Y |Base64 encoded username:password | ++-------------------+---------+-----------------------------------------------------------------------------------------+ + +Request Body: + ++----------------+---------+-----------+--------------------------+-------------------------------------------+ +|Attribute |Qualifier|Cardinality|Content |Description | ++================+=========+===========+==========================+===========================================+ +|requestDetails |M |1 |requestDetails Object |Content of requestDetails object. | ++----------------+---------+-----------+--------------------------+-------------------------------------------+ + +RequestDetails Object + ++-------------------+--------------------------+-------------------------------------------------+ +|Attribute |Content |Description | ++===================+==========================+=================================================+ +|modelInfo |modelInfo Object |Content of modelInfo object. | ++-------------------+--------------------------+-------------------------------------------------+ +|requestInfo |requestInfo Object |Content of requestInfo object. | ++-------------------+--------------------------+-------------------------------------------------+ +|requestParameters |requestParameters Object |Content of requestParameters object. | ++-------------------+--------------------------+-------------------------------------------------+ +|relatedInstanceList|relatedInstanceList Object|Content of relatedInstanceList object. | ++-------------------+--------------------------+-------------------------------------------------+ +|cloudConfiguration |cloudConfiguration Object |Content of cloudConfiguration object. | ++-------------------+--------------------------+-------------------------------------------------+ +|platform |platform Object |Content of platform object. | ++-------------------+--------------------------+-------------------------------------------------+ +|lineOfBusiness |lineOfBusiness Object |Content of lineOfBusiness object. | ++-------------------+--------------------------+-------------------------------------------------+ + +ModelInfo Object + ++-------------------------+------------------+-------------------------------------------------+ +|Attribute |Content |Description | ++=========================+==================+=================================================+ +|modelType |String |Type of model | ++-------------------------+------------------+-------------------------------------------------+ +|modelInvariantId |String |The Model Invariant Id. | ++-------------------------+------------------+-------------------------------------------------+ +|modelName |String |Name of the Model | ++-------------------------+------------------+-------------------------------------------------+ +|modelVersion |String |Version of the model | ++-------------------------+------------------+-------------------------------------------------+ +|modelCustomizationName |String |The Model Customization name | ++-------------------------+------------------+-------------------------------------------------+ +|modelVersionId |String |The Model version id | ++-------------------------+------------------+-------------------------------------------------+ + +CloudConfiguration Object + ++-------------------------+------------------+-------------------------------------------------+ +|Attribute |Content |Description | ++=========================+==================+=================================================+ +|lcpCloudRegionId |String |CloudRegion Id (in A&AI) | ++-------------------------+------------------+-------------------------------------------------+ +|tenantId |String |Name of the Subscriber | ++-------------------------+------------------+-------------------------------------------------+ +|cloudOwner |String |Name of the cloud owner | ++-------------------------+------------------+-------------------------------------------------+ + +RequestInfo Object + ++-------------------------+------------------+-------------------------------------------------+ +|Attribute |Content |Description | ++=========================+==================+=================================================+ +|source |String |source of the request | ++-------------------------+------------------+-------------------------------------------------+ +|productFamilyId |String |productFamilyId of the request | ++-------------------------+------------------+-------------------------------------------------+ +|instanceName |String |instanceName of the request | ++-------------------------+------------------+-------------------------------------------------+ +|suppressRollback |String |suppressRollback of the request | ++-------------------------+------------------+-------------------------------------------------+ +|requestorId |String |requestorId of the request | ++-------------------------+------------------+-------------------------------------------------+ + +relatedInstance List + ++-------------------------+------------------+-------------------------------------------------+ +|Attribute |Content |Description | ++=========================+==================+=================================================+ +|relatedInstance |Object |relatedInstance Object | ++-------------------------+------------------+-------------------------------------------------+ + +relatedInstance List + ++-------------------------+------------------+-------------------------------------------------+ +|Attribute |Content |Description | ++=========================+==================+=================================================+ +|instanceId |String |instanceId | ++-------------------------+------------------+-------------------------------------------------+ +|modelInfo |Object |Content of modelInfo object. | ++-------------------------+------------------+-------------------------------------------------+ + +RequestParameters Object + ++-------------------------+------------------+-------------------------------------------------+ +|Attribute |Content |Description | ++=========================+==================+=================================================+ +|userParams |Array |The product family Id. | ++-------------------------+------------------+-------------------------------------------------+ + +UserParams Object + ++-------------------------+------------------+-------------------------------------------------+ +|Attribute |Content |Description | ++=========================+==================+=================================================+ +|name |String |Tag name of attribute | ++-------------------------+------------------+-------------------------------------------------+ +|value |String |Value of the tag | ++-------------------------+------------------+-------------------------------------------------+ + +.. _delete_cnf: + +Delete CNF +++++++++++ + ++--------------------+-----------------------------------------------------------------------------------------------------+ +|Interface Definition|Description | ++====================+=====================================================================================================+ +|URI |/onap/so/infra/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}/cnfs/{cnfInstanceId} | ++--------------------+-----------------------------------------------------------------------------------------------------+ +|Operation Type |DELETE | ++--------------------+-----------------------------------------------------------------------------------------------------+ +|Content-Type |application/json | ++--------------------+-----------------------------------------------------------------------------------------------------+ + +Request Headers: + ++-------------------+---------+-----------------------------------------------------------------------------------------+ +|Header Name |Required |Description | ++===================+=========+=========================================================================================+ +|Authorization |Y |Base64 encoded username:password | ++-------------------+---------+-----------------------------------------------------------------------------------------+ + +Request Body: + ++----------------+---------+-----------+--------------------------+-------------------------------------------+ +|Attribute |Qualifier|Cardinality|Content |Description | ++================+=========+===========+==========================+===========================================+ +|requestDetails |M |1 |requestDetails Object |Content of requestDetails object. | ++----------------+---------+-----------+--------------------------+-------------------------------------------+ + +RequestDetails Object + ++---------------------+-------------------------+-------------------------------------------------+ +|Attribute |Content |Description | ++=====================+=========================+=================================================+ +|modelInfo |modelInfo Object |Content of modelInfo object. | ++---------------------+-------------------------+-------------------------------------------------+ +|cloudConfiguration |cloudConfiguration Object|Content of cloudConfiguration object. | ++---------------------+-------------------------+-------------------------------------------------+ +|requestInfo |requestInfo Object |Content of requestInfo object. | ++---------------------+-------------------------+-------------------------------------------------+ +|requestParameters |requestParameters Object |Content of requestParameters object. | ++---------------------+-------------------------+-------------------------------------------------+ + +ModelInfo Object + ++-------------------------+------------------+-------------------------------------------------+ +|Attribute |Content |Description | ++=========================+==================+=================================================+ +|modelType |String |Type of model | ++-------------------------+------------------+-------------------------------------------------+ +|modelName |String |Name of the Model | ++-------------------------+------------------+-------------------------------------------------+ +|modelVersionId |String |The Model version id | ++-------------------------+------------------+-------------------------------------------------+ +|modelInvariantId |String |The Model Invariant Id. | ++-------------------------+------------------+-------------------------------------------------+ +|modelVersion |String |Version of the model | ++-------------------------+------------------+-------------------------------------------------+ +|modelCustomizationName |String |The Model Customization name | ++-------------------------+------------------+-------------------------------------------------+ +|modelCustomizationId |String |The Model Customization Id. | ++-------------------------+------------------+-------------------------------------------------+ + +CloudConfiguration Object + ++-------------------------+------------------+-------------------------------------------------+ +|Attribute |Content |Description | ++=========================+==================+=================================================+ +|lcpCloudRegionId |String |CloudRegion Id (in A&AI) | ++-------------------------+------------------+-------------------------------------------------+ +|tenantId |String |Name of the Subscriber | ++-------------------------+------------------+-------------------------------------------------+ +|cloudOwner |String |Name of the cloud owner | ++-------------------------+------------------+-------------------------------------------------+ + +RequestInfo Object + ++-------------------------+------------------+-------------------------------------------------+ +|Attribute |Content |Description | ++=========================+==================+=================================================+ +|source |String |source of the request | ++-------------------------+------------------+-------------------------------------------------+ +|requestId |String |request Id | ++-------------------------+------------------+-------------------------------------------------+ + +RequestParameters Object + ++-------------------------+------------------+-------------------------------------------------+ +|Attribute |Content |Description | ++=========================+==================+=================================================+ +|UserParams |Array |The product family Id. | ++-------------------------+------------------+-------------------------------------------------+ + +UserParams Object + ++-------------------------+------------------+-------------------------------------------------+ +|Attribute |Content |Description | ++=========================+==================+=================================================+ +|name |String |Tag name of attribute | ++-------------------------+------------------+-------------------------------------------------+ +|value |String |Value of the tag | ++-------------------------+------------------+-------------------------------------------------+ + .. _get_orchestration_request_by_id: GET Orchestration Request diff --git a/docs/developer_info/ASD_Overview.rst b/docs/developer_info/ASD_Overview.rst new file mode 100644 index 0000000000..bb38f01749 --- /dev/null +++ b/docs/developer_info/ASD_Overview.rst @@ -0,0 +1,47 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright 2017 Huawei Technologies Co., Ltd. + +ASD Architecture +======================= + +ASD Overview +------------- +Application Service Descriptor (ASD) is a deployment descriptor for cloud native application/functions. It seeks to provide deployment using the minimum information needed by the orchestrator. +The CSAR package adheres to ETSI SOL004. +ASD minimizes duplication whilst leveraging the management capabilities of the Kubernets platfor. It provides a clear separation between high level orchestration and cloud native application deployment. + +ASD Architecture Overview +--------------------------- + +The following diagram depicts the ASD high-level architecture: + +CreateVfModuleVolumeInfraV1 is a main process flow. + +.. image:: ../images/asd_architecture.png + +`ASD POC wiki page <https://wiki.onap.org/display/DW/ASD+Onboarding+and+Orchestration+PoC>`_ + +ASD Onboarding +--------------------- + +The following diagram depicts the ASD onboarding to ONAP SDC: + +.. image:: ../images/asd_onboarding.png + +ASD Orchestration by ONAP SO +--------------------------------- + +The following diagram depicts the ASD Orchestration by ONAP SO: + +.. image:: ../images/asd_orchestration.png + +`AS LCM RESTful Protocols <https://wiki.onap.org/display/DW/AS+LCM+RESTful+Protocols+for+SO+CNFM+Manager>`_ + +SO CNFM +----------- + +The following diagram depicts the SO CNFM, an SO Plug-in component: + +.. image:: ../images/asd_cnfm.png + diff --git a/docs/developer_info/developer_information.rst b/docs/developer_info/developer_information.rst index 3f72b4bcf6..1c65f83545 100644 --- a/docs/developer_info/developer_information.rst +++ b/docs/developer_info/developer_information.rst @@ -32,4 +32,5 @@ SO Developer Information ETSI_CSIT_NFVO_VNFM.rst ETSI_NFVO_Network_Service_LCM_Setup_Guide.rst ETSI_VNF_LCM_Setup_Guide.rst + ASD_Overview.rst FAQs.rst diff --git a/docs/images/asd_architecture.png b/docs/images/asd_architecture.png Binary files differnew file mode 100644 index 0000000000..2fad790cdc --- /dev/null +++ b/docs/images/asd_architecture.png diff --git a/docs/images/asd_cnfm.png b/docs/images/asd_cnfm.png Binary files differnew file mode 100644 index 0000000000..da19ad5060 --- /dev/null +++ b/docs/images/asd_cnfm.png diff --git a/docs/images/asd_onboarding.png b/docs/images/asd_onboarding.png Binary files differnew file mode 100644 index 0000000000..297eff4422 --- /dev/null +++ b/docs/images/asd_onboarding.png diff --git a/docs/images/asd_orchestration.png b/docs/images/asd_orchestration.png Binary files differnew file mode 100644 index 0000000000..0cfcb1cab0 --- /dev/null +++ b/docs/images/asd_orchestration.png diff --git a/docs/tox.ini b/docs/tox.ini index 9b45c816d9..833cd33adc 100644 --- a/docs/tox.ini +++ b/docs/tox.ini @@ -12,7 +12,7 @@ deps = commands = sphinx-build -W -q -b html -n -d {envtmpdir}/doctrees ./ {toxinidir}/_build/html echo "Generated docs available in {toxinidir}/_build/html" -whitelist_externals = +allowlist_externals = echo git sh @@ -25,7 +25,7 @@ deps = -chttps://git.onap.org/doc/plain/etc/upper-constraints.onap.txt commands = echo "Link Checking not enforced" #commands = sphinx-build -W -q -b linkcheck -d {envtmpdir}/doctrees ./ {toxinidir}/_build/linkcheck -whitelist_externals = echo +allowlist_externals = echo [testenv:docs-spellcheck] basepython = python3.8 diff --git a/releases/1.12.1.yaml b/releases/1.12.1.yaml new file mode 100644 index 0000000000..be5af0de2f --- /dev/null +++ b/releases/1.12.1.yaml @@ -0,0 +1,22 @@ + +--- +distribution_type: 'container' +container_release_tag: '1.12.1' +project: 'so' +log_dir: 'so-maven-docker-stage-master/1428/' +ref: '0f7d74f6be3b182654f726b2b815a8290da08a88' +containers: + - name: 'so/catalog-db-adapter' + version: '1.12.1-20230424T1507' + - name: 'so/request-db-adapter' + version: '1.12.1-20230424T1507' + - name: 'so/openstack-adapter' + version: '1.12.1-20230424T1507' + - name: 'so/sdnc-adapter' + version: '1.12.1-20230424T1507' + - name: 'so/sdc-controller' + version: '1.12.1-20230424T1507' + - name: 'so/bpmn-infra' + version: '1.12.1-20230424T1507' + - name: 'so/api-handler-infra' + version: '1.12.1-20230424T1507' |