diff options
author | Reshmasree <reshmasree.chamarthi2@wipro.com> | 2020-09-02 08:30:19 -0700 |
---|---|---|
committer | Reshmasree <reshmasree.chamarthi2@wipro.com> | 2020-09-06 06:10:28 -0700 |
commit | 521f95dfd4328eeb4c1634317ed33888ba7cc5a0 (patch) | |
tree | fd92317d8fb88523583e2d1fef2059d3870e5cad /bpmn | |
parent | f99da95f1f808d05e25e041e84e030612a43561d (diff) |
Implement subprocess for calling SDNR from RAN NSSMF
-Also added common methods in oofUtils
Issue-ID: SO-3215
Signed-off-by: Reshmasree <reshmasree.chamarthi2@wipro.com>
Change-Id: Id85112db648f6607d7075da857a45e1ed5ca23ec
Diffstat (limited to 'bpmn')
4 files changed, 315 insertions, 1 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 2c96e7d3bb..040fc26f23 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 @@ -42,6 +42,7 @@ import org.onap.so.db.catalog.beans.CloudSite import org.onap.so.db.catalog.beans.HomingInstance import org.slf4j.Logger import org.slf4j.LoggerFactory +import com.google.gson.JsonObject import com.fasterxml.jackson.databind.ObjectMapper @@ -571,5 +572,82 @@ class OofUtils { response.append("\n }\n") return response.toString() } - +/** +* Method to create select NSSI request +* @param requestId - mso-request-id +* @param messageType - Message type for callback correlation +* @param UUID - UUID of NSST +* @param invariantUUID - Invariant UUID of NSST +* @param name - name of the NSST model +* @param profileInfo - A JSON object containing slice profile parameters +* @return +*/ +public String buildSelectNSSIRequest(String requestId, String messageType, String UUID,String invariantUUID, +String name, 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 profileJson = objectMapper.writeValueAsString(profileInfo); + +//Prepare requestInfo object +JsonObject requestInfo = new JsonObject() +requestInfo.addProperty("transactionId", transactionId) +requestInfo.addProperty("requestId", requestId) +requestInfo.addProperty("callbackUrl", callbackUrl) +requestInfo.addProperty("sourceId","SO" ) +requestInfo.addProperty("timeout", 600) +requestInfo.addProperty("numSolutions", 1) + +//Prepare serviceInfo object +JsonObject nsstInfo = new JsonObject() +nsstInfo.addProperty("UUID", UUID) +nsstInfo.addProperty("invariantUUID", invariantUUID) +nsstInfo.addProperty("name", name) + +JsonObject json = new JsonObject() +json.add("requestInfo", requestInfo) +json.add("NSSTInfo", nsstInfo) +json.addProperty("sliceProfile", profileJson) +return json.toString() +} +/** +* Method to create NSI/NSSI termination request +* (OOF response will be synchronous in G-Release) +* @param requestId - mso-request-id +* @param nxlId - NSI/NSSI Id to be terminated +* @param messageType - Message type for callback correlation +* @param serviceInstanceId - NSI/NSSI Id related to nxlId +* @return +*/ +public String buildTerminateNxiRequest(String requestId,String nxlId, String nxlType, String messageType, String serviceInstanceId) { +def transactionId = requestId +logger.debug( "transactionId is: " + transactionId) +String correlator = requestId +String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator +//Prepare Terminate Nxl Json +JsonObject json = new JsonObject() +json.addProperty("type", nxlType) +json.addProperty("NxIId", nxlId) + +//Prepare requestInfo object +JsonObject requestInfo = new JsonObject() +requestInfo.addProperty("transactionId", transactionId) +requestInfo.addProperty("requestId", requestId) +requestInfo.addProperty("callbackUrl", callbackUrl) +requestInfo.addProperty("sourceId","SO" ) +requestInfo.addProperty("timeout", 600) + +//Prepare addtnlArgs object +JsonObject addtnlArgs = new JsonObject() +addtnlArgs.addProperty("serviceInstanceId", serviceInstanceId) + +requestInfo.add("addtnlArgs", addtnlArgs) +json.add("requestInfo", requestInfo) + +return json.toString() + +} } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/SdnrDmaapPublisher.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/SdnrDmaapPublisher.java new file mode 100644 index 0000000000..0f35b38f72 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/SdnrDmaapPublisher.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.dmaapproperties; + +import java.io.IOException; +import java.util.Optional; +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.client.dmaap.DmaapPublisher; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +@Component +@Scope("prototype") +public class SdnrDmaapPublisher extends DmaapPublisher { + + + public SdnrDmaapPublisher() throws IOException { + super(); + } + + @Override + public String getAuth() { + + return UrnPropertiesReader.getVariable("mso.global.dmaap.auth"); + } + + @Override + public String getKey() { + + return UrnPropertiesReader.getVariable("mso.msoKey"); + } + + @Override + public String getTopic() { + return UrnPropertiesReader.getVariable("sdnc.dmaap.publisher.topic"); + } + + @Override + public Optional<String> getHost() { + return Optional.ofNullable(UrnPropertiesReader.getVariable("sdnc.dmaap.host")); + } +} + + diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SendRequestToSdnr.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SendRequestToSdnr.java new file mode 100644 index 0000000000..d9656f7ea2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SendRequestToSdnr.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.sdnc.common; + +import static org.onap.so.bpmn.common.scripts.GenericUtils.isBlank; +import javax.inject.Provider; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.so.bpmn.common.scripts.ExceptionUtil; +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.client.dmaapproperties.SdnrDmaapPublisher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component("SendRequestToSdnr") +public class SendRequestToSdnr implements JavaDelegate { + private static final Logger logger = LoggerFactory.getLogger(SendRequestToSdnr.class); + ExceptionUtil exceptionUtil = new ExceptionUtil(); + + @Autowired + private Provider<SdnrDmaapPublisher> sdnrDmaapPublisher; + + @Override + public void execute(DelegateExecution execution) throws Exception { + + logger.debug("SendRequestToSdnr_start"); + + String requestId = (String) execution.getVariable("correlator"); + if (isBlank(requestId)) { + String msg = "Cannot process SDNR Request : correlator is null"; + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg); + } + + String messageType = (String) execution.getVariable("messageType"); + if (isBlank(messageType)) { + String msg = "Cannot process SDNR Request : messageType is null"; + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg); + } + + String timeout = (String) execution.getVariable("timeout"); + if (isBlank(timeout)) { + timeout = UrnPropertiesReader.getVariable("sdnc.dmaap.callback.timeout", execution); + if (isBlank(timeout)) { + logger.debug("Setting SDNR timeout to default : PT30M"); + timeout = "PT30M"; + } + } + logger.debug("Async Callback Timeout will be: " + timeout); + String msg = (String) execution.getVariable("sdnrRequest"); + logger.debug("msg to be sent on dmaap " + msg); + sdnrDmaapPublisher.get().send(msg); + + } +} + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoHandleSdnrDmaapRequest.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoHandleSdnrDmaapRequest.bpmn new file mode 100644 index 0000000000..d4e50c4d44 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoHandleSdnrDmaapRequest.bpmn @@ -0,0 +1,98 @@ +<?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" id="Definitions_1347ugu" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.1"> + <bpmn:process id="DoHandleSdnrDmaapRequest" name="CallSdnrForSliceSubnetActions" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>Flow_05aj74g</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:callActivity id="Activity_1930vdf" name="Receive Async Callback" camunda:modelerTemplate="receiveWorkflowMessage" calledElement="ReceiveWorkflowMessage"> + <bpmn:extensionElements> + <camunda:in source="true" target="isDebugLogEnabled" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="messageType" target="RCVWFMSG_messageType" /> + <camunda:in source="correlator" target="RCVWFMSG_correlator" /> + <camunda:in source="timeout" target="RCVWFMSG_timeout" /> + <camunda:out source="WorkflowResponse" target="asyncCallbackResponse" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1ujhb0b</bpmn:incoming> + <bpmn:outgoing>Flow_0ygvrm7</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_0ygvrm7" sourceRef="Activity_1930vdf" targetRef="Event_0axmcg1" /> + <bpmn:endEvent id="Event_0axmcg1"> + <bpmn:incoming>Flow_0ygvrm7</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_05aj74g" sourceRef="StartEvent_1" targetRef="Activity_0se24pv" /> + <bpmn:subProcess id="Activity_1br4yea" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_06b1eun"> + <bpmn:outgoing>Flow_1if0x9d</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0y90o3x" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_1q3xxjf"> + <bpmn:incoming>Flow_04gv65b</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_0k6o70p" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_1if0x9d</bpmn:incoming> + <bpmn:outgoing>Flow_04gv65b</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1if0x9d" sourceRef="Event_06b1eun" targetRef="Activity_0k6o70p" /> + <bpmn:sequenceFlow id="Flow_04gv65b" sourceRef="Activity_0k6o70p" targetRef="Event_1q3xxjf" /> + </bpmn:subProcess> + <bpmn:sequenceFlow id="Flow_1ujhb0b" sourceRef="Activity_0se24pv" targetRef="Activity_1930vdf" /> + <bpmn:serviceTask id="Activity_0se24pv" name="send request to SDNR" camunda:class="org.onap.so.client.sdnc.common.SendRequestToSdnr"> + <bpmn:incoming>Flow_05aj74g</bpmn:incoming> + <bpmn:outgoing>Flow_1ujhb0b</bpmn:outgoing> + </bpmn:serviceTask> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoHandleSdnrDmaapRequest"> + <bpmndi:BPMNEdge id="Flow_05aj74g_di" bpmnElement="Flow_05aj74g"> + <di:waypoint x="308" y="120" /> + <di:waypoint x="350" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ygvrm7_di" bpmnElement="Flow_0ygvrm7"> + <di:waypoint x="581" y="118" /> + <di:waypoint x="622" y="118" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1ujhb0b_di" bpmnElement="Flow_1ujhb0b"> + <di:waypoint x="450" y="120" /> + <di:waypoint x="481" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="272" y="102" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1930vdf_di" bpmnElement="Activity_1930vdf"> + <dc:Bounds x="481" y="78" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0axmcg1_di" bpmnElement="Event_0axmcg1"> + <dc:Bounds x="622" y="100" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1f7ncbf_di" bpmnElement="Activity_0se24pv"> + <dc:Bounds x="350" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1br4yea_di" bpmnElement="Activity_1br4yea" isExpanded="true"> + <dc:Bounds x="140" y="310" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_04gv65b_di" bpmnElement="Flow_04gv65b"> + <di:waypoint x="534" y="414" /> + <di:waypoint x="808" y="414" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1if0x9d_di" bpmnElement="Flow_1if0x9d"> + <di:waypoint x="206" y="414" /> + <di:waypoint x="434" y="414" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_06b1eun_di" bpmnElement="Event_06b1eun"> + <dc:Bounds x="170" y="396" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1q3xxjf_di" bpmnElement="Event_1q3xxjf"> + <dc:Bounds x="808" y="396" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0k6o70p_di" bpmnElement="Activity_0k6o70p"> + <dc:Bounds x="434" y="374" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> + + |