diff options
17 files changed, 1231 insertions, 40 deletions
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn new file mode 100644 index 0000000000..a1d4178962 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn @@ -0,0 +1,377 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1k6npmy" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0"> + <bpmn:process id="ServiceLevelUpgrade" name="ServiceLevelUpgrade" isExecutable="true"> + <bpmn:startEvent id="Event_02mc8tr"> + <bpmn:outgoing>Flow_0nrz340</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:serviceTask id="Activity_18vue7u" name="Service Upgrade Dispatcher" camunda:delegateExpression="${ServiceLevelRequestDispatcher}"> + <bpmn:incoming>Flow_0nrz340</bpmn:incoming> + <bpmn:outgoing>Flow_1b392qs</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:endEvent id="Event_12983th"> + <bpmn:incoming>Flow_10jgbxm</bpmn:incoming> + <bpmn:terminateEventDefinition id="TerminateEventDefinition_1pnutu7" /> + </bpmn:endEvent> + <bpmn:exclusiveGateway id="Gateway_02fectw" default="Flow_0y1ebox"> + <bpmn:incoming>Flow_1y3cptr</bpmn:incoming> + <bpmn:outgoing>Flow_0y1ebox</bpmn:outgoing> + <bpmn:outgoing>Flow_0mbp7mv</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="Event_0ldlupa"> + <bpmn:incoming>Flow_0y1ebox</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1dih7c9" errorRef="Error_01a8p43" /> + </bpmn:endEvent> + <bpmn:exclusiveGateway id="Gateway_1nr51kr" default="Flow_0mxq0qe"> + <bpmn:incoming>Flow_0trmo7s</bpmn:incoming> + <bpmn:outgoing>Flow_1z06yyv</bpmn:outgoing> + <bpmn:outgoing>Flow_0mxq0qe</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="Event_16k9r1c"> + <bpmn:incoming>Flow_0mxq0qe</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_042otuj" errorRef="Error_0e5owqi" /> + </bpmn:endEvent> + <bpmn:exclusiveGateway id="Gateway_1vq11i7" default="Flow_1tcnzdx"> + <bpmn:incoming>Flow_1ru18s3</bpmn:incoming> + <bpmn:outgoing>Flow_1tcnzdx</bpmn:outgoing> + <bpmn:outgoing>Flow_0l67uzl</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="Event_03tpudy"> + <bpmn:incoming>Flow_1tcnzdx</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_16r0jc3" errorRef="Error_04y00c4" /> + </bpmn:endEvent> + <bpmn:serviceTask id="Activity_0snmatn" name="Service Level Upgrade" camunda:delegateExpression="${ServiceLevelUpgrade}"> + <bpmn:incoming>Flow_1z06yyv</bpmn:incoming> + <bpmn:outgoing>Flow_01gwzx9</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:serviceTask id="Activity_0ft7fa2" name="Service Level Postcheck" camunda:delegateExpression="${ServiceLevelPostcheck}"> + <bpmn:incoming>Flow_05ohtnj</bpmn:incoming> + <bpmn:outgoing>Flow_1ru18s3</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:serviceTask id="Activity_09bqns0" name="Service Level Preparation" camunda:delegateExpression="${ServiceLevelPreparation}"> + <bpmn:incoming>Flow_1v0mxe7</bpmn:incoming> + <bpmn:outgoing>Flow_1p4xkdj</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:scriptTask id="Activity_0qgmx7a" name="Send Response" scriptFormat="groovy"> + <bpmn:incoming>Flow_1b392qs</bpmn:incoming> + <bpmn:outgoing>Flow_1v0mxe7</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def pnfSwUpgrade = new PNFSoftwareUpgrade() +pnfSwUpgrade.sendResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1n4rk7m" name="Prepare Completion" scriptFormat="groovy"> + <bpmn:incoming>Flow_0l67uzl</bpmn:incoming> + <bpmn:outgoing>Flow_0frhsd0</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def pnfSwUpgrade = new PNFSoftwareUpgrade() +pnfSwUpgrade.prepareCompletion(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_1lz38px" name="Complete Process" calledElement="CompleteMsoProcess"> + <bpmn:incoming>Flow_0frhsd0</bpmn:incoming> + <bpmn:outgoing>Flow_10jgbxm</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:subProcess id="Activity_0ui6tp1" name="Subprocess for FalloutHandler" triggeredByEvent="true"> + <bpmn:startEvent id="Event_08f3m9h"> + <bpmn:outgoing>Flow_0iayg6u</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1d67w55" /> + </bpmn:startEvent> + <bpmn:scriptTask id="Activity_1k2f3ha" name="Prepare FalloutHandler" scriptFormat="groovy"> + <bpmn:incoming>Flow_0iayg6u</bpmn:incoming> + <bpmn:outgoing>Flow_0lb7zv5</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def pnfSwUpgrade = new PNFSoftwareUpgrade() +pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_0ai3z2q" name="Call FalloutHandler" calledElement="FalloutHandler"> + <bpmn:incoming>Flow_0lb7zv5</bpmn:incoming> + <bpmn:outgoing>Flow_1peoyur</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:endEvent id="Event_0ngb9wx"> + <bpmn:incoming>Flow_1peoyur</bpmn:incoming> + <bpmn:terminateEventDefinition id="TerminateEventDefinition_1e5scwm" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_1peoyur" sourceRef="Activity_0ai3z2q" targetRef="Event_0ngb9wx" /> + <bpmn:sequenceFlow id="Flow_0lb7zv5" sourceRef="Activity_1k2f3ha" targetRef="Activity_0ai3z2q" /> + <bpmn:sequenceFlow id="Flow_0iayg6u" sourceRef="Event_08f3m9h" targetRef="Activity_1k2f3ha" /> + </bpmn:subProcess> + <bpmn:sequenceFlow id="Flow_0nrz340" sourceRef="Event_02mc8tr" targetRef="Activity_18vue7u" /> + <bpmn:sequenceFlow id="Flow_1b392qs" sourceRef="Activity_18vue7u" targetRef="Activity_0qgmx7a" /> + <bpmn:sequenceFlow id="Flow_10jgbxm" sourceRef="Activity_1lz38px" targetRef="Event_12983th" /> + <bpmn:sequenceFlow id="Flow_01gwzx9" sourceRef="Activity_0snmatn" targetRef="Activity_1q4o9fx" /> + <bpmn:sequenceFlow id="Flow_0y1ebox" name="Failure" sourceRef="Gateway_02fectw" targetRef="Event_0ldlupa" /> + <bpmn:sequenceFlow id="Flow_1p4xkdj" sourceRef="Activity_09bqns0" targetRef="Activity_0n17xou" /> + <bpmn:sequenceFlow id="Flow_1z06yyv" name="Success" sourceRef="Gateway_1nr51kr" targetRef="Activity_0snmatn"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0mxq0qe" name="Failure" sourceRef="Gateway_1nr51kr" targetRef="Event_16k9r1c" /> + <bpmn:sequenceFlow id="Flow_1ru18s3" sourceRef="Activity_0ft7fa2" targetRef="Gateway_1vq11i7" /> + <bpmn:sequenceFlow id="Flow_1tcnzdx" name="Failure" sourceRef="Gateway_1vq11i7" targetRef="Event_03tpudy" /> + <bpmn:sequenceFlow id="Flow_0l67uzl" name="Success" sourceRef="Gateway_1vq11i7" targetRef="Activity_1n4rk7m"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1v0mxe7" sourceRef="Activity_0qgmx7a" targetRef="Activity_09bqns0" /> + <bpmn:sequenceFlow id="Flow_0frhsd0" sourceRef="Activity_1n4rk7m" targetRef="Activity_1lz38px" /> + <bpmn:sequenceFlow id="Flow_0mbp7mv" name="Success" sourceRef="Gateway_02fectw" targetRef="Activity_1hp67qz"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:callActivity id="Activity_0n17xou" name="BPMN to Execute" calledElement="${healthCheckWorkflow}"> + <bpmn:extensionElements> + <camunda:in source="bpmnRequest" target="bpmnRequest" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:out source="WorkflowExceptionErrorMessage" target="WorkflowExceptionErrorMessage" /> + <camunda:out source="ControllerStatus" target="ControllerStatus" /> + <camunda:in source="isRollback" target="isRollback" /> + <camunda:in source="pnfName" target="pnfName" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1p4xkdj</bpmn:incoming> + <bpmn:outgoing>Flow_0trmo7s</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_0trmo7s" sourceRef="Activity_0n17xou" targetRef="Gateway_1nr51kr" /> + <bpmn:callActivity id="Activity_1q4o9fx" name="BPMN to Execute" calledElement="${softwareUpgradeWorkflow}"> + <bpmn:extensionElements> + <camunda:in source="bpmnRequest" target="bpmnRequest" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:out source="WorkflowExceptionErrorMessage" target="WorkflowExceptionErrorMessage" /> + <camunda:out source="ControllerStatus" target="ControllerStatus" /> + <camunda:in source="isRollback" target="isRollback" /> + <camunda:in source="pnfName" target="pnfName" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_01gwzx9</bpmn:incoming> + <bpmn:outgoing>Flow_1y3cptr</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_1y3cptr" sourceRef="Activity_1q4o9fx" targetRef="Gateway_02fectw" /> + <bpmn:serviceTask id="Activity_1hp67qz" name="Update ServiceInstance To AAI" camunda:delegateExpression="${UpdateServiceInstanceInAai}"> + <bpmn:incoming>Flow_0mbp7mv</bpmn:incoming> + <bpmn:outgoing>Flow_0dyc3kv</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0dyc3kv" sourceRef="Activity_1hp67qz" targetRef="Gateway_18ch73t" /> + <bpmn:exclusiveGateway id="Gateway_18ch73t" default="Flow_0ny61qm"> + <bpmn:incoming>Flow_0dyc3kv</bpmn:incoming> + <bpmn:outgoing>Flow_05ohtnj</bpmn:outgoing> + <bpmn:outgoing>Flow_0ny61qm</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_05ohtnj" name="Success " sourceRef="Gateway_18ch73t" targetRef="Activity_0ft7fa2"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:endEvent id="Event_1fhov6x"> + <bpmn:incoming>Flow_0ny61qm</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0od3xnw" errorRef="Error_01a8p43" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_0ny61qm" name="Failure " sourceRef="Gateway_18ch73t" targetRef="Event_1fhov6x" /> + </bpmn:process> + <bpmn:error id="Error_01a8p43" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn:error id="Error_0e5owqi" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn:error id="Error_1at4rzq" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn:error id="Error_04y00c4" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ServiceLevelUpgrade"> + <bpmndi:BPMNEdge id="Flow_0ny61qm_di" bpmnElement="Flow_0ny61qm"> + <di:waypoint x="1190" y="278" /> + <di:waypoint x="1190" y="334" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1152" y="290" width="35" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_05ohtnj_di" bpmnElement="Flow_05ohtnj"> + <di:waypoint x="1206" y="262" /> + <di:waypoint x="1300" y="262" /> + <di:waypoint x="1300" y="372" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1232" y="244" width="43" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0dyc3kv_di" bpmnElement="Flow_0dyc3kv"> + <di:waypoint x="1120" y="262" /> + <di:waypoint x="1174" y="262" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1y3cptr_di" bpmnElement="Flow_1y3cptr"> + <di:waypoint x="860" y="262" /> + <di:waypoint x="904" y="262" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0trmo7s_di" bpmnElement="Flow_0trmo7s"> + <di:waypoint x="450" y="262" /> + <di:waypoint x="501" y="262" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0mbp7mv_di" bpmnElement="Flow_0mbp7mv"> + <di:waypoint x="936" y="262" /> + <di:waypoint x="1020" y="262" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="948" y="248" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0frhsd0_di" bpmnElement="Flow_0frhsd0"> + <di:waypoint x="312" y="482" /> + <di:waypoint x="372" y="482" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1v0mxe7_di" bpmnElement="Flow_1v0mxe7"> + <di:waypoint x="532" y="122" /> + <di:waypoint x="562" y="122" /> + <di:waypoint x="562" y="192" /> + <di:waypoint x="172" y="192" /> + <di:waypoint x="172" y="262" /> + <di:waypoint x="212" y="262" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0l67uzl_di" bpmnElement="Flow_0l67uzl"> + <di:waypoint x="1054" y="412" /> + <di:waypoint x="172" y="412" /> + <di:waypoint x="172" y="482" /> + <di:waypoint x="212" y="482" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="663" y="398" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1tcnzdx_di" bpmnElement="Flow_1tcnzdx"> + <di:waypoint x="1070" y="428" /> + <di:waypoint x="1070" y="494" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1032" y="451" width="35" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1ru18s3_di" bpmnElement="Flow_1ru18s3"> + <di:waypoint x="1250" y="412" /> + <di:waypoint x="1086" y="412" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0mxq0qe_di" bpmnElement="Flow_0mxq0qe"> + <di:waypoint x="517" y="278" /> + <di:waypoint x="517" y="334" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="472" y="296" width="35" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1z06yyv_di" bpmnElement="Flow_1z06yyv"> + <di:waypoint x="533" y="262" /> + <di:waypoint x="590" y="262" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="540" y="248" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1p4xkdj_di" bpmnElement="Flow_1p4xkdj"> + <di:waypoint x="312" y="262" /> + <di:waypoint x="350" y="262" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0y1ebox_di" bpmnElement="Flow_0y1ebox"> + <di:waypoint x="920" y="278" /> + <di:waypoint x="918" y="335" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="879" y="296" width="35" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_01gwzx9_di" bpmnElement="Flow_01gwzx9"> + <di:waypoint x="690" y="262" /> + <di:waypoint x="760" y="262" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_10jgbxm_di" bpmnElement="Flow_10jgbxm"> + <di:waypoint x="472" y="482" /> + <di:waypoint x="524" y="480" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1b392qs_di" bpmnElement="Flow_1b392qs"> + <di:waypoint x="362" y="122" /> + <di:waypoint x="432" y="122" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0nrz340_di" bpmnElement="Flow_0nrz340"> + <di:waypoint x="186" y="120" /> + <di:waypoint x="262" y="122" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_02mc8tr_di" bpmnElement="Event_02mc8tr"> + <dc:Bounds x="154" y="104" width="32" height="32" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-6" y="-188" width="51" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_18vue7u_di" bpmnElement="Activity_18vue7u"> + <dc:Bounds x="262" y="82" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_12983th_di" bpmnElement="Event_12983th"> + <dc:Bounds x="524" y="464" width="32" height="32" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-132" y="-188" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_02fectw_di" bpmnElement="Gateway_02fectw" isMarkerVisible="true"> + <dc:Bounds x="904" y="246" width="32" height="32" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0ldlupa_di" bpmnElement="Event_0ldlupa"> + <dc:Bounds x="905" y="334" width="32" height="32" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1nr51kr_di" bpmnElement="Gateway_1nr51kr" isMarkerVisible="true"> + <dc:Bounds x="501" y="246" width="32" height="32" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_16k9r1c_di" bpmnElement="Event_16k9r1c"> + <dc:Bounds x="501" y="334" width="32" height="32" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1vq11i7_di" bpmnElement="Gateway_1vq11i7" isMarkerVisible="true"> + <dc:Bounds x="1054" y="396" width="32" height="32" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_03tpudy_di" bpmnElement="Event_03tpudy"> + <dc:Bounds x="1054" y="494" width="32" height="32" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0snmatn_di" bpmnElement="Activity_0snmatn"> + <dc:Bounds x="590" y="222" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ft7fa2_di" bpmnElement="Activity_0ft7fa2"> + <dc:Bounds x="1250" y="372" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_09bqns0_di" bpmnElement="Activity_09bqns0"> + <dc:Bounds x="212" y="222" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0qgmx7a_di" bpmnElement="Activity_0qgmx7a"> + <dc:Bounds x="432" y="82" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1n4rk7m_di" bpmnElement="Activity_1n4rk7m"> + <dc:Bounds x="212" y="442" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1lz38px_di" bpmnElement="Activity_1lz38px"> + <dc:Bounds x="372" y="442" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ui6tp1_di" bpmnElement="Activity_0ui6tp1" isExpanded="true"> + <dc:Bounds x="362" y="572" width="650" height="190" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_0iayg6u_di" bpmnElement="Flow_0iayg6u"> + <di:waypoint x="466" y="670" /> + <di:waypoint x="532" y="672" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0lb7zv5_di" bpmnElement="Flow_0lb7zv5"> + <di:waypoint x="632" y="672" /> + <di:waypoint x="702" y="672" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1peoyur_di" bpmnElement="Flow_1peoyur"> + <di:waypoint x="802" y="672" /> + <di:waypoint x="874" y="670" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_08f3m9h_di" bpmnElement="Event_08f3m9h"> + <dc:Bounds x="434" y="654" width="32" height="32" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-161" y="-188" width="78" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1k2f3ha_di" bpmnElement="Activity_1k2f3ha"> + <dc:Bounds x="532" y="632" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ai3z2q_di" bpmnElement="Activity_0ai3z2q"> + <dc:Bounds x="702" y="632" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0ngb9wx_di" bpmnElement="Event_0ngb9wx"> + <dc:Bounds x="874" y="654" width="32" height="32" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-132" y="-188" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0n17xou_di" bpmnElement="Activity_0n17xou"> + <dc:Bounds x="350" y="222" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1q4o9fx_di" bpmnElement="Activity_1q4o9fx"> + <dc:Bounds x="760" y="222" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1hp67qz_di" bpmnElement="Activity_1hp67qz"> + <dc:Bounds x="1020" y="222" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_18ch73t_di" bpmnElement="Gateway_18ch73t" isMarkerVisible="true"> + <dc:Bounds x="1174" y="246" width="32" height="32" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1fhov6x_di" bpmnElement="Event_1fhov6x"> + <dc:Bounds x="1174" y="334" width="32" height="32" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java new file mode 100644 index 0000000000..805597cd12 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java @@ -0,0 +1,255 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.process; + +import com.google.protobuf.Struct; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Before; +import org.junit.Test; +import org.onap.aaiclient.client.aai.AAIVersion; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.so.BaseBPMNTest; +import org.onap.so.GrpcNettyServer; +import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames; +import org.onap.so.bpmn.mock.FileUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static org.assertj.core.api.Assertions.fail; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; + +/** + * Basic Integration test for ServiceLevelUpgrade.bpmn workflow. + */ +public class ServiceLevelUpgradeTest extends BaseBPMNTest { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + private static final long WORKFLOW_WAIT_TIME = 1000L; + + private static final String TEST_PROCESSINSTANCE_KEY = "ServiceLevelUpgrade"; + private static final AAIVersion VERSION = AAIVersion.LATEST; + private static final Map<String, Object> executionVariables = new HashMap(); + private static final String REQUEST_ID = "50ae41ad-049c-4fe2-9950-539f111120f5"; + private static final String SERVICE_INSTANCE_ID = "5df8b6de-2083-11e7-93ae-92361f002676"; + private final String[] actionNames = new String[5]; + private final String CLASSNAME = getClass().getSimpleName(); + private String requestObject; + private String responseObject; + + @Autowired + private GrpcNettyServer grpcNettyServer; + + @Before + public void setUp() throws IOException { + actionNames[0] = "healthCheck"; + actionNames[1] = "preCheck"; + actionNames[2] = "downloadNESw"; + actionNames[3] = "activateNESw"; + actionNames[4] = "postCheck"; + + executionVariables.clear(); + + requestObject = FileUtil.readResourceFile("request/" + CLASSNAME + ".json"); + responseObject = FileUtil.readResourceFile("response/" + CLASSNAME + ".json"); + + executionVariables.put("bpmnRequest", requestObject); + executionVariables.put("requestId", REQUEST_ID); + executionVariables.put("serviceInstanceId", SERVICE_INSTANCE_ID); + + + /** + * This variable indicates that the flow was invoked asynchronously. It's injected by {@link WorkflowProcessor}. + */ + executionVariables.put("isAsyncProcess", "true"); + executionVariables.put(ExecutionVariableNames.PRC_CUSTOMIZATION_UUID, "38dc9a92-214c-11e7-93ae-92361f002680"); + + /** + * Temporary solution to add pnfCorrelationId to context. this value is getting from the request to SO api + * handler and then convert to CamudaInput + */ + executionVariables.put(ExecutionVariableNames.PNF_CORRELATION_ID, "PNFDemo"); + } + + + @Test + public void workflow_validInput_expectedOutput() throws InterruptedException { + + mockCatalogDb(); + mockRequestDb(); + mockAai(); + + final String msoRequestId = UUID.randomUUID().toString(); + executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId); + + final String testBusinessKey = UUID.randomUUID().toString(); + logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey); + + ProcessInstance pi = + runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables); + + int waitCount = 10; + while (!isProcessInstanceEnded() && waitCount >= 0) { + Thread.sleep(WORKFLOW_WAIT_TIME); + waitCount--; + } + + // Layout is to reflect the bpmn visual layout + assertThat(pi).isEnded().hasPassedInOrder("Event_02mc8tr", "Activity_18vue7u", "Activity_0qgmx7a", + "Activity_09bqns0", "Activity_0n17xou", "Gateway_1nr51kr", "Activity_0snmatn", "Activity_1q4o9fx", + "Gateway_02fectw", "Activity_1hp67qz", "Gateway_18ch73t", "Activity_0ft7fa2", "Gateway_1vq11i7", + "Activity_1n4rk7m", "Activity_1lz38px", "Event_12983th"); + + List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages(); + assertThat(detailedMessages.size() == 5); + int count = 0; + try { + for (ExecutionServiceInput eSI : detailedMessages) { + for (String action : actionNames) { + if (action.equals(eSI.getActionIdentifiers().getActionName()) + && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) { + checkWithActionName(eSI, action); + count++; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + fail("PNFSoftwareUpgrade request exception", e); + } + assertThat(count == actionNames.length); + } + + private boolean isProcessInstanceEnded() { + return runtimeService.createProcessInstanceQuery().processDefinitionKey(TEST_PROCESSINSTANCE_KEY) + .singleResult() == null; + } + + private void checkWithActionName(ExecutionServiceInput executionServiceInput, String action) { + + logger.info("Checking the " + action + " request"); + ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); + + /** + * the fields of actionIdentifiers should match the one in the response/PnfHealthCheck_catalogdb.json. + */ + assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_pnf_software_upgrade_restconf"); + assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0"); + assertThat(actionIdentifiers.getActionName()).isEqualTo(action); + assertThat(actionIdentifiers.getMode()).isEqualTo("async"); + + CommonHeader commonHeader = executionServiceInput.getCommonHeader(); + assertThat(commonHeader.getOriginatorId()).isEqualTo("SO"); + + Struct payload = executionServiceInput.getPayload(); + Struct requeststruct = payload.getFieldsOrThrow(action + "-request").getStructValue(); + + assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).isEqualTo("PNFDemo"); + Struct propertiesStruct = requeststruct.getFieldsOrThrow(action + "-properties").getStructValue(); + + assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo("PNFDemo"); + assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()) + .isEqualTo("d88da85c-d9e8-4f73-b837-3a72a431622b"); + assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue()) + .isEqualTo("38dc9a92-214c-11e7-93ae-92361f002680"); + } + + private void mockAai() { + + final String sIUrl = + "/business/customers/customer/5df8b6de-2083-11e7-93ae-92361f002676/service-subscriptions/service-subscription/pNF/service-instances/service-instance/ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce"; + final String aaiPnfEntry = FileUtil.readResourceFile("response/Pnf_aai.json"); + final String aaiServiceInstanceEntry = FileUtil.readResourceFile("response/Service_instance_aai.json"); + + /** + * PUT the PNF correlation ID to AAI. + */ + wireMockServer.stubFor(put(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); + + /** + * Get the PNF entry from AAI. + */ + wireMockServer.stubFor( + get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry))); + + /** + * Post the pnf to AAI + */ + wireMockServer.stubFor(post(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); + + /** + * Get the Service Instance to AAI. + */ + wireMockServer.stubFor(get(urlEqualTo("/aai/" + VERSION + sIUrl)).willReturn(okJson(aaiServiceInstanceEntry))); + + /** + * Post the Service Instance to AAI. + */ + wireMockServer.stubFor(post(urlEqualTo("/aai/" + VERSION + sIUrl))); + } + + private void mockRequestDb() { + /** + * Update Request DB + */ + wireMockServer.stubFor(put(urlEqualTo("/infraActiveRequests/" + REQUEST_ID))); + + } + + /** + * Mock the catalobdb rest interface. + */ + private void mockCatalogDb() { + + String catalogdbClientResponse = FileUtil.readResourceFile("response/" + CLASSNAME + "_catalogdb.json"); + + + /** + * Return valid json for the model UUID in the request file. + */ + wireMockServer + .stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=d88da85c-d9e8-4f73-b837-3a72a431622b")) + .willReturn(okJson(responseObject))); + + /** + * Return valid json for the service model InvariantUUID as specified in the request file. + */ + wireMockServer.stubFor( + get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=fe41489e-1563-46a3-b90a-1db629e4375b")) + .willReturn(okJson(responseObject))); + + /** + * Return valid spring data rest json for the service model UUID as specified in the request file. + */ + wireMockServer.stubFor(get(urlEqualTo( + "/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=d88da85c-d9e8-4f73-b837-3a72a431622b")) + .willReturn(okJson(catalogdbClientResponse))); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/ServiceLevelUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/ServiceLevelUpgradeTest.json new file mode 100644 index 0000000000..b5cce60094 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/ServiceLevelUpgradeTest.json @@ -0,0 +1,48 @@ +{ + "requestDetails":{ + "subscriberInfo":{ + "globalSubscriberId":"ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce" + }, + "requestInfo":{ + "suppressRollback": false, + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "requestorId": "demo", + "instanceName":"testInstanceName", + "source":"VID" + }, + "cloudConfiguration":{ + "lcpCloudRegionId": "RegionOne", + "tenantId": "7320ec4a5b9d4589ba7c4412ccfd290f", + "cloudOwner": "CloudOwner" + }, + "requestParameters":{ + "subscriptionServiceType": "pNF", + "userParams":[ + { + "name":"targetSoftwareVersion", + "value":"demo-sw-ver2.0.0" + }, + { + "name":"pnfName", + "value":"PNFDemo" + } + ], + "aLaCarte": false, + "payload": "{\"k1\": \"v1\"}" + }, + "project":{ + "projectName": "ServiceLevelUpgrade" + }, + "owningEntity":{ + "owningEntityId":"67f2e84c-734d-4e90-a1e4-d2ffa2e75849", + "owningEntityName":"OE-Test" + }, + "modelInfo":{ + "modelVersion": "2.0", + "modelVersionId": "d88da85c-d9e8-4f73-b837-3a72a431622b", + "modelInvariantId": "fe41489e-1563-46a3-b90a-1db629e4375b", + "modelName": "Demo_svc", + "modelType": "service" + } + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Pnf_aai.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Pnf_aai.json new file mode 100644 index 0000000000..865600c800 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Pnf_aai.json @@ -0,0 +1,42 @@ +{ + "pnf-name": "PNFDemo", + "pnf-id": "27c6e19d-6d9f-4085-98a9-d3fcbaf3a616", + "equip-type": "val8", + "equip-vendor": "Ericsson", + "equip-model": "val6", + "ipaddress-v4-oam": "10.10.10.43", + "sw-version": "5gDUv18.05.201", + "in-maint": false, + "serial-number": "6061ZW3", + "ipaddress-v6-oam": "2001:0db8:0:0:0:0:1428:57ab", + "resource-version": "1595010038094", + "nf-role": "gNB", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "related-link": "/aai/v11/business/customers/customer/ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce/service-subscriptions/service-subscription/pNF/service-instances/service-instance/5df8b6de-2083-11e7-93ae-92361f002676", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "pNF" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5df8b6de-2083-11e7-93ae-92361f002676" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "Service_Ete_Name123452c4-3d7f-42ce-8188-818fab951269" + } + ] + } + ] + } +},
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest.json new file mode 100644 index 0000000000..ec92552c5e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest.json @@ -0,0 +1,27 @@ +{ + "serviceResources":{ + "modelInfo":{ + "modelVersion": "2.0", + "modelVersionId": "d88da85c-d9e8-4f73-b837-3a72a431622b", + "modelInvariantId": "fe41489e-1563-46a3-b90a-1db629e4375b", + "modelName": "Demo_svc", + "modelType": "service" + }, + "serviceType":"pNF", + "environmentContext":"Luna", + "serviceRole":"NA", + "workloadContext":"Oxygen", + "serviceVnfs":[ + + ], + "serviceNetworks":[ + + ], + "serviceAllottedResources":[ + + ], + "configResource":[ + + ] + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest_catalogdb.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest_catalogdb.json new file mode 100644 index 0000000000..faec947fec --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest_catalogdb.json @@ -0,0 +1,39 @@ +{ + "_embedded": { + "pnfResourceCustomization": [ + { + "modelCustomizationUUID": "38dc9a92-214c-11e7-93ae-92361f002680", + "modelInstanceName": "PNF routing", + "created": "2019-03-08 12:00:29.000", + "nfFunction": "routing", + "nfType": "routing", + "nfRole": "routing", + "nfNamingCode": "routing", + "multiStageDesign": null, + "resourceInput": null, + "blueprintName": "test_pnf_software_upgrade_restconf", + "blueprintVersion": "1.0.0", + "skipPostInstConf": false, + "softwareVersion": "1.0.0", + "creationTimestamp": "2019-03-08T12:00:29.000+0000", + "controllerActor": "cds", + "_links": { + "self": { + "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680" + }, + "pnfResourceCustomization": { + "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680" + }, + "pnfResources": { + "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680/pnfResources" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:41023/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=4df8b6de-2083-11e7-93ae-92361f002676" + } + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Service_instance_aai.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Service_instance_aai.json new file mode 100644 index 0000000000..53fb210478 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Service_instance_aai.json @@ -0,0 +1,35 @@ +{ + "service-instance-id": "5df8b6de-2083-11e7-93ae-92361f002676", + "service-instance-name": "Service_Ete_Name123452c4-3d7f-42ce-8188-818fab951269", + "environment-context": "General_Revenue-Bearing", + "workload-context": "Production", + "model-version-id": "d88da85c-d9e8-4f73-b837-3a72a431622b", + "modelInvariantId": "fe41489e-1563-46a3-b90a-1db629e4375b", + "resource-version": "1595258335377", + "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/5df8b6de-2083-11e7-93ae-92361f002676/service-data/service-topology/", + "orchestration-status": "Assigned", + "relationship-list": { + "relationship": [ + { + "related-to": "owning-entity", + "related-link": "/aai/v11/business/owning-entities/owning-entity/67f2e84c-734d-4e90-a1e4-d2ffa2e75849", + "relationship-data": [ + { + "relationship-key": "owning-entity.owning-entity-id", + "relationship-value": "67f2e84c-734d-4e90-a1e4-d2ffa2e75849" + } + ] + }, + { + "related-to": "pnf", + "related-link": "/aai/v11/network/pnfs/pnf/PNFDemo", + "relationship-data": [ + { + "relationship-key": "pnf.pnf-name", + "relationship-value": "PNFDemo" + } + ] + } + ] + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/AbstractServiceLevelPreparable.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/AbstractServiceLevelPreparable.java index 36db549486..0671354bd6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/AbstractServiceLevelPreparable.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/AbstractServiceLevelPreparable.java @@ -21,6 +21,7 @@ package org.onap.so.bpmn.infrastructure.service.level; import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelConstants; import org.onap.so.client.exception.ExceptionBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,15 +34,6 @@ import java.util.List; */ public abstract class AbstractServiceLevelPreparable { - protected static final String WORKFLOW_TO_INVOKE = "healthCheckWorkflow"; - protected static final String GENERIC_PNF_HEALTH_CHECK_WORKFLOW = "GenericPnfHealthCheck"; - protected static final String GENERIC_PNF_SOFTWARE_UPGRADE_WORKFLOW = "GenericPnfSoftwareUpgrade"; - protected static final String RESOURCE_TYPE = "RESOURCE_TYPE"; - protected static final int ERROR_CODE = 601; - - // TODO This value needs to be updated once vnf health check workflow is available - protected static final String GENERIC_VNF_HEALTH_CHECK_WORKFLOW = "GenericVNFHealthCheck"; - protected static final Logger LOG = LoggerFactory.getLogger(AbstractServiceLevelPreparable.class); @Autowired @@ -61,8 +53,7 @@ public abstract class AbstractServiceLevelPreparable { * @param execution Delegate execution obj * @param scope Controller scope * Throws workflow exception if validation fails */ - protected void validateParamsWithScope(DelegateExecution execution, final String scope, List<String> params) - throws Exception { + protected void validateParamsWithScope(DelegateExecution execution, final String scope, List<String> params) { List<String> invalidVariables = new ArrayList<>(); for (String param : params) { if (!execution.hasVariable(param) || execution.getVariable(param) == null @@ -72,7 +63,7 @@ public abstract class AbstractServiceLevelPreparable { } if (invalidVariables.size() > 0) { LOG.error("Validation error for the {} health check attributes: {}", scope, invalidVariables); - exceptionBuilder.buildAndThrowWorkflowException(execution, ERROR_CODE, + exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, "Validation of health check workflow parameters failed for the scope: " + scope); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java new file mode 100644 index 0000000000..34ebb308c3 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java @@ -0,0 +1,20 @@ +package org.onap.so.bpmn.infrastructure.service.level.impl; + +public class ServiceLevelConstants { + public static final String BPMN_REQUEST = "bpmnRequest"; + public static final String RESOURCE_TYPE = "resourceType"; + public static final String SERVICE_INSTANCE_ID = "serviceInstanceId"; + public static final String PNF_NAME = "pnfName"; + public static final String PNF = "pnf"; + public static final String VNF = "vnf"; + public static final String EMPTY_STRING = ""; + public static final String WORKFLOW_TO_INVOKE = "healthCheckWorkflow"; + public static final String SOFTWARE_WORKFLOW_TO_INVOKE = "softwareUpgradeWorkflow"; + public static final String GENERIC_PNF_HEALTH_CHECK_WORKFLOW = "GenericPnfHealthCheck"; + public static final String PNF_SOFTWARE_UPGRADE_WORKFLOW = "PNFSoftwareUpgrade"; + public static final String CONTROLLER_STATUS = "ControllerStatus"; + public static final int ERROR_CODE = 601; + // TODO This value needs to be updated once vnf health check workflow is available + protected static final String GENERIC_VNF_HEALTH_CHECK_WORKFLOW = "GenericVNFHealthCheck"; + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java new file mode 100644 index 0000000000..fad28e315e --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java @@ -0,0 +1,13 @@ +package org.onap.so.bpmn.infrastructure.service.level.impl; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.springframework.stereotype.Component; + +@Component +public class ServiceLevelPostcheck implements JavaDelegate { + @Override + public void execute(DelegateExecution delegateExecution) throws Exception { + // TODO : Set serviceInstance to aai + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java index 52521ce16b..5b772760f0 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java @@ -27,7 +27,6 @@ import org.springframework.stereotype.Component; import java.util.Arrays; import java.util.List; - /** * Fetches health check workflow based on the controller_scope. Invoke the corresponding health check workflow after * validation. @@ -35,24 +34,26 @@ import java.util.List; @Component("ServiceLevelPreparation") public class ServiceLevelPreparation extends AbstractServiceLevelPreparable implements JavaDelegate { - // Health check parameters to be validated for pnf resource - private static final List<String> PNF_HC_PARAMS = Arrays.asList("SERVICE_MODEL_INFO", "SERVICE_INSTANCE_NAME", - "PNF_CORRELATION_ID", "MODEL_UUID", "PNF_UUID", "PRC_BLUEPRINT_NAME", "PRC_BLUEPRINT_VERSION", - "PRC_CUSTOMIZATION_UUID", "RESOURCE_CUSTOMIZATION_UUID_PARAM", "PRC_INSTANCE_NAME", "PRC_CONTROLLER_ACTOR", - "REQUEST_PAYLOAD"); + private static final List<String> PNF_HC_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID, + ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST, ServiceLevelConstants.PNF_NAME); @Override public void execute(DelegateExecution execution) throws Exception { - if (execution.hasVariable(RESOURCE_TYPE) && execution.getVariable(RESOURCE_TYPE) != null) { - final String controllerScope = (String) execution.getVariable(RESOURCE_TYPE); + if (execution.hasVariable(ServiceLevelConstants.RESOURCE_TYPE) + && execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE) != null) { + final String controllerScope = (String) execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE); LOG.debug("Scope retrieved from delegate execution: " + controllerScope); final String wflName = fetchWorkflowUsingScope(execution, controllerScope); - LOG.debug("Health check workflow fetched for the scope: {}", wflName); - validateParamsWithScope(execution, controllerScope, PNF_HC_PARAMS); - LOG.info("Parameters validated successfully for {}", wflName); - execution.setVariable(WORKFLOW_TO_INVOKE, wflName); + LOG.debug("Health check workflow fetched for the scope: {} is: {}", controllerScope, wflName); + + if (ServiceLevelConstants.PNF.equalsIgnoreCase(controllerScope)) { + validateParamsWithScope(execution, controllerScope, PNF_HC_PARAMS); + LOG.info("Parameters validated successfully for {}", wflName); + } + execution.setVariable(ServiceLevelConstants.WORKFLOW_TO_INVOKE, wflName); + execution.setVariable(ServiceLevelConstants.CONTROLLER_STATUS, ServiceLevelConstants.EMPTY_STRING); } else { - exceptionBuilder.buildAndThrowWorkflowException(execution, ERROR_CODE, + exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, "Controller scope not found to invoke resource level health check"); } } @@ -61,14 +62,14 @@ public class ServiceLevelPreparation extends AbstractServiceLevelPreparable impl public String fetchWorkflowUsingScope(DelegateExecution execution, final String scope) { String wflName = null; switch (scope.toLowerCase()) { - case "pnf": - wflName = GENERIC_PNF_HEALTH_CHECK_WORKFLOW; + case ServiceLevelConstants.PNF: + wflName = ServiceLevelConstants.GENERIC_PNF_HEALTH_CHECK_WORKFLOW; break; - case "vnf": - wflName = GENERIC_VNF_HEALTH_CHECK_WORKFLOW; + case ServiceLevelConstants.VNF: + wflName = ServiceLevelConstants.GENERIC_VNF_HEALTH_CHECK_WORKFLOW; break; default: - exceptionBuilder.buildAndThrowWorkflowException(execution, ERROR_CODE, + exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, "No valid health check work flow retrieved for the scope: " + scope); } return wflName; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java new file mode 100644 index 0000000000..5b20a86cb7 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java @@ -0,0 +1,131 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.service.level.impl; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aaiclient.client.aai.AAIRestClientI; +import org.onap.aaiclient.client.aai.AAIRestClientImpl; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.io.IOException; +import java.util.Optional; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*; + +/** + * This implementation of {@link JavaDelegate} is used to populate the execution object for Service level upgrade + */ +@Component +public class ServiceLevelRequestDispatcher implements JavaDelegate { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private ExceptionBuilder exceptionUtil; + + @Autowired + private ObjectMapper mapper; + + @Override + public void execute(DelegateExecution delegateExecution) throws Exception { + logger.debug("Running execute block for activity id: {}, name: {}", delegateExecution.getCurrentActivityId(), + delegateExecution.getCurrentActivityName()); + + RequestDetails bpmnRequestDetails = requestVerification(delegateExecution); + + final String serviceInstanceId = String.valueOf(delegateExecution.getVariable(SERVICE_INSTANCE_ID)); + final String serviceType = bpmnRequestDetails.getRequestParameters().getSubscriptionServiceType(); + final String globalSubscriberId = bpmnRequestDetails.getSubscriberInfo().getGlobalSubscriberId(); + + final String modelInvariantId = bpmnRequestDetails.getModelInfo().getModelInvariantId(); + final String modelId = bpmnRequestDetails.getModelInfo().getModelUuid(); + final String modelVersion = bpmnRequestDetails.getModelInfo().getModelVersion(); + + if (ServiceLevelConstants.PNF.equalsIgnoreCase(serviceType)) { + getAndSetPnfNameFromServiceInstance(serviceInstanceId, serviceType, globalSubscriberId, delegateExecution); + } + + // TODO : handling for vnf + + logger.trace("Completed dispatcher request for ServiceLevelUpgrade."); + } + + private void getAndSetPnfNameFromServiceInstance(final String serviceInstanceId, final String serviceType, + final String globalSubscriberId, DelegateExecution delegateExecution) { + + AAIRestClientI restClient = new AAIRestClientImpl(); + + Optional<ServiceInstance> optionalSi = + restClient.getServiceInstanceById(serviceInstanceId, serviceType, globalSubscriberId); + + if (!optionalSi.isPresent()) { + + } + + optionalSi.ifPresentOrElse(serviceInstance -> { + final String pnfName = serviceInstance.getRelationshipList().getRelationship().stream() + .filter(x -> x.getRelatedTo().contains("pnf")).findFirst().get().getRelationshipData().stream() + .filter(data -> data.getRelationshipKey().contains("pnf.pnf-name")).findFirst().get() + .getRelationshipValue(); + if (pnfName == null || pnfName.isEmpty()) { + logger.warn( + "Unable to find the PNF for service instance id: " + serviceInstance.getServiceInstanceId()); + return; + } + delegateExecution.setVariable(ServiceLevelConstants.PNF_NAME, pnfName); + delegateExecution.setVariable(ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.PNF); + }, () -> { + throwExceptionWithWarn(delegateExecution, "Unable to find the service instance: " + serviceInstanceId); + }); + } + + private RequestDetails requestVerification(DelegateExecution delegateExecution) throws IOException { + RequestDetails bpmnRequestDetails = mapper.readValue(JsonUtils.getJsonValue( + String.valueOf(delegateExecution.getVariable(ServiceLevelConstants.BPMN_REQUEST)), "requestDetails"), + RequestDetails.class); + + throwIfNull(delegateExecution, bpmnRequestDetails.getModelInfo(), SERVICE_MODEL_INFO); + throwIfNull(delegateExecution, bpmnRequestDetails.getRequestInfo(), "RequestInfo"); + throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters(), "RequestParameters"); + throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters().getUserParams(), "UserParams"); + + return bpmnRequestDetails; + } + + private void throwIfNull(DelegateExecution delegateExecution, Object obj, String param) { + if (obj == null) { + throwExceptionWithWarn(delegateExecution, + "Unable to find the parameter: " + param + " in the execution context"); + } + } + + private void throwExceptionWithWarn(DelegateExecution delegateExecution, String exceptionMsg) { + logger.warn(exceptionMsg); + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ServiceLevelConstants.ERROR_CODE, exceptionMsg); + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java new file mode 100644 index 0000000000..dfc77d6f0c --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java @@ -0,0 +1,54 @@ +package org.onap.so.bpmn.infrastructure.service.level.impl; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.so.bpmn.infrastructure.service.level.AbstractServiceLevelPreparable; +import org.springframework.stereotype.Component; +import java.util.Arrays; +import java.util.List; + +@Component +public class ServiceLevelUpgrade extends AbstractServiceLevelPreparable implements JavaDelegate { + + private static final List<String> PNF_SWU_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID, + ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST, ServiceLevelConstants.PNF_NAME); + + @Override + protected String fetchWorkflowUsingScope(DelegateExecution execution, String scope) { + String wflName = null; + switch (scope.toLowerCase()) { + case ServiceLevelConstants.PNF: + wflName = ServiceLevelConstants.PNF_SOFTWARE_UPGRADE_WORKFLOW; + break; + case ServiceLevelConstants.VNF: + wflName = ServiceLevelConstants.GENERIC_VNF_HEALTH_CHECK_WORKFLOW; + break; + default: + exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, + "No valid health check work flow retrieved for the scope: " + scope); + } + return wflName; + } + + @Override + public void execute(DelegateExecution execution) throws Exception { + if (execution.hasVariable(ServiceLevelConstants.RESOURCE_TYPE) + && execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE) != null) { + final String controllerScope = (String) execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE); + LOG.debug("Scope retrieved from delegate execution: " + controllerScope); + final String wflName = fetchWorkflowUsingScope(execution, controllerScope); + LOG.debug("Health check workflow fetched for the scope: {} is: {}", controllerScope, wflName); + + if ("pnf".equalsIgnoreCase(controllerScope)) { + validateParamsWithScope(execution, controllerScope, PNF_SWU_PARAMS); + LOG.info("Parameters validated successfully for {}", wflName); + execution.setVariable(ServiceLevelConstants.SOFTWARE_WORKFLOW_TO_INVOKE, wflName); + execution.setVariable(ServiceLevelConstants.CONTROLLER_STATUS, ""); + } + + } else { + exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, + "Controller scope not found to invoke resource level health check"); + } + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/UpdateServiceInstanceInAai.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/UpdateServiceInstanceInAai.java new file mode 100644 index 0000000000..c9bd607b8b --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/UpdateServiceInstanceInAai.java @@ -0,0 +1,123 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.service.level.impl; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aaiclient.client.aai.AAIRestClientI; +import org.onap.aaiclient.client.aai.AAIRestClientImpl; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.io.IOException; +import java.util.Optional; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_MODEL_INFO; + +@Component +public class UpdateServiceInstanceInAai implements JavaDelegate { + + @Autowired + private ExceptionBuilder exceptionUtil; + + private final Logger logger = LoggerFactory.getLogger(getClass()); + private static final String BPMN_REQUEST = "bpmnRequest"; + private static final String PNF_RESOURCE = "pnf"; + private static final String SERVICE_INSTANCE_ID = "serviceInstanceId"; + + // ERROR CODE for variable not found in the delegation Context + private static final int ERROR_CODE = 601; + + @Autowired + private ObjectMapper mapper; + + @Override + public void execute(DelegateExecution delegateExecution) throws Exception { + logger.debug("Running execute block for activity id: {}, name: {}", delegateExecution.getCurrentActivityId(), + delegateExecution.getCurrentActivityName()); + + RequestDetails bpmnRequestDetails = requestVerification(delegateExecution); + + final String serviceInstanceId = String.valueOf(delegateExecution.getVariable(SERVICE_INSTANCE_ID)); + final String serviceType = bpmnRequestDetails.getRequestParameters().getSubscriptionServiceType(); + final String globalSubscriberId = bpmnRequestDetails.getSubscriberInfo().getGlobalSubscriberId(); + + final String modelId = bpmnRequestDetails.getModelInfo().getModelUuid(); + + if (PNF_RESOURCE.equalsIgnoreCase(serviceType)) { + getAndSetServiceInstance(serviceInstanceId, serviceType, globalSubscriberId, modelId); + } + + // TODO : handling for vnf + + logger.trace("Completed updating request for ServiceLevelUpgrade."); + } + + private void getAndSetServiceInstance(final String serviceInstanceId, final String serviceType, + final String globalSubscriberId, String modelVersionId) { + + AAIRestClientI restClient = new AAIRestClientImpl(); + + Optional<ServiceInstance> optionalSi = + restClient.getServiceInstanceById(serviceInstanceId, serviceType, globalSubscriberId); + + if (!optionalSi.isPresent()) { + // throwExceptionWithWarn(delegateExecution, "Unable to find the service instance: " + serviceInstanceId); + } + + ServiceInstance serviceInstance = optionalSi.get(); + + serviceInstance.setModelVersionId(modelVersionId); + + restClient.updateServiceInstance(serviceInstanceId, serviceType, globalSubscriberId, serviceInstance); + + } + + private RequestDetails requestVerification(DelegateExecution delegateExecution) throws IOException { + RequestDetails bpmnRequestDetails = mapper.readValue( + JsonUtils.getJsonValue(String.valueOf(delegateExecution.getVariable(BPMN_REQUEST)), "requestDetails"), + RequestDetails.class); + + throwIfNull(delegateExecution, bpmnRequestDetails.getModelInfo(), SERVICE_MODEL_INFO); + throwIfNull(delegateExecution, bpmnRequestDetails.getRequestInfo(), "RequestInfo"); + throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters(), "RequestParameters"); + throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters().getUserParams(), "UserParams"); + + return bpmnRequestDetails; + } + + private void throwIfNull(DelegateExecution delegateExecution, Object obj, String param) { + if (obj == null) { + throwExceptionWithWarn(delegateExecution, + "Unable to find the parameter: " + param + " in the execution context"); + } + } + + private void throwExceptionWithWarn(DelegateExecution delegateExecution, String exceptionMsg) { + logger.warn(exceptionMsg); + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, exceptionMsg); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java index a99ee7d2df..340b2776a4 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java @@ -28,6 +28,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; +import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelConstants; import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelPreparation; import org.onap.so.client.exception.ExceptionBuilder; import org.springframework.beans.factory.annotation.Autowired; @@ -38,9 +39,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; -import static org.onap.so.bpmn.infrastructure.service.level.AbstractServiceLevelPreparable.RESOURCE_TYPE; -import static org.onap.so.bpmn.infrastructure.service.level.AbstractServiceLevelPreparable.WORKFLOW_TO_INVOKE; - @RunWith(SpringJUnit4ClassRunner.class) @@ -50,10 +48,13 @@ public class ServiceLevelPreparationTest { private static final String TEST_PNF_SCOPE = "pnf"; private static final String TEST_PROCESS_KEY = "testProcessKey"; private static final String PROCESS_KEY_VALUE = "testProcessKeyValue"; - private static final List<String> PNF_HEALTH_CHECK_PARAMS = Arrays.asList("SERVICE_MODEL_INFO", - "SERVICE_INSTANCE_NAME", "PNF_CORRELATION_ID", "MODEL_UUID", "PNF_UUID", "PRC_BLUEPRINT_NAME", - "PRC_BLUEPRINT_VERSION", "PRC_CUSTOMIZATION_UUID", "RESOURCE_CUSTOMIZATION_UUID_PARAM", "PRC_INSTANCE_NAME", - "PRC_CONTROLLER_ACTOR", "REQUEST_PAYLOAD"); + private static final String BPMN_REQUEST = "bpmnRequest"; + private static final String RESOURCE_TYPE = "resourceType"; + private static final String SERVICE_INSTANCE_ID = "serviceInstanceId"; + private static final String PNF_NAME = "pnfName"; + private static final List<String> PNF_HEALTH_CHECK_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID, + ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST, ServiceLevelConstants.PNF_NAME); + private Map<String, String> pnfHealthCheckTestParams = new HashMap<>(); @Autowired @@ -89,6 +90,9 @@ public class ServiceLevelPreparationTest { } execution.setVariable(RESOURCE_TYPE, TEST_PNF_SCOPE); execution.setVariable(TEST_PROCESS_KEY, PROCESS_KEY_VALUE); + execution.setVariable(BPMN_REQUEST, "bpmnRequestValue"); + execution.setVariable(SERVICE_INSTANCE_ID, "serviceInstanceIdValue"); + execution.setVariable(PNF_NAME, "PnfDemo"); invalidExecution.setVariables(execution.getVariables()); } @@ -97,13 +101,13 @@ public class ServiceLevelPreparationTest { public void executePnfUpgradeSuccessTest() throws Exception { serviceLevelPrepare.execute(execution); // Expect the pnf health check workflow to be set in to execution if validation is successful - assertThat(String.valueOf(execution.getVariable(WORKFLOW_TO_INVOKE))).isEqualTo("GenericPnfHealthCheck"); + assertThat(String.valueOf(execution.getVariable(ServiceLevelConstants.WORKFLOW_TO_INVOKE))) + .isEqualTo("GenericPnfHealthCheck"); } @Test public void validateFailureParamsForPnfTest() throws Exception { - invalidExecution.removeVariable("PNF_UUID"); - invalidExecution.setVariable("PRC_BLUEPRINT_NAME", null); + invalidExecution.removeVariable(BPMN_REQUEST); // BPMN exception is thrown in case of validation failure or invalid execution thrown.expect(BpmnError.class); serviceLevelPrepare.validateParamsWithScope(invalidExecution, TEST_PNF_SCOPE, PNF_HEALTH_CHECK_PARAMS); diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientI.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientI.java index ef6ca00a32..3b08761568 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientI.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientI.java @@ -26,6 +26,7 @@ import java.util.Optional; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.Pnf; import org.onap.aai.domain.yang.Pserver; +import org.onap.aai.domain.yang.ServiceInstance; public interface AAIRestClientI { @@ -40,4 +41,10 @@ public interface AAIRestClientI { void createPnf(String pnfId, Pnf pnf); void updatePnf(String pnfId, Pnf pnf); + + Optional<ServiceInstance> getServiceInstanceById(String serviceInstanceId, String serviceType, + String globalSubscriberId); + + void updateServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId, + ServiceInstance serviceInstance); } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientImpl.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientImpl.java index 886891a34e..0aff965ac0 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientImpl.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientImpl.java @@ -31,14 +31,18 @@ import javax.ws.rs.core.Response; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.Pnf; import org.onap.aai.domain.yang.Pserver; +import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aaiclient.client.aai.entities.CustomQuery; import org.onap.aaiclient.client.aai.entities.Results; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.aaiclient.client.graphinventory.Format; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AAIRestClientImpl implements AAIRestClientI { + private final Logger log = LoggerFactory.getLogger(getClass()); private static final String PSERVER_VNF_QUERY = "pservers-fromVnf"; @Override @@ -97,4 +101,24 @@ public class AAIRestClientImpl implements AAIRestClientI { public void updatePnf(String pnfId, Pnf pnf) { new AAIResourcesClient().update(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId), pnf); } + + @Override + public Optional<ServiceInstance> getServiceInstanceById(String globalSubscriberId, String serviceType, + String serviceInstanceId) { + Response response = new AAIResourcesClient().getFullResponse(AAIUriFactory + .createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId)); + return Optional.ofNullable(response.readEntity(ServiceInstance.class)); + } + + @Override + public void updateServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId, + ServiceInstance serviceInstance) { + try { + new AAIResourcesClient().update(AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalSubscriberId, serviceType, serviceInstanceId), serviceInstance); + } catch (Throwable ex) { + log.error("Exception happened while updating ServiceInstance, Exception: {}", ex.getLocalizedMessage()); + throw new RuntimeException(ex); + } + } } |