Pass parameters from SDNC response to APP-C. 65/49365/1
authorElena Kuleshov <ek1439@att.com>
Tue, 29 May 2018 13:25:41 +0000 (09:25 -0400)
committerElena Kuleshov <ek1439@att.com>
Tue, 29 May 2018 13:49:06 +0000 (09:49 -0400)
Change-Id: I7d83ee933361ca16d9b05639bfb84b9c1466887c
Issue-ID: SO-602
Signed-off-by: Elena Kuleshov <ek1439@att.com>
bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy
bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn

index 797086b..ca0bb53 100644 (file)
@@ -23,6 +23,15 @@ package org.openecomp.mso.bpmn.infrastructure.scripts;
 import groovy.json.JsonSlurper\r
 import groovy.json.JsonOutput\r
 \r
+import javax.xml.parsers.DocumentBuilder\r
+import javax.xml.parsers.DocumentBuilderFactory\r
+\r
+import org.w3c.dom.Document\r
+import org.w3c.dom.Element\r
+import org.w3c.dom.Node\r
+import org.w3c.dom.NodeList\r
+import org.xml.sax.InputSource\r
+\r
 import org.camunda.bpm.engine.delegate.BpmnError\r
 import org.camunda.bpm.engine.delegate.DelegateExecution\r
 import org.onap.appc.client.lcm.model.Action\r
@@ -42,6 +51,12 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor {
 \r
        ExceptionUtil exceptionUtil = new ExceptionUtil()\r
        JsonUtils jsonUtil = new JsonUtils()\r
+       \r
+       private AbstractServiceTaskProcessor taskProcessor\r
+       \r
+       public SDNCAdapterUtils(AbstractServiceTaskProcessor taskProcessor) {\r
+               this.taskProcessor = taskProcessor\r
+       }       \r
 \r
        /**\r
         * Validates the request message and sets up the workflow.\r
@@ -308,6 +323,50 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor {
                        }\r
                }\r
        }\r
+       \r
+       /**\r
+        * Retrieve data for ConfigScaleOut from SDNC topology\r
+        */\r
+       \r
+       public void retreiveConfigScaleOutData(DelegateExecution execution){\r
+               def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
+               def vfModuleName = execution.getVariable("CVFMI_vfModuleName")\r
+               String ipAddress = "";\r
+               String oamIpAddress = "";\r
+               String vnfHostIpAddress = "";\r
+\r
+               String vnfGetSDNC = execution.getVariable("DCVFM_getSDNCAdapterResponse");\r
+\r
+               String data = utils.getNodeXml(vnfGetSDNC, "response-data")\r
+               data = data.replaceAll("&lt;", "<")\r
+               data = data.replaceAll("&gt;", ">")\r
+\r
+               InputSource source = new InputSource(new StringReader(data));\r
+               DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();\r
+               docFactory.setNamespaceAware(true)\r
+               DocumentBuilder docBuilder = docFactory.newDocumentBuilder()\r
+               Document responseXml = docBuilder.parse(source)\r
+\r
+               NodeList paramsList = responseXml.getElementsByTagNameNS("*", "vnf-parameters")\r
+               for (int z = 0; z < paramsList.getLength(); z++) {\r
+                       Node node = paramsList.item(z)\r
+                       Element eElement = (Element) node\r
+                       String vnfParameterName = utils.getElementText(eElement, "vnf-parameter-name")\r
+                       String vnfParameterValue = utils.getElementText(eElement, "vnf-parameter-value")\r
+                       if (vnfParameterName.equals("vlb_private_ip_1")) {\r
+                               vnfHostIpAddress = vnfParameterValue\r
+                       }\r
+                       else if (vnfParameterName.equals("vdns_private_ip_0")) {\r
+                               ipAddress = vnfParameterValue\r
+                       }\r
+                       else if (vnfParameterName.equals("vdns_private_ip_1")) {                        \r
+                               oamIpAddress = vnfParameterValue\r
+                       }\r
+               }\r
+\r
+               String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":" + vnfHostIpAddress + ",\"vf-module-id\":" + vfModuleName + "},\"configuration-parameters\":{\"ip-addr\":" + ipAddress +", \"oam-ip-addr\":"+ oamIpAddress +",\"enabled\":\"true\"}}"\r
+               execution.setVariable("payload", payload);\r
+       }\r
 \r
        /**\r
         *\r
index f882094..b042209 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_pNTO8MRhEeWv36YLr7PC3Q" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
+<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_pNTO8MRhEeWv36YLr7PC3Q" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.2" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
   <bpmn2:process id="CreateVfModuleInfra" name="CreateVfModuleInfra" isExecutable="true">
     <bpmn2:startEvent id="StartEvent_1" name="Start">
       <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
@@ -38,6 +38,7 @@
         <camunda:in source="CVFMI_usePreload" target="usePreload" />
         <camunda:in source="CVFMI_vfModuleInputParams" target="vfModuleInputParams" />
         <camunda:in source="CVFMI_aLaCarte" target="aLaCarte" />
+        <camunda:out source="DCVFM_getSDNCAdapterResponse" target="DCVFM_getSDNCAdapterResponse" />
       </bpmn2:extensionElements>
       <bpmn2:incoming>SequenceFlow_1y7d5qk</bpmn2:incoming>
       <bpmn2:incoming>SequenceFlow_1vx081s</bpmn2:incoming>
@@ -255,7 +256,7 @@ exceptionUtil.processJavaException(execution)]]></bpmn2:script>
         <camunda:out source="failedActivity" target="failedActivity" />
         <camunda:in source="CVFMI_vfModuleId" target="vfModuleId" />
       </bpmn2:extensionElements>
-      <bpmn2:incoming>SequenceFlow_020dbkp</bpmn2:incoming>
+      <bpmn2:incoming>SequenceFlow_09i6f7t</bpmn2:incoming>
       <bpmn2:outgoing>SequenceFlow_1tk5ru7</bpmn2:outgoing>
     </bpmn2:callActivity>
     <bpmn2:sequenceFlow id="SequenceFlow_1crl7uf" sourceRef="ServiceTask_1" targetRef="UpdateInfraRequestResponseCheck" />
@@ -287,7 +288,7 @@ exceptionUtil.processJavaException(execution)]]></bpmn2:script>
       <bpmn2:outgoing>SequenceFlow_020dbkp</bpmn2:outgoing>
       <bpmn2:outgoing>SequenceFlow_0u8zesf</bpmn2:outgoing>
     </bpmn2:exclusiveGateway>
-    <bpmn2:sequenceFlow id="SequenceFlow_020dbkp" name="yes" sourceRef="ExclusiveGateway_0c8x2mq" targetRef="CallActivity_17ukiqm">
+    <bpmn2:sequenceFlow id="SequenceFlow_020dbkp" name="yes" sourceRef="ExclusiveGateway_0c8x2mq" targetRef="Task_09om99x">
       <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression" language="groovy"><![CDATA[execution.getVariable("runConfigScaleOut")]]></bpmn2:conditionExpression>
     </bpmn2:sequenceFlow>
     <bpmn2:sequenceFlow id="SequenceFlow_0u8zesf" name="no" sourceRef="ExclusiveGateway_0c8x2mq" targetRef="PrepareMSOCompletionHandler" />
@@ -299,6 +300,14 @@ exceptionUtil.processJavaException(execution)]]></bpmn2:script>
 def createVfModule = new CreateVfModuleInfra()
 createVfModule.queryAAIForVnfOrchestrationStatus(execution)]]></bpmn2:script>
     </bpmn2:scriptTask>
+    <bpmn2:sequenceFlow id="SequenceFlow_09i6f7t" sourceRef="Task_09om99x" targetRef="CallActivity_17ukiqm" />
+    <bpmn2:scriptTask id="Task_09om99x" name="Retreive Data for Config ScaleOut" scriptFormat="groovy">
+      <bpmn2:incoming>SequenceFlow_020dbkp</bpmn2:incoming>
+      <bpmn2:outgoing>SequenceFlow_09i6f7t</bpmn2:outgoing>
+      <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.*
+def createVfModule = new CreateVfModuleInfra()
+createVfModule.retreiveConfigScaleOutData(execution)]]></bpmn2:script>
+    </bpmn2:scriptTask>
   </bpmn2:process>
   <bpmn2:error id="Error_1" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
   <bpmn2:error id="Error_2" name="REST Fault" errorCode="RESTFault" />
@@ -582,7 +591,7 @@ createVfModule.queryAAIForVnfOrchestrationStatus(execution)]]></bpmn2:script>
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="CallActivity_17ukiqm_di" bpmnElement="CallActivity_17ukiqm">
-        <dc:Bounds x="472" y="189" width="145" height="80" />
+        <dc:Bounds x="472" y="120" width="145" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_1crl7uf_di" bpmnElement="SequenceFlow_1crl7uf">
         <di:waypoint xsi:type="dc:Point" x="377" y="367" />
@@ -592,36 +601,36 @@ createVfModule.queryAAIForVnfOrchestrationStatus(execution)]]></bpmn2:script>
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="ExclusiveGateway_1hncvjy_di" bpmnElement="ExclusiveGateway_1hncvjy" isMarkerVisible="true">
-        <dc:Bounds x="675" y="204" width="50" height="50" />
+        <dc:Bounds x="675" y="135" width="50" height="50" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="657" y="170" width="86" height="24" />
+          <dc:Bounds x="659" y="101" width="82" height="24" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_1tk5ru7_di" bpmnElement="SequenceFlow_1tk5ru7">
-        <di:waypoint xsi:type="dc:Point" x="617" y="229" />
-        <di:waypoint xsi:type="dc:Point" x="675" y="229" />
+        <di:waypoint xsi:type="dc:Point" x="617" y="160" />
+        <di:waypoint xsi:type="dc:Point" x="675" y="160" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="601" y="208" width="90" height="12" />
+          <dc:Bounds x="601" y="139" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0td7d9m_di" bpmnElement="SequenceFlow_0td7d9m">
-        <di:waypoint xsi:type="dc:Point" x="700" y="254" />
-        <di:waypoint xsi:type="dc:Point" x="701" y="327" />
+        <di:waypoint xsi:type="dc:Point" x="700" y="185" />
+        <di:waypoint xsi:type="dc:Point" x="702" y="327" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="706.5002014596164" y="260.46992001430345" width="15" height="12" />
+          <dc:Bounds x="708" y="122" width="12" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="EndEvent_0a97jcr_di" bpmnElement="EndEvent_0a97jcr">
-        <dc:Bounds x="773" y="211" width="36" height="36" />
+        <dc:Bounds x="773" y="142" width="36" height="36" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="701" y="252" width="90" height="12" />
+          <dc:Bounds x="701" y="183" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_0h5cld9_di" bpmnElement="SequenceFlow_0h5cld9">
-        <di:waypoint xsi:type="dc:Point" x="725" y="229" />
-        <di:waypoint xsi:type="dc:Point" x="773" y="229" />
+        <di:waypoint xsi:type="dc:Point" x="725" y="160" />
+        <di:waypoint xsi:type="dc:Point" x="773" y="160" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="729" y="235" width="20" height="12" />
+          <dc:Bounds x="730" y="166" width="18" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="ExclusiveGateway_1qozral_di" bpmnElement="ExclusiveGateway_1qozral" isMarkerVisible="true">
@@ -652,9 +661,9 @@ createVfModule.queryAAIForVnfOrchestrationStatus(execution)]]></bpmn2:script>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_020dbkp_di" bpmnElement="SequenceFlow_020dbkp">
         <di:waypoint xsi:type="dc:Point" x="545" y="342" />
-        <di:waypoint xsi:type="dc:Point" x="545" y="269" />
+        <di:waypoint xsi:type="dc:Point" x="545" y="309" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="550" y="307" width="20" height="12" />
+          <dc:Bounds x="515" y="321.9537912405942" width="18" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0u8zesf_di" bpmnElement="SequenceFlow_0u8zesf">
@@ -674,6 +683,16 @@ createVfModule.queryAAIForVnfOrchestrationStatus(execution)]]></bpmn2:script>
       <bpmndi:BPMNShape id="ScriptTask_19vqej7_di" bpmnElement="Task_1o3z68c">
         <dc:Bounds x="460" y="-6" width="100" height="80" />
       </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_09i6f7t_di" bpmnElement="SequenceFlow_09i6f7t">
+        <di:waypoint xsi:type="dc:Point" x="545" y="229" />
+        <di:waypoint xsi:type="dc:Point" x="545" y="200" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="560" y="208.5" width="0" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="ScriptTask_1s0bky7_di" bpmnElement="Task_09om99x">
+        <dc:Bounds x="495" y="229" width="100" height="80" />
+      </bpmndi:BPMNShape>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>
 </bpmn2:definitions>