From 8250deb396c4c7a9e7b29d98dda8115c4912e8de Mon Sep 17 00:00:00 2001 From: Elena Kuleshov Date: Tue, 29 May 2018 09:25:41 -0400 Subject: Pass parameters from SDNC response to APP-C. Change-Id: I7d83ee933361ca16d9b05639bfb84b9c1466887c Issue-ID: SO-602 Signed-off-by: Elena Kuleshov --- .../scripts/CreateVfModuleInfra.groovy | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp') diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy index 797086b125..ca0bb53dc1 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy @@ -23,6 +23,15 @@ package org.openecomp.mso.bpmn.infrastructure.scripts; import groovy.json.JsonSlurper import groovy.json.JsonOutput +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory + +import org.w3c.dom.Document +import org.w3c.dom.Element +import org.w3c.dom.Node +import org.w3c.dom.NodeList +import org.xml.sax.InputSource + import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.appc.client.lcm.model.Action @@ -42,6 +51,12 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() + + private AbstractServiceTaskProcessor taskProcessor + + public SDNCAdapterUtils(AbstractServiceTaskProcessor taskProcessor) { + this.taskProcessor = taskProcessor + } /** * Validates the request message and sets up the workflow. @@ -308,6 +323,50 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { } } } + + /** + * Retrieve data for ConfigScaleOut from SDNC topology + */ + + public void retreiveConfigScaleOutData(DelegateExecution execution){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def vfModuleName = execution.getVariable("CVFMI_vfModuleName") + String ipAddress = ""; + String oamIpAddress = ""; + String vnfHostIpAddress = ""; + + String vnfGetSDNC = execution.getVariable("DCVFM_getSDNCAdapterResponse"); + + String data = utils.getNodeXml(vnfGetSDNC, "response-data") + data = data.replaceAll("<", "<") + data = data.replaceAll(">", ">") + + InputSource source = new InputSource(new StringReader(data)); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + docFactory.setNamespaceAware(true) + DocumentBuilder docBuilder = docFactory.newDocumentBuilder() + Document responseXml = docBuilder.parse(source) + + NodeList paramsList = responseXml.getElementsByTagNameNS("*", "vnf-parameters") + for (int z = 0; z < paramsList.getLength(); z++) { + Node node = paramsList.item(z) + Element eElement = (Element) node + String vnfParameterName = utils.getElementText(eElement, "vnf-parameter-name") + String vnfParameterValue = utils.getElementText(eElement, "vnf-parameter-value") + if (vnfParameterName.equals("vlb_private_ip_1")) { + vnfHostIpAddress = vnfParameterValue + } + else if (vnfParameterName.equals("vdns_private_ip_0")) { + ipAddress = vnfParameterValue + } + else if (vnfParameterName.equals("vdns_private_ip_1")) { + oamIpAddress = vnfParameterValue + } + } + + String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":" + vnfHostIpAddress + ",\"vf-module-id\":" + vfModuleName + "},\"configuration-parameters\":{\"ip-addr\":" + ipAddress +", \"oam-ip-addr\":"+ oamIpAddress +",\"enabled\":\"true\"}}" + execution.setVariable("payload", payload); + } /** * -- cgit 1.2.3-korg