From 6c009875e53796b0b79a7bd8010590651d2af028 Mon Sep 17 00:00:00 2001 From: Eric Multanen Date: Tue, 30 Apr 2019 01:20:09 -0700 Subject: build sndc and user directives in groovy Fill out the sdnc_directives and user_directives used by the multicloud vnf plugin adapter when invoked via the groovy path. Change-Id: Ia11680be682b38756f188c71e3e000bc21c15aa9 Issue-ID: SO-1822 Signed-off-by: Eric Multanen --- .../so/bpmn/common/scripts/VfModuleBase.groovy | 2300 ++++++++++---------- .../infrastructure/scripts/DoCreateVfModule.groovy | 4 +- .../scripts/DoCreateVfModuleTest.groovy | 17 +- .../__files/DoCreateVfModule/createVnfARequest.xml | 22 +- 4 files changed, 1227 insertions(+), 1116 deletions(-) (limited to 'bpmn') diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy index c4ef165f63..07d8ec9b8e 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy @@ -9,9 +9,9 @@ * 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. @@ -40,839 +40,924 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger( VfModuleBase.class); - protected XmlParser xmlParser = new XmlParser() - - /** - * Get the XmlParser. - * - * @return the XmlParser. - */ - protected XmlParser getXmlParser() { - return xmlParser - } - - /** - * Find the VF Module with specified ID in the specified Generic VF. If no such - * VF Module is found, null is returned. - * - * @param genericVnf The Generic VNF in which to search for the specified VF Moduel. - * @param vfModuleId The ID of the VF Module for which to search. - * @return a VFModule object for the found VF Module or null if no VF Module is found. - */ - protected VfModule findVfModule(String genericVnf, String vfModuleId) { - - def genericVnfNode = xmlParser.parseText(genericVnf) - def vfModulesNode = utils.getChildNode(genericVnfNode, 'vf-modules') - if (vfModulesNode == null) { - return null - } - def vfModuleList = utils.getIdenticalChildren(vfModulesNode, 'vf-module') - for (vfModuleNode in vfModuleList) { - def vfModuleIdNode = utils.getChildNode(vfModuleNode, 'vf-module-id') - if ((vfModuleIdNode != null) && (vfModuleIdNode.text().equals(vfModuleId))) { - return new VfModule(vfModuleNode, (vfModuleList.size() == 1)) - } - } - return null - } - - /** - * Transform all '*_network' parameter specifications from the incoming '*-params' root - * element to a corresponding list of 'vnf-networks' specifications (typically used when - * invoking the VNF Rest Adpater). Each element in '*-params' whose name attribute ends - * with '_network' is used to create an 'vnf-networks' element. - * - * @param paramsNode A Node representing a '*-params' element. - * @return a String of 'vnf-networks' elements, one for each 'param' element whose name - * attribute ends with '_network'. - */ - protected String transformNetworkParamsToVnfNetworks(String paramsRootXml) { - if ((paramsRootXml == null) || (paramsRootXml.isEmpty())) { - return '' - } - def String vnfNetworks = '' - try { - paramsRootXml = utils.removeXmlNamespaces(paramsRootXml) - def paramsNode = xmlParser.parseText(paramsRootXml) - def params = utils.getIdenticalChildren(paramsNode, 'param') - for (param in params) { - def String attrName = (String) param.attribute('name') - if (attrName.endsWith('_network')) { - def networkRole = attrName.substring(0, (attrName.length()-'_network'.length())) - def networkName = param.text() - String vnfNetwork = """ + protected XmlParser xmlParser = new XmlParser() + + /** + * Get the XmlParser. + * + * @return the XmlParser. + */ + protected XmlParser getXmlParser() { + return xmlParser + } + + /** + * Find the VF Module with specified ID in the specified Generic VF. If no such + * VF Module is found, null is returned. + * + * @param genericVnf The Generic VNF in which to search for the specified VF Moduel. + * @param vfModuleId The ID of the VF Module for which to search. + * @return a VFModule object for the found VF Module or null if no VF Module is found. + */ + protected VfModule findVfModule(String genericVnf, String vfModuleId) { + + def genericVnfNode = xmlParser.parseText(genericVnf) + def vfModulesNode = utils.getChildNode(genericVnfNode, 'vf-modules') + if (vfModulesNode == null) { + return null + } + def vfModuleList = utils.getIdenticalChildren(vfModulesNode, 'vf-module') + for (vfModuleNode in vfModuleList) { + def vfModuleIdNode = utils.getChildNode(vfModuleNode, 'vf-module-id') + if ((vfModuleIdNode != null) && (vfModuleIdNode.text().equals(vfModuleId))) { + return new VfModule(vfModuleNode, (vfModuleList.size() == 1)) + } + } + return null + } + + /** + * Transform all '*_network' parameter specifications from the incoming '*-params' root + * element to a corresponding list of 'vnf-networks' specifications (typically used when + * invoking the VNF Rest Adpater). Each element in '*-params' whose name attribute ends + * with '_network' is used to create an 'vnf-networks' element. + * + * @param paramsNode A Node representing a '*-params' element. + * @return a String of 'vnf-networks' elements, one for each 'param' element whose name + * attribute ends with '_network'. + */ + protected String transformNetworkParamsToVnfNetworks(String paramsRootXml) { + if ((paramsRootXml == null) || (paramsRootXml.isEmpty())) { + return '' + } + def String vnfNetworks = '' + try { + paramsRootXml = utils.removeXmlNamespaces(paramsRootXml) + def paramsNode = xmlParser.parseText(paramsRootXml) + def params = utils.getIdenticalChildren(paramsNode, 'param') + for (param in params) { + def String attrName = (String) param.attribute('name') + if (attrName.endsWith('_network')) { + def networkRole = attrName.substring(0, (attrName.length()-'_network'.length())) + def networkName = param.text() + String vnfNetwork = """ ${MsoUtils.xmlEscape(networkRole)} ${MsoUtils.xmlEscape(networkName)} """ - vnfNetworks = vnfNetworks + vnfNetwork - } - } - } catch (Exception e) { - logger.warn("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(), - 'Exception transforming network params to vnfNetworks', "BPMN", - ErrorCode.UnknownError.getValue(), 'Exception is: \n' + e); - } - return vnfNetworks - } - - /** - * Transform the parameter specifications from the incoming '*-params' root element to - * a corresponding list of 'entry's (typically used when invoking the VNF Rest Adpater). - * Each element in '*-params' is used to create an 'entry' element. - * - * @param paramsNode A Node representing a '*-params' element. - * @return a String of 'entry' elements, one for each 'param' element. - */ - protected String transformParamsToEntries(String paramsRootXml) { - if ((paramsRootXml == null) || (paramsRootXml.isEmpty())) { - return '' - } - def String entries = '' - try { - paramsRootXml = utils.removeXmlNamespaces(paramsRootXml) - def paramsNode = xmlParser.parseText(paramsRootXml) - def params = utils.getIdenticalChildren(paramsNode, 'param') - for (param in params) { - def key = (String) param.attribute('name') - if (key == null) { - key = '' - } - def value = (String) param.text() - String entry = """ + vnfNetworks = vnfNetworks + vnfNetwork + } + } + } catch (Exception e) { + logger.warn("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(), + 'Exception transforming network params to vnfNetworks', "BPMN", + ErrorCode.UnknownError.getValue(), 'Exception is: \n' + e); + } + return vnfNetworks + } + + /** + * Transform the parameter specifications from the incoming '*-params' root element to + * a corresponding list of 'entry's (typically used when invoking the VNF Rest Adpater). + * Each element in '*-params' is used to create an 'entry' element. + * + * @param paramsNode A Node representing a '*-params' element. + * @return a String of 'entry' elements, one for each 'param' element. + */ + protected String transformParamsToEntries(String paramsRootXml) { + if ((paramsRootXml == null) || (paramsRootXml.isEmpty())) { + return '' + } + def String entries = '' + try { + paramsRootXml = utils.removeXmlNamespaces(paramsRootXml) + def paramsNode = xmlParser.parseText(paramsRootXml) + def params = utils.getIdenticalChildren(paramsNode, 'param') + for (param in params) { + def key = (String) param.attribute('name') + if (key == null) { + key = '' + } + def value = (String) param.text() + String entry = """ ${MsoUtils.xmlEscape(key)} ${MsoUtils.xmlEscape(value)} """ - entries = entries + entry - } - } catch (Exception e) { - logger.warn("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(), - 'Exception transforming params to entries', "BPMN", - ErrorCode.UnknownError.getValue(), 'Exception transforming params to entries' + e); - } - return entries - } - - /** - * Transform the parameter specifications from the incoming '*-params' root element to - * a corresponding list of 'entry's (typically used when invoking the VNF Rest Adpater). - * Each element in '*-params' is used to create an 'entry' element. - * - * @param paramsNode A Node representing a '*-params' element. - * @return a String of 'entry' elements, one for each 'param' element. - */ - protected String transformVolumeParamsToEntries(String paramsRootXml) { - if ((paramsRootXml == null) || (paramsRootXml.isEmpty())) { - return '' - } - def String entries = '' - try { - paramsRootXml = utils.removeXmlNamespaces(paramsRootXml) - def paramsNode = xmlParser.parseText(paramsRootXml) - def params = utils.getIdenticalChildren(paramsNode, 'param') - for (param in params) { - def key = (String) param.attribute('name') - if (key == null) { - key = '' - } - if ( !(key in ['vnf_id', 'vnf_name', 'vf_module_id', 'vf_module_name'])) { - def value = (String) param.text() - String entry = """ + entries = entries + entry + } + } catch (Exception e) { + logger.warn("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(), + 'Exception transforming params to entries', "BPMN", + ErrorCode.UnknownError.getValue(), 'Exception transforming params to entries' + e); + } + return entries + } + + /** + * Transform the parameter specifications from the incoming '*-params' root element to + * a corresponding list of 'entry's (typically used when invoking the VNF Rest Adpater). + * Each element in '*-params' is used to create an 'entry' element. + * + * @param paramsNode A Node representing a '*-params' element. + * @return a String of 'entry' elements, one for each 'param' element. + */ + protected String transformVolumeParamsToEntries(String paramsRootXml) { + if ((paramsRootXml == null) || (paramsRootXml.isEmpty())) { + return '' + } + def String entries = '' + try { + paramsRootXml = utils.removeXmlNamespaces(paramsRootXml) + def paramsNode = xmlParser.parseText(paramsRootXml) + def params = utils.getIdenticalChildren(paramsNode, 'param') + for (param in params) { + def key = (String) param.attribute('name') + if (key == null) { + key = '' + } + if ( !(key in [ + 'vnf_id', + 'vnf_name', + 'vf_module_id', + 'vf_module_name' + ])) { + def value = (String) param.text() + String entry = """ ${MsoUtils.xmlEscape(key)} ${MsoUtils.xmlEscape(value)} """ - entries = entries + entry - } - } - } catch (Exception e) { - logger.warn("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(), - 'Exception transforming params to entries', "BPMN", - ErrorCode.UnknownError.getValue(), 'Exception transforming params to entries' + e); - } - return entries - } - - /* - * Parses VNF parameters passed in on the incoming requests and SDNC parameters returned from SDNC get response - * and puts them into the format expected by VNF adapter. - * @param vnfParamsMap - map of VNF parameters passed in the request body - * @param sdncGetResponse - response string from SDNC GET topology request - * @param vnfId - * @param vnfName - * @param vfModuleId - * @param vfModuleName - * @param vfModuleIndex - can be null - * @return a String of key/value entries for vfModuleParams - */ - - - protected String buildVfModuleParams(Map vnfParamsMap, String sdncGetResponse, String vnfId, String vnfName, - String vfModuleId, String vfModuleName, String vfModuleIndex, String environmentContext, String workloadContext) { - - //Get SDNC Response Data - - String data = utils.getNodeXml(sdncGetResponse, "response-data") - - String serviceData = utils.getNodeXml(data, "service-data") - serviceData = utils.removeXmlPreamble(serviceData) - serviceData = utils.removeXmlNamespaces(serviceData) - String vnfRequestInfo = utils.getNodeXml(serviceData, "vnf-request-information") - String oldVnfId = utils.getNodeXml(vnfRequestInfo, "vnf-id") - oldVnfId = utils.removeXmlPreamble(oldVnfId) - oldVnfId = utils.removeXmlNamespaces(oldVnfId) - serviceData = serviceData.replace(oldVnfId, "") - def vnfId1 = utils.getNodeText(serviceData, "vnf-id") - - Map paramsMap = new HashMap() - - if (vfModuleIndex != null) { - paramsMap.put("vf_module_index", "${vfModuleIndex}") - } - - // Add-on data - paramsMap.put("vnf_id", "${vnfId}") - paramsMap.put("vnf_name", "${vnfName}") - paramsMap.put("vf_module_id", "${vfModuleId}") - paramsMap.put("vf_module_name", "${vfModuleName}") - paramsMap.put("environment_context", "${environmentContext}") - paramsMap.put("workload_context", "${workloadContext}") - - InputSource source = new InputSource(new StringReader(data)); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - docFactory.setNamespaceAware(true) - DocumentBuilder docBuilder = docFactory.newDocumentBuilder() - Document responseXml = docBuilder.parse(source) - - - // Availability Zones Data - - NodeList aZonesList = responseXml.getElementsByTagNameNS("*", "availability-zones") - String aZonePosition = "0" - for (int z = 0; z < aZonesList.getLength(); z++) { - Node node = aZonesList.item(z) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - String aZoneValue = utils.getElementText(eElement, "availability-zone") - aZonePosition = z.toString() - paramsMap.put("availability_zone_${aZonePosition}", "${aZoneValue}") - } - } - - // Map of network-roles and network-tags from vm-networks - - NodeList vmNetworksListGlobal = responseXml.getElementsByTagNameNS("*", "vm-networks") - Map networkRoleMap = new HashMap() - for(int n = 0; n < vmNetworksListGlobal.getLength(); n++){ - Node nodeNetworkKey = vmNetworksListGlobal.item(n) - if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) { - Element eElementNetworkKey = (Element) nodeNetworkKey - String networkRole = utils.getElementText(eElementNetworkKey, "network-role") - String networkRoleValue = utils.getElementText(eElementNetworkKey, "network-role-tag") - if (networkRoleValue.isEmpty()) { - networkRoleValue = networkRole - } - networkRoleMap.put(networkRole, networkRoleValue) - } - } - - // VNF Networks Data - - StringBuilder sbNet = new StringBuilder() - - NodeList vnfNetworkList = responseXml.getElementsByTagNameNS("*", "vnf-networks") - for (int x = 0; x < vnfNetworkList.getLength(); x++) { - Node node = vnfNetworkList.item(x) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - String vnfNetworkKey = utils.getElementText(eElement, "network-role-tag") - String networkRole = utils.getElementText(eElement, "network-role") - if (vnfNetworkKey.isEmpty()) { - vnfNetworkKey = networkRoleMap.get(networkRole) - if (vnfNetworkKey == null || vnfNetworkKey.isEmpty()) { - vnfNetworkKey = networkRole - } - } - String vnfNetworkNeutronIdValue = utils.getElementText(eElement, "neutron-id") - String vnfNetworkNetNameValue = utils.getElementText(eElement, "network-name") - String vnfNetworkSubNetIdValue = utils.getElementText(eElement, "subnet-id") - String vnfNetworkV6SubNetIdValue = utils.getElementText(eElement, "ipv6-subnet-id") - String vnfNetworkNetFqdnValue = utils.getElementText(eElement, "contrail-network-fqdn") - paramsMap.put("${vnfNetworkKey}_net_id", "${vnfNetworkNeutronIdValue}") - paramsMap.put("${vnfNetworkKey}_net_name", "${vnfNetworkNetNameValue}") - paramsMap.put("${vnfNetworkKey}_subnet_id", "${vnfNetworkSubNetIdValue}") - paramsMap.put("${vnfNetworkKey}_v6_subnet_id", "${vnfNetworkV6SubNetIdValue}") - paramsMap.put("${vnfNetworkKey}_net_fqdn", "${vnfNetworkNetFqdnValue}") - - NodeList sriovVlanFilterList = eElement.getElementsByTagNameNS("*","sriov-vlan-filter-list") - StringBuffer sriovFilterBuf = new StringBuffer() - String values = "" - for(int i = 0; i < sriovVlanFilterList.getLength(); i++){ - Node node1 = sriovVlanFilterList.item(i) - if (node1.getNodeType() == Node.ELEMENT_NODE) { - Element eElement1 = (Element) node1 - String value = utils.getElementText(eElement1, "sriov-vlan-filter") - if (i != sriovVlanFilterList.getLength() - 1) { - values = sriovFilterBuf.append(value + ",") - } - else { - values = sriovFilterBuf.append(value); - } - } - } - if (!values.isEmpty()) { - paramsMap.put("${vnfNetworkKey}_ATT_VF_VLAN_FILTER", "${values}") - } - } - } - - // VNF-VMS Data - - def key - def value - def networkKey - def networkValue - def floatingIPKey - def floatingIPKeyValue - def floatingIPV6Key - def floatingIPV6KeyValue - StringBuilder sb = new StringBuilder() - - NodeList vmsList = responseXml.getElementsByTagNameNS("*","vnf-vms") - for (int x = 0; x < vmsList.getLength(); x++) { - Node node = vmsList.item(x) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - key = utils.getElementText(eElement, "vm-type") - String values - String position = "0" - StringBuilder sb1 = new StringBuilder() - NodeList valueList = eElement.getElementsByTagNameNS("*","vm-names") - NodeList vmNetworksList = eElement.getElementsByTagNameNS("*","vm-networks") - for(int i = 0; i < valueList.getLength(); i++){ - Node node1 = valueList.item(i) - if (node1.getNodeType() == Node.ELEMENT_NODE) { - Element eElement1 = (Element) node1 - value = utils.getElementText(eElement1, "vm-name") - if (i != valueList.getLength() - 1) { - values = sb1.append(value + ",") - } - else { - values = sb1.append(value); - } - position = i.toString() - paramsMap.put("${key}_name_${position}", "${value}") - } - } - for(int n = 0; n < vmNetworksList.getLength(); n++){ - String floatingIpKeyValueStr = "" - String floatingIpV6KeyValueStr = "" - Node nodeNetworkKey = vmNetworksList.item(n) - if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) { - Element eElementNetworkKey = (Element) nodeNetworkKey - String ipAddressValues - String ipV6AddressValues - String networkPosition = "0" - StringBuilder sb2 = new StringBuilder() - StringBuilder sb3 = new StringBuilder() - StringBuilder sb4 = new StringBuilder() - networkKey = utils.getElementText(eElementNetworkKey, "network-role-tag") - if (networkKey.isEmpty()) { - networkKey = utils.getElementText(eElementNetworkKey, "network-role") - } - floatingIPKey = key + '_' + networkKey + '_floating_ip' - floatingIPKeyValue = utils.getElementText(eElementNetworkKey, "floating-ip") - if(!floatingIPKeyValue.isEmpty()){ - paramsMap.put("$floatingIPKey", "$floatingIPKeyValue") - } - floatingIPV6Key = key + '_' + networkKey + '_floating_v6_ip' - floatingIPV6KeyValue = utils.getElementText(eElementNetworkKey, "floating-ip-v6") - if(!floatingIPV6KeyValue.isEmpty()){ - paramsMap.put("$floatingIPV6Key", "$floatingIPV6KeyValue") - } - NodeList networkIpsList = eElementNetworkKey.getElementsByTagNameNS("*","network-ips") - for(int a = 0; a < networkIpsList.getLength(); a++){ - Node ipAddress = networkIpsList.item(a) - if (ipAddress.getNodeType() == Node.ELEMENT_NODE) { - Element eElementIpAddress = (Element) ipAddress - String ipAddressValue = utils.getElementText(eElementIpAddress, "ip-address") - if (a != networkIpsList.getLength() - 1) { - ipAddressValues = sb2.append(ipAddressValue + ",") - } - else { - ipAddressValues = sb2.append(ipAddressValue); - } - networkPosition = a.toString() - paramsMap.put("${key}_${networkKey}_ip_${networkPosition}", "${ipAddressValue}") - } - } - - paramsMap.put("${key}_${networkKey}_ips", "${ipAddressValues}") - - NodeList interfaceRoutePrefixesList = eElementNetworkKey.getElementsByTagNameNS("*","interface-route-prefixes") - String interfaceRoutePrefixValues = sb3.append("[") - - for(int a = 0; a < interfaceRoutePrefixesList.getLength(); a++){ - Node interfaceRoutePrefix = interfaceRoutePrefixesList.item(a) - if (interfaceRoutePrefix.getNodeType() == Node.ELEMENT_NODE) { - Element eElementInterfaceRoutePrefix = (Element) interfaceRoutePrefix - String interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix-cidr") - if (interfaceRoutePrefixValue == null || interfaceRoutePrefixValue.isEmpty()) { - interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix") - } - if (a != interfaceRoutePrefixesList.getLength() - 1) { - interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}" + ",") - } - else { - interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}") - } - } - } - interfaceRoutePrefixValues = sb3.append("]") - if (interfaceRoutePrefixesList.getLength() > 0) { - paramsMap.put("${key}_${networkKey}_route_prefixes", "${interfaceRoutePrefixValues}") - } - - NodeList networkIpsV6List = eElementNetworkKey.getElementsByTagNameNS("*","network-ips-v6") - for(int a = 0; a < networkIpsV6List.getLength(); a++){ - Node ipV6Address = networkIpsV6List.item(a) - if (ipV6Address.getNodeType() == Node.ELEMENT_NODE) { - Element eElementIpV6Address = (Element) ipV6Address - String ipV6AddressValue = utils.getElementText(eElementIpV6Address, "ip-address-ipv6") - if (a != networkIpsV6List.getLength() - 1) { - ipV6AddressValues = sb4.append(ipV6AddressValue + ",") - } - else { - ipV6AddressValues = sb4.append(ipV6AddressValue); - } - networkPosition = a.toString() - paramsMap.put("${key}_${networkKey}_v6_ip_${networkPosition}", "${ipV6AddressValue}") - } - } - paramsMap.put("${key}_${networkKey}_v6_ips", "${ipV6AddressValues}") - } - } - paramsMap.put("${key}_names", "${values}") - } - } - //SDNC Response Params - String sdncResponseParams = "" - List sdncResponseParamsToSkip = ["vnf_id", "vf_module_id", "vnf_name", "vf_module_name"] - String vnfParamsChildNodes = utils.getChildNodes(data, "vnf-parameters") - if(vnfParamsChildNodes == null || vnfParamsChildNodes.length() < 1){ - // No SDNC params - }else{ - 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") - if (!sdncResponseParamsToSkip.contains(vnfParameterName)) { - String vnfParameterValue = utils.getElementText(eElement, "vnf-parameter-value") - paramsMap.put("${vnfParameterName}", "${vnfParameterValue}") - } - } - } - - // Parameters received from the request should overwrite any parameters received from SDNC - if (vnfParamsMap != null) { - for (Map.Entry entry : vnfParamsMap.entrySet()) { - String vnfKey = entry.getKey() - String vnfValue = entry.getValue() - paramsMap.put("$vnfKey", "$vnfValue") - } - } - - StringBuilder sbParams = new StringBuilder() - def vfModuleParams = "" - for (Map.Entry entry : paramsMap.entrySet()) { - String paramsXml - String paramName = entry.getKey() - String paramValue = entry.getValue() - paramsXml = - """ + entries = entries + entry + } + } + } catch (Exception e) { + logger.warn("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(), + 'Exception transforming params to entries', "BPMN", + ErrorCode.UnknownError.getValue(), 'Exception transforming params to entries' + e); + } + return entries + } + + /* + * Parses VNF parameters passed in on the incoming requests and SDNC parameters returned from SDNC get response + * and puts them into the format expected by VNF adapter. + * @param vnfParamsMap - map of VNF parameters passed in the request body + * @param sdncGetResponse - response string from SDNC GET topology request + * @param vnfId + * @param vnfName + * @param vfModuleId + * @param vfModuleName + * @param vfModuleIndex - can be null + * @return a String of key/value entries for vfModuleParams + */ + + + protected String buildVfModuleParams(Map vnfParamsMap, String sdncGetResponse, String vnfId, String vnfName, + String vfModuleId, String vfModuleName, String vfModuleIndex, String environmentContext, String workloadContext) { + + //Get SDNC Response Data + + String data = utils.getNodeXml(sdncGetResponse, "response-data") + + String serviceData = utils.getNodeXml(data, "service-data") + serviceData = utils.removeXmlPreamble(serviceData) + serviceData = utils.removeXmlNamespaces(serviceData) + String vnfRequestInfo = utils.getNodeXml(serviceData, "vnf-request-information") + String oldVnfId = utils.getNodeXml(vnfRequestInfo, "vnf-id") + oldVnfId = utils.removeXmlPreamble(oldVnfId) + oldVnfId = utils.removeXmlNamespaces(oldVnfId) + serviceData = serviceData.replace(oldVnfId, "") + def vnfId1 = utils.getNodeText(serviceData, "vnf-id") + + Map paramsMap = new HashMap() + + if (vfModuleIndex != null) { + paramsMap.put("vf_module_index", "${vfModuleIndex}") + } + + // Add-on data + paramsMap.put("vnf_id", "${vnfId}") + paramsMap.put("vnf_name", "${vnfName}") + paramsMap.put("vf_module_id", "${vfModuleId}") + paramsMap.put("vf_module_name", "${vfModuleName}") + paramsMap.put("environment_context", "${environmentContext}") + paramsMap.put("workload_context", "${workloadContext}") + + InputSource source = new InputSource(new StringReader(data)); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + docFactory.setNamespaceAware(true) + DocumentBuilder docBuilder = docFactory.newDocumentBuilder() + Document responseXml = docBuilder.parse(source) + + + // Availability Zones Data + + NodeList aZonesList = responseXml.getElementsByTagNameNS("*", "availability-zones") + String aZonePosition = "0" + for (int z = 0; z < aZonesList.getLength(); z++) { + Node node = aZonesList.item(z) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + String aZoneValue = utils.getElementText(eElement, "availability-zone") + aZonePosition = z.toString() + paramsMap.put("availability_zone_${aZonePosition}", "${aZoneValue}") + } + } + + // Map of network-roles and network-tags from vm-networks + + NodeList vmNetworksListGlobal = responseXml.getElementsByTagNameNS("*", "vm-networks") + Map networkRoleMap = new HashMap() + for(int n = 0; n < vmNetworksListGlobal.getLength(); n++){ + Node nodeNetworkKey = vmNetworksListGlobal.item(n) + if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) { + Element eElementNetworkKey = (Element) nodeNetworkKey + String networkRole = utils.getElementText(eElementNetworkKey, "network-role") + String networkRoleValue = utils.getElementText(eElementNetworkKey, "network-role-tag") + if (networkRoleValue.isEmpty()) { + networkRoleValue = networkRole + } + networkRoleMap.put(networkRole, networkRoleValue) + } + } + + // VNF Networks Data + + StringBuilder sbNet = new StringBuilder() + + NodeList vnfNetworkList = responseXml.getElementsByTagNameNS("*", "vnf-networks") + for (int x = 0; x < vnfNetworkList.getLength(); x++) { + Node node = vnfNetworkList.item(x) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + String vnfNetworkKey = utils.getElementText(eElement, "network-role-tag") + String networkRole = utils.getElementText(eElement, "network-role") + if (vnfNetworkKey.isEmpty()) { + vnfNetworkKey = networkRoleMap.get(networkRole) + if (vnfNetworkKey == null || vnfNetworkKey.isEmpty()) { + vnfNetworkKey = networkRole + } + } + String vnfNetworkNeutronIdValue = utils.getElementText(eElement, "neutron-id") + String vnfNetworkNetNameValue = utils.getElementText(eElement, "network-name") + String vnfNetworkSubNetIdValue = utils.getElementText(eElement, "subnet-id") + String vnfNetworkV6SubNetIdValue = utils.getElementText(eElement, "ipv6-subnet-id") + String vnfNetworkNetFqdnValue = utils.getElementText(eElement, "contrail-network-fqdn") + paramsMap.put("${vnfNetworkKey}_net_id", "${vnfNetworkNeutronIdValue}") + paramsMap.put("${vnfNetworkKey}_net_name", "${vnfNetworkNetNameValue}") + paramsMap.put("${vnfNetworkKey}_subnet_id", "${vnfNetworkSubNetIdValue}") + paramsMap.put("${vnfNetworkKey}_v6_subnet_id", "${vnfNetworkV6SubNetIdValue}") + paramsMap.put("${vnfNetworkKey}_net_fqdn", "${vnfNetworkNetFqdnValue}") + + NodeList sriovVlanFilterList = eElement.getElementsByTagNameNS("*","sriov-vlan-filter-list") + StringBuffer sriovFilterBuf = new StringBuffer() + String values = "" + for(int i = 0; i < sriovVlanFilterList.getLength(); i++){ + Node node1 = sriovVlanFilterList.item(i) + if (node1.getNodeType() == Node.ELEMENT_NODE) { + Element eElement1 = (Element) node1 + String value = utils.getElementText(eElement1, "sriov-vlan-filter") + if (i != sriovVlanFilterList.getLength() - 1) { + values = sriovFilterBuf.append(value + ",") + } + else { + values = sriovFilterBuf.append(value); + } + } + } + if (!values.isEmpty()) { + paramsMap.put("${vnfNetworkKey}_ATT_VF_VLAN_FILTER", "${values}") + } + } + } + + // VNF-VMS Data + + def key + def value + def networkKey + def networkValue + def floatingIPKey + def floatingIPKeyValue + def floatingIPV6Key + def floatingIPV6KeyValue + StringBuilder sb = new StringBuilder() + + NodeList vmsList = responseXml.getElementsByTagNameNS("*","vnf-vms") + for (int x = 0; x < vmsList.getLength(); x++) { + Node node = vmsList.item(x) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + key = utils.getElementText(eElement, "vm-type") + String values + String position = "0" + StringBuilder sb1 = new StringBuilder() + NodeList valueList = eElement.getElementsByTagNameNS("*","vm-names") + NodeList vmNetworksList = eElement.getElementsByTagNameNS("*","vm-networks") + for(int i = 0; i < valueList.getLength(); i++){ + Node node1 = valueList.item(i) + if (node1.getNodeType() == Node.ELEMENT_NODE) { + Element eElement1 = (Element) node1 + value = utils.getElementText(eElement1, "vm-name") + if (i != valueList.getLength() - 1) { + values = sb1.append(value + ",") + } + else { + values = sb1.append(value); + } + position = i.toString() + paramsMap.put("${key}_name_${position}", "${value}") + } + } + for(int n = 0; n < vmNetworksList.getLength(); n++){ + String floatingIpKeyValueStr = "" + String floatingIpV6KeyValueStr = "" + Node nodeNetworkKey = vmNetworksList.item(n) + if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) { + Element eElementNetworkKey = (Element) nodeNetworkKey + String ipAddressValues + String ipV6AddressValues + String networkPosition = "0" + StringBuilder sb2 = new StringBuilder() + StringBuilder sb3 = new StringBuilder() + StringBuilder sb4 = new StringBuilder() + networkKey = utils.getElementText(eElementNetworkKey, "network-role-tag") + if (networkKey.isEmpty()) { + networkKey = utils.getElementText(eElementNetworkKey, "network-role") + } + floatingIPKey = key + '_' + networkKey + '_floating_ip' + floatingIPKeyValue = utils.getElementText(eElementNetworkKey, "floating-ip") + if(!floatingIPKeyValue.isEmpty()){ + paramsMap.put("$floatingIPKey", "$floatingIPKeyValue") + } + floatingIPV6Key = key + '_' + networkKey + '_floating_v6_ip' + floatingIPV6KeyValue = utils.getElementText(eElementNetworkKey, "floating-ip-v6") + if(!floatingIPV6KeyValue.isEmpty()){ + paramsMap.put("$floatingIPV6Key", "$floatingIPV6KeyValue") + } + NodeList networkIpsList = eElementNetworkKey.getElementsByTagNameNS("*","network-ips") + for(int a = 0; a < networkIpsList.getLength(); a++){ + Node ipAddress = networkIpsList.item(a) + if (ipAddress.getNodeType() == Node.ELEMENT_NODE) { + Element eElementIpAddress = (Element) ipAddress + String ipAddressValue = utils.getElementText(eElementIpAddress, "ip-address") + if (a != networkIpsList.getLength() - 1) { + ipAddressValues = sb2.append(ipAddressValue + ",") + } + else { + ipAddressValues = sb2.append(ipAddressValue); + } + networkPosition = a.toString() + paramsMap.put("${key}_${networkKey}_ip_${networkPosition}", "${ipAddressValue}") + } + } + + paramsMap.put("${key}_${networkKey}_ips", "${ipAddressValues}") + + NodeList interfaceRoutePrefixesList = eElementNetworkKey.getElementsByTagNameNS("*","interface-route-prefixes") + String interfaceRoutePrefixValues = sb3.append("[") + + for(int a = 0; a < interfaceRoutePrefixesList.getLength(); a++){ + Node interfaceRoutePrefix = interfaceRoutePrefixesList.item(a) + if (interfaceRoutePrefix.getNodeType() == Node.ELEMENT_NODE) { + Element eElementInterfaceRoutePrefix = (Element) interfaceRoutePrefix + String interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix-cidr") + if (interfaceRoutePrefixValue == null || interfaceRoutePrefixValue.isEmpty()) { + interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix") + } + if (a != interfaceRoutePrefixesList.getLength() - 1) { + interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}" + ",") + } + else { + interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}") + } + } + } + interfaceRoutePrefixValues = sb3.append("]") + if (interfaceRoutePrefixesList.getLength() > 0) { + paramsMap.put("${key}_${networkKey}_route_prefixes", "${interfaceRoutePrefixValues}") + } + + NodeList networkIpsV6List = eElementNetworkKey.getElementsByTagNameNS("*","network-ips-v6") + for(int a = 0; a < networkIpsV6List.getLength(); a++){ + Node ipV6Address = networkIpsV6List.item(a) + if (ipV6Address.getNodeType() == Node.ELEMENT_NODE) { + Element eElementIpV6Address = (Element) ipV6Address + String ipV6AddressValue = utils.getElementText(eElementIpV6Address, "ip-address-ipv6") + if (a != networkIpsV6List.getLength() - 1) { + ipV6AddressValues = sb4.append(ipV6AddressValue + ",") + } + else { + ipV6AddressValues = sb4.append(ipV6AddressValue); + } + networkPosition = a.toString() + paramsMap.put("${key}_${networkKey}_v6_ip_${networkPosition}", "${ipV6AddressValue}") + } + } + paramsMap.put("${key}_${networkKey}_v6_ips", "${ipV6AddressValues}") + } + } + paramsMap.put("${key}_names", "${values}") + } + } + //SDNC Response Params + String sdncResponseParams = "" + List sdncResponseParamsToSkip = [ + "vnf_id", + "vf_module_id", + "vnf_name", + "vf_module_name" + ] + String vnfParamsChildNodes = utils.getChildNodes(data, "vnf-parameters") + if(vnfParamsChildNodes == null || vnfParamsChildNodes.length() < 1){ + // No SDNC params + }else{ + 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") + if (!sdncResponseParamsToSkip.contains(vnfParameterName)) { + String vnfParameterValue = utils.getElementText(eElement, "vnf-parameter-value") + paramsMap.put("${vnfParameterName}", "${vnfParameterValue}") + } + } + } + + // make the sdnc_directives parameter + String sdncDirectives = "{}" + StringBuilder sdncDirectivesBuilder = new StringBuilder() + sdncDirectivesBuilder.append("{ \"attributes\": [") + int pcnt = 0 + for (Map.Entry entry : paramsMap.entrySet()) { + String attributeName = entry.getKey() + String attributeValue = entry.getValue() + if (pcnt > 0) { + sdncDirectivesBuilder.append(",") + } + pcnt++ + sdncDirectivesBuilder.append("{\"attribute_name\":\"${attributeName}\",") + sdncDirectivesBuilder.append("\"attribute_value\":\"${attributeValue}\"}") + } + if (pcnt > 0) { + sdncDirectives = sdncDirectivesBuilder.append("]}").toString() + } + paramsMap.put("sdnc_directives", "${sdncDirectives}") + + // Parameters received from the request should overwrite any parameters received from SDNC + // Also build the user_directives parameter + String userDirectives = "{}" + if (vnfParamsMap != null) { + StringBuilder userDirectivesBuilder = new StringBuilder() + userDirectivesBuilder.append("{ \"attributes\": [") + pcnt = 0 + for (Map.Entry entry : vnfParamsMap.entrySet()) { + String vnfKey = entry.getKey() + String vnfValue = entry.getValue() + paramsMap.put("$vnfKey", "$vnfValue") + if (pcnt > 0) { + userDirectivesBuilder.append(",") + } + pcnt++ + userDirectivesBuilder.append("{\"attribute_name\":\"${vnfKey}\",") + userDirectivesBuilder.append("\"attribute_value\":\"${vnfValue}\"}") + } + if (pcnt > 0) { + userDirectives = userDirectivesBuilder.append("]}").toString() + } + } + paramsMap.put("user_directives", "${userDirectives}") + + StringBuilder sbParams = new StringBuilder() + def vfModuleParams = "" + for (Map.Entry entry : paramsMap.entrySet()) { + String paramsXml + String paramName = entry.getKey() + String paramValue = entry.getValue() + paramsXml = + """ ${MsoUtils.xmlEscape(paramName)} ${MsoUtils.xmlEscape(paramValue)} """ - - vfModuleParams = sbParams.append(paramsXml) - } - - return vfModuleParams - - } - - - /* - * Parses VNF parameters passed in on the incoming requests and SDNC parameters returned from SDNC get response - * for both VNF and VF Module - * and puts them into the format expected by VNF adapter. - * @param vnfParamsMap - map of VNF parameters passed in the request body - * @param vnfSdncGetResponse - response string from SDNC GET VNF topology request - * @param vfmoduleSdncGetResponse - response string from SDNC GET VF Module topology request - * @param vnfId - * @param vnfName - * @param vfModuleId - * @param vfModuleName - * @param vfModuleIndex - can be null - * @return a String of key/value entries for vfModuleParams - */ - - protected String buildVfModuleParamsFromCombinedTopologies(Map vnfParamsMap, String vnfSdncGetResponse, String vfmoduleSdncGetResponse, String vnfId, String vnfName, - String vfModuleId, String vfModuleName, String vfModuleIndex, String environmentContext, String workloadContext) { - - // Set up initial parameters - - Map paramsMap = new HashMap() - - if (vfModuleIndex != null) { - paramsMap.put("vf_module_index", "${vfModuleIndex}") - } - - // Add-on data - paramsMap.put("vnf_id", "${vnfId}") - paramsMap.put("vnf_name", "${vnfName}") - paramsMap.put("vf_module_id", "${vfModuleId}") - paramsMap.put("vf_module_name", "${vfModuleName}") - paramsMap.put("environment_context","${environmentContext}") - paramsMap.put("workload_context", "${workloadContext}") - - //Get SDNC Response Data for VNF - - String vnfData = utils.getNodeXml(vnfSdncGetResponse, "response-data") - - String vnfTopology = utils.getNodeXml(vnfData, "vnf-topology") - vnfTopology = utils.removeXmlPreamble(vnfTopology) - vnfTopology = utils.removeXmlNamespaces(vnfTopology) - - InputSource sourceVnf = new InputSource(new StringReader(vnfData)); - DocumentBuilderFactory docFactoryVnf = DocumentBuilderFactory.newInstance(); - docFactoryVnf.setNamespaceAware(true) - DocumentBuilder docBuilderVnf = docFactoryVnf.newDocumentBuilder() - Document responseXmlVnf = docBuilderVnf.parse(sourceVnf) - - // Availability Zones Data - - NodeList aZonesList = responseXmlVnf.getElementsByTagNameNS("*", "availability-zones") - String aZonePosition = "0" - for (int z = 0; z < aZonesList.getLength(); z++) { - Node node = aZonesList.item(z) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - String aZoneValue = utils.getElementText(eElement, "availability-zone") - aZonePosition = z.toString() - paramsMap.put("availability_zone_${aZonePosition}", "${aZoneValue}") - } - } - - //Get SDNC Response Data for VF Module - - String vfModuleData = utils.getNodeXml(vfmoduleSdncGetResponse, "response-data") - - String vfModuleTopology = utils.getNodeXml(vfModuleData, "vf-module-topology") - vfModuleTopology = utils.removeXmlPreamble(vfModuleTopology) - vfModuleTopology = utils.removeXmlNamespaces(vfModuleTopology) - String vfModuleTopologyIdentifier = utils.getNodeXml(vfModuleTopology, "vf-module-topology-identifier") - - InputSource sourceVfModule = new InputSource(new StringReader(vfModuleData)); - DocumentBuilderFactory docFactoryVfModule = DocumentBuilderFactory.newInstance(); - docFactoryVfModule.setNamespaceAware(true) - DocumentBuilder docBuilderVfModule = docFactoryVfModule.newDocumentBuilder() - Document responseXmlVfModule = docBuilderVfModule.parse(sourceVfModule) - - // Map of network-roles and network-tags from vm-networks - - NodeList vmNetworksListGlobal = responseXmlVfModule.getElementsByTagNameNS("*", "vm-networks") - Map networkRoleMap = new HashMap() - for(int n = 0; n < vmNetworksListGlobal.getLength(); n++){ - Node nodeNetworkKey = vmNetworksListGlobal.item(n) - if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) { - Element eElementNetworkKey = (Element) nodeNetworkKey - String networkRole = utils.getElementText(eElementNetworkKey, "network-role") - String networkRoleValue = utils.getElementText(eElementNetworkKey, "network-role-tag") - if (networkRoleValue.isEmpty()) { - networkRoleValue = networkRole - } - networkRoleMap.put(networkRole, networkRoleValue) - } - } - - // VNF Networks Data - - StringBuilder sbNet = new StringBuilder() - - NodeList vnfNetworkList = responseXmlVnf.getElementsByTagNameNS("*", "vnf-networks") - for (int x = 0; x < vnfNetworkList.getLength(); x++) { - Node node = vnfNetworkList.item(x) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - String vnfNetworkKey = utils.getElementText(eElement, "network-role-tag") - String networkRole = utils.getElementText(eElement, "network-role") - if (vnfNetworkKey.isEmpty()) { - vnfNetworkKey = networkRoleMap.get(networkRole) - if (vnfNetworkKey == null || vnfNetworkKey.isEmpty()) { - vnfNetworkKey = networkRole - } - } - String vnfNetworkNeutronIdValue = utils.getElementText(eElement, "neutron-id") - String vnfNetworkNetNameValue = utils.getElementText(eElement, "network-name") - String vnfNetworkSubNetIdValue = utils.getElementText(eElement, "subnet-id") - String vnfNetworkV6SubNetIdValue = utils.getElementText(eElement, "ipv6-subnet-id") - String vnfNetworkNetFqdnValue = utils.getElementText(eElement, "contrail-network-fqdn") - paramsMap.put("${vnfNetworkKey}_net_id", "${vnfNetworkNeutronIdValue}") - paramsMap.put("${vnfNetworkKey}_net_name", "${vnfNetworkNetNameValue}") - paramsMap.put("${vnfNetworkKey}_subnet_id", "${vnfNetworkSubNetIdValue}") - paramsMap.put("${vnfNetworkKey}_v6_subnet_id", "${vnfNetworkV6SubNetIdValue}") - paramsMap.put("${vnfNetworkKey}_net_fqdn", "${vnfNetworkNetFqdnValue}") - - NodeList sriovVlanFilterList = eElement.getElementsByTagNameNS("*","sriov-vlan-filter-list") - StringBuffer sriovFilterBuf = new StringBuffer() - String values = "" - for(int i = 0; i < sriovVlanFilterList.getLength(); i++){ - Node node1 = sriovVlanFilterList.item(i) - if (node1.getNodeType() == Node.ELEMENT_NODE) { - Element eElement1 = (Element) node1 - String value = utils.getElementText(eElement1, "sriov-vlan-filter") - if (i != sriovVlanFilterList.getLength() - 1) { - values = sriovFilterBuf.append(value + ",") - } - else { - values = sriovFilterBuf.append(value); - } - } - } - if (!values.isEmpty()) { - paramsMap.put("${vnfNetworkKey}_ATT_VF_VLAN_FILTER", "${values}") - } - } - } - - - - // VMS Data - - def key - def value - def networkKey - def networkValue - def floatingIPKey - def floatingIPKeyValue - def floatingIPV6Key - def floatingIPV6KeyValue - StringBuilder sb = new StringBuilder() - - NodeList vmsList = responseXmlVfModule.getElementsByTagNameNS("*","vm") - for (int x = 0; x < vmsList.getLength(); x++) { - Node node = vmsList.item(x) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - key = utils.getElementText(eElement, "vm-type") - String values - String position = "0" - StringBuilder sb1 = new StringBuilder() - NodeList valueList = eElement.getElementsByTagNameNS("*","vm-names") - NodeList vmNetworksList = eElement.getElementsByTagNameNS("*","vm-networks") - for(int i = 0; i < valueList.getLength(); i++){ - Node node1 = valueList.item(i) - if (node1.getNodeType() == Node.ELEMENT_NODE) { - Element eElement1 = (Element) node1 - value = utils.getElementText(eElement1, "vm-name") - if (i != valueList.getLength() - 1) { - values = sb1.append(value + ",") - } - else { - values = sb1.append(value); - } - position = i.toString() - paramsMap.put("${key}_name_${position}", "${value}") - } - } - for(int n = 0; n < vmNetworksList.getLength(); n++){ - String floatingIpKeyValueStr = "" - String floatingIpV6KeyValueStr = "" - Node nodeNetworkKey = vmNetworksList.item(n) - if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) { - Element eElementNetworkKey = (Element) nodeNetworkKey - String ipAddressValues - String ipV6AddressValues - String networkPosition = "0" - StringBuilder sb2 = new StringBuilder() - StringBuilder sb3 = new StringBuilder() - StringBuilder sb4 = new StringBuilder() - networkKey = utils.getElementText(eElementNetworkKey, "network-role-tag") - if (networkKey.isEmpty()) { - networkKey = utils.getElementText(eElementNetworkKey, "network-role") - } - floatingIPKey = key + '_' + networkKey + '_floating_ip' - floatingIPKeyValue = utils.getElementText(eElementNetworkKey, "floating-ip") - if(!floatingIPKeyValue.isEmpty()){ - paramsMap.put("$floatingIPKey", "$floatingIPKeyValue") - } - floatingIPV6Key = key + '_' + networkKey + '_floating_v6_ip' - floatingIPV6KeyValue = utils.getElementText(eElementNetworkKey, "floating-ip-v6") - if(!floatingIPV6KeyValue.isEmpty()){ - paramsMap.put("$floatingIPV6Key", "$floatingIPV6KeyValue") - } - NodeList networkIpsList = eElementNetworkKey.getElementsByTagNameNS("*","network-ips") - for(int a = 0; a < networkIpsList.getLength(); a++){ - Node ipAddress = networkIpsList.item(a) - if (ipAddress.getNodeType() == Node.ELEMENT_NODE) { - Element eElementIpAddress = (Element) ipAddress - String ipAddressValue = utils.getElementText(eElementIpAddress, "ip-address") - if (a != networkIpsList.getLength() - 1) { - ipAddressValues = sb2.append(ipAddressValue + ",") - } - else { - ipAddressValues = sb2.append(ipAddressValue); - } - networkPosition = a.toString() - paramsMap.put("${key}_${networkKey}_ip_${networkPosition}", "${ipAddressValue}") - } - } - - paramsMap.put("${key}_${networkKey}_ips", "${ipAddressValues}") - - NodeList interfaceRoutePrefixesList = eElementNetworkKey.getElementsByTagNameNS("*","interface-route-prefixes") - String interfaceRoutePrefixValues = sb3.append("[") - - for(int a = 0; a < interfaceRoutePrefixesList.getLength(); a++){ - Node interfaceRoutePrefix = interfaceRoutePrefixesList.item(a) - if (interfaceRoutePrefix.getNodeType() == Node.ELEMENT_NODE) { - Element eElementInterfaceRoutePrefix = (Element) interfaceRoutePrefix - String interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix-cidr") - if (interfaceRoutePrefixValue == null || interfaceRoutePrefixValue.isEmpty()) { - interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix") - } - if (a != interfaceRoutePrefixesList.getLength() - 1) { - interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}" + ",") - } - else { - interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}") - } - } - } - interfaceRoutePrefixValues = sb3.append("]") - if (interfaceRoutePrefixesList.getLength() > 0) { - paramsMap.put("${key}_${networkKey}_route_prefixes", "${interfaceRoutePrefixValues}") - } - - NodeList networkIpsV6List = eElementNetworkKey.getElementsByTagNameNS("*","network-ips-v6") - for(int a = 0; a < networkIpsV6List.getLength(); a++){ - Node ipV6Address = networkIpsV6List.item(a) - if (ipV6Address.getNodeType() == Node.ELEMENT_NODE) { - Element eElementIpV6Address = (Element) ipV6Address - String ipV6AddressValue = utils.getElementText(eElementIpV6Address, "ip-address-ipv6") - if (a != networkIpsV6List.getLength() - 1) { - ipV6AddressValues = sb4.append(ipV6AddressValue + ",") - } - else { - ipV6AddressValues = sb4.append(ipV6AddressValue); - } - networkPosition = a.toString() - paramsMap.put("${key}_${networkKey}_v6_ip_${networkPosition}", "${ipV6AddressValue}") - } - } - paramsMap.put("${key}_${networkKey}_v6_ips", "${ipV6AddressValues}") - } - } - paramsMap.put("${key}_names", "${values}") - } - } - //SDNC Response Params - List sdncResponseParamsToSkip = ["vnf_id", "vf_module_id", "vnf_name", "vf_module_name"] - - String vnfParamsChildNodes = utils.getChildNodes(vnfData, "param") - if(vnfParamsChildNodes == null || vnfParamsChildNodes.length() < 1){ - // No SDNC params for VNF - }else{ - NodeList paramsList = responseXmlVnf.getElementsByTagNameNS("*", "param") - for (int z = 0; z < paramsList.getLength(); z++) { - Node node = paramsList.item(z) - Element eElement = (Element) node - String vnfParameterName = utils.getElementText(eElement, "name") - if (!sdncResponseParamsToSkip.contains(vnfParameterName)) { - String vnfParameterValue = utils.getElementText(eElement, "value") - paramsMap.put("${vnfParameterName}", "${vnfParameterValue}") - } - } - } - - String vfModuleParamsChildNodes = utils.getChildNodes(vfModuleData, "param") - if(vfModuleParamsChildNodes == null || vfModuleParamsChildNodes.length() < 1){ - // No SDNC params for VF Module - }else{ - NodeList paramsList = responseXmlVfModule.getElementsByTagNameNS("*", "param") - for (int z = 0; z < paramsList.getLength(); z++) { - Node node = paramsList.item(z) - Element eElement = (Element) node - String vnfParameterName = utils.getElementText(eElement, "name") - if (!sdncResponseParamsToSkip.contains(vnfParameterName)) { - String vnfParameterValue = utils.getElementText(eElement, "value") - paramsMap.put("${vnfParameterName}", "${vnfParameterValue}") - } - } - } - - // Parameters received from the request should overwrite any parameters received from SDNC - if (vnfParamsMap != null) { - for (Map.Entry entry : vnfParamsMap.entrySet()) { - String vnfKey = entry.getKey() - String vnfValue = entry.getValue() - paramsMap.put("$vnfKey", "$vnfValue") - } - } - - StringBuilder sbParams = new StringBuilder() - def vfModuleParams = "" - for (Map.Entry entry : paramsMap.entrySet()) { - String paramsXml - String paramName = entry.getKey() - String paramValue = entry.getValue() - paramsXml = - """ + + vfModuleParams = sbParams.append(paramsXml) + } + + return vfModuleParams + + } + + + /* + * Parses VNF parameters passed in on the incoming requests and SDNC parameters returned from SDNC get response + * for both VNF and VF Module + * and puts them into the format expected by VNF adapter. + * @param vnfParamsMap - map of VNF parameters passed in the request body + * @param vnfSdncGetResponse - response string from SDNC GET VNF topology request + * @param vfmoduleSdncGetResponse - response string from SDNC GET VF Module topology request + * @param vnfId + * @param vnfName + * @param vfModuleId + * @param vfModuleName + * @param vfModuleIndex - can be null + * @return a String of key/value entries for vfModuleParams + */ + + protected String buildVfModuleParamsFromCombinedTopologies(Map vnfParamsMap, String vnfSdncGetResponse, String vfmoduleSdncGetResponse, String vnfId, String vnfName, + String vfModuleId, String vfModuleName, String vfModuleIndex, String environmentContext, String workloadContext) { + + // Set up initial parameters + + Map paramsMap = new HashMap() + + if (vfModuleIndex != null) { + paramsMap.put("vf_module_index", "${vfModuleIndex}") + } + + // Add-on data + paramsMap.put("vnf_id", "${vnfId}") + paramsMap.put("vnf_name", "${vnfName}") + paramsMap.put("vf_module_id", "${vfModuleId}") + paramsMap.put("vf_module_name", "${vfModuleName}") + paramsMap.put("environment_context","${environmentContext}") + paramsMap.put("workload_context", "${workloadContext}") + + //Get SDNC Response Data for VNF + + String vnfData = utils.getNodeXml(vnfSdncGetResponse, "response-data") + + String vnfTopology = utils.getNodeXml(vnfData, "vnf-topology") + vnfTopology = utils.removeXmlPreamble(vnfTopology) + vnfTopology = utils.removeXmlNamespaces(vnfTopology) + + InputSource sourceVnf = new InputSource(new StringReader(vnfData)); + DocumentBuilderFactory docFactoryVnf = DocumentBuilderFactory.newInstance(); + docFactoryVnf.setNamespaceAware(true) + DocumentBuilder docBuilderVnf = docFactoryVnf.newDocumentBuilder() + Document responseXmlVnf = docBuilderVnf.parse(sourceVnf) + + // Availability Zones Data + + NodeList aZonesList = responseXmlVnf.getElementsByTagNameNS("*", "availability-zones") + String aZonePosition = "0" + for (int z = 0; z < aZonesList.getLength(); z++) { + Node node = aZonesList.item(z) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + String aZoneValue = utils.getElementText(eElement, "availability-zone") + aZonePosition = z.toString() + paramsMap.put("availability_zone_${aZonePosition}", "${aZoneValue}") + } + } + + //Get SDNC Response Data for VF Module + + String vfModuleData = utils.getNodeXml(vfmoduleSdncGetResponse, "response-data") + + String vfModuleTopology = utils.getNodeXml(vfModuleData, "vf-module-topology") + vfModuleTopology = utils.removeXmlPreamble(vfModuleTopology) + vfModuleTopology = utils.removeXmlNamespaces(vfModuleTopology) + String vfModuleTopologyIdentifier = utils.getNodeXml(vfModuleTopology, "vf-module-topology-identifier") + + InputSource sourceVfModule = new InputSource(new StringReader(vfModuleData)); + DocumentBuilderFactory docFactoryVfModule = DocumentBuilderFactory.newInstance(); + docFactoryVfModule.setNamespaceAware(true) + DocumentBuilder docBuilderVfModule = docFactoryVfModule.newDocumentBuilder() + Document responseXmlVfModule = docBuilderVfModule.parse(sourceVfModule) + + // Map of network-roles and network-tags from vm-networks + + NodeList vmNetworksListGlobal = responseXmlVfModule.getElementsByTagNameNS("*", "vm-networks") + Map networkRoleMap = new HashMap() + for(int n = 0; n < vmNetworksListGlobal.getLength(); n++){ + Node nodeNetworkKey = vmNetworksListGlobal.item(n) + if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) { + Element eElementNetworkKey = (Element) nodeNetworkKey + String networkRole = utils.getElementText(eElementNetworkKey, "network-role") + String networkRoleValue = utils.getElementText(eElementNetworkKey, "network-role-tag") + if (networkRoleValue.isEmpty()) { + networkRoleValue = networkRole + } + networkRoleMap.put(networkRole, networkRoleValue) + } + } + + // VNF Networks Data + + StringBuilder sbNet = new StringBuilder() + + NodeList vnfNetworkList = responseXmlVnf.getElementsByTagNameNS("*", "vnf-networks") + for (int x = 0; x < vnfNetworkList.getLength(); x++) { + Node node = vnfNetworkList.item(x) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + String vnfNetworkKey = utils.getElementText(eElement, "network-role-tag") + String networkRole = utils.getElementText(eElement, "network-role") + if (vnfNetworkKey.isEmpty()) { + vnfNetworkKey = networkRoleMap.get(networkRole) + if (vnfNetworkKey == null || vnfNetworkKey.isEmpty()) { + vnfNetworkKey = networkRole + } + } + String vnfNetworkNeutronIdValue = utils.getElementText(eElement, "neutron-id") + String vnfNetworkNetNameValue = utils.getElementText(eElement, "network-name") + String vnfNetworkSubNetIdValue = utils.getElementText(eElement, "subnet-id") + String vnfNetworkV6SubNetIdValue = utils.getElementText(eElement, "ipv6-subnet-id") + String vnfNetworkNetFqdnValue = utils.getElementText(eElement, "contrail-network-fqdn") + paramsMap.put("${vnfNetworkKey}_net_id", "${vnfNetworkNeutronIdValue}") + paramsMap.put("${vnfNetworkKey}_net_name", "${vnfNetworkNetNameValue}") + paramsMap.put("${vnfNetworkKey}_subnet_id", "${vnfNetworkSubNetIdValue}") + paramsMap.put("${vnfNetworkKey}_v6_subnet_id", "${vnfNetworkV6SubNetIdValue}") + paramsMap.put("${vnfNetworkKey}_net_fqdn", "${vnfNetworkNetFqdnValue}") + + NodeList sriovVlanFilterList = eElement.getElementsByTagNameNS("*","sriov-vlan-filter-list") + StringBuffer sriovFilterBuf = new StringBuffer() + String values = "" + for(int i = 0; i < sriovVlanFilterList.getLength(); i++){ + Node node1 = sriovVlanFilterList.item(i) + if (node1.getNodeType() == Node.ELEMENT_NODE) { + Element eElement1 = (Element) node1 + String value = utils.getElementText(eElement1, "sriov-vlan-filter") + if (i != sriovVlanFilterList.getLength() - 1) { + values = sriovFilterBuf.append(value + ",") + } + else { + values = sriovFilterBuf.append(value); + } + } + } + if (!values.isEmpty()) { + paramsMap.put("${vnfNetworkKey}_ATT_VF_VLAN_FILTER", "${values}") + } + } + } + + + + // VMS Data + + def key + def value + def networkKey + def networkValue + def floatingIPKey + def floatingIPKeyValue + def floatingIPV6Key + def floatingIPV6KeyValue + StringBuilder sb = new StringBuilder() + + NodeList vmsList = responseXmlVfModule.getElementsByTagNameNS("*","vm") + for (int x = 0; x < vmsList.getLength(); x++) { + Node node = vmsList.item(x) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + key = utils.getElementText(eElement, "vm-type") + String values + String position = "0" + StringBuilder sb1 = new StringBuilder() + NodeList valueList = eElement.getElementsByTagNameNS("*","vm-names") + NodeList vmNetworksList = eElement.getElementsByTagNameNS("*","vm-networks") + for(int i = 0; i < valueList.getLength(); i++){ + Node node1 = valueList.item(i) + if (node1.getNodeType() == Node.ELEMENT_NODE) { + Element eElement1 = (Element) node1 + value = utils.getElementText(eElement1, "vm-name") + if (i != valueList.getLength() - 1) { + values = sb1.append(value + ",") + } + else { + values = sb1.append(value); + } + position = i.toString() + paramsMap.put("${key}_name_${position}", "${value}") + } + } + for(int n = 0; n < vmNetworksList.getLength(); n++){ + String floatingIpKeyValueStr = "" + String floatingIpV6KeyValueStr = "" + Node nodeNetworkKey = vmNetworksList.item(n) + if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) { + Element eElementNetworkKey = (Element) nodeNetworkKey + String ipAddressValues + String ipV6AddressValues + String networkPosition = "0" + StringBuilder sb2 = new StringBuilder() + StringBuilder sb3 = new StringBuilder() + StringBuilder sb4 = new StringBuilder() + networkKey = utils.getElementText(eElementNetworkKey, "network-role-tag") + if (networkKey.isEmpty()) { + networkKey = utils.getElementText(eElementNetworkKey, "network-role") + } + floatingIPKey = key + '_' + networkKey + '_floating_ip' + floatingIPKeyValue = utils.getElementText(eElementNetworkKey, "floating-ip") + if(!floatingIPKeyValue.isEmpty()){ + paramsMap.put("$floatingIPKey", "$floatingIPKeyValue") + } + floatingIPV6Key = key + '_' + networkKey + '_floating_v6_ip' + floatingIPV6KeyValue = utils.getElementText(eElementNetworkKey, "floating-ip-v6") + if(!floatingIPV6KeyValue.isEmpty()){ + paramsMap.put("$floatingIPV6Key", "$floatingIPV6KeyValue") + } + NodeList networkIpsList = eElementNetworkKey.getElementsByTagNameNS("*","network-ips") + for(int a = 0; a < networkIpsList.getLength(); a++){ + Node ipAddress = networkIpsList.item(a) + if (ipAddress.getNodeType() == Node.ELEMENT_NODE) { + Element eElementIpAddress = (Element) ipAddress + String ipAddressValue = utils.getElementText(eElementIpAddress, "ip-address") + if (a != networkIpsList.getLength() - 1) { + ipAddressValues = sb2.append(ipAddressValue + ",") + } + else { + ipAddressValues = sb2.append(ipAddressValue); + } + networkPosition = a.toString() + paramsMap.put("${key}_${networkKey}_ip_${networkPosition}", "${ipAddressValue}") + } + } + + paramsMap.put("${key}_${networkKey}_ips", "${ipAddressValues}") + + NodeList interfaceRoutePrefixesList = eElementNetworkKey.getElementsByTagNameNS("*","interface-route-prefixes") + String interfaceRoutePrefixValues = sb3.append("[") + + for(int a = 0; a < interfaceRoutePrefixesList.getLength(); a++){ + Node interfaceRoutePrefix = interfaceRoutePrefixesList.item(a) + if (interfaceRoutePrefix.getNodeType() == Node.ELEMENT_NODE) { + Element eElementInterfaceRoutePrefix = (Element) interfaceRoutePrefix + String interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix-cidr") + if (interfaceRoutePrefixValue == null || interfaceRoutePrefixValue.isEmpty()) { + interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix") + } + if (a != interfaceRoutePrefixesList.getLength() - 1) { + interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}" + ",") + } + else { + interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}") + } + } + } + interfaceRoutePrefixValues = sb3.append("]") + if (interfaceRoutePrefixesList.getLength() > 0) { + paramsMap.put("${key}_${networkKey}_route_prefixes", "${interfaceRoutePrefixValues}") + } + + NodeList networkIpsV6List = eElementNetworkKey.getElementsByTagNameNS("*","network-ips-v6") + for(int a = 0; a < networkIpsV6List.getLength(); a++){ + Node ipV6Address = networkIpsV6List.item(a) + if (ipV6Address.getNodeType() == Node.ELEMENT_NODE) { + Element eElementIpV6Address = (Element) ipV6Address + String ipV6AddressValue = utils.getElementText(eElementIpV6Address, "ip-address-ipv6") + if (a != networkIpsV6List.getLength() - 1) { + ipV6AddressValues = sb4.append(ipV6AddressValue + ",") + } + else { + ipV6AddressValues = sb4.append(ipV6AddressValue); + } + networkPosition = a.toString() + paramsMap.put("${key}_${networkKey}_v6_ip_${networkPosition}", "${ipV6AddressValue}") + } + } + paramsMap.put("${key}_${networkKey}_v6_ips", "${ipV6AddressValues}") + } + } + paramsMap.put("${key}_names", "${values}") + } + } + //SDNC Response Params + List sdncResponseParamsToSkip = [ + "vnf_id", + "vf_module_id", + "vnf_name", + "vf_module_name" + ] + + String vnfParamsChildNodes = utils.getChildNodes(vnfData, "param") + if(vnfParamsChildNodes == null || vnfParamsChildNodes.length() < 1){ + // No SDNC params for VNF + }else{ + NodeList paramsList = responseXmlVnf.getElementsByTagNameNS("*", "param") + for (int z = 0; z < paramsList.getLength(); z++) { + Node node = paramsList.item(z) + Element eElement = (Element) node + String vnfParameterName = utils.getElementText(eElement, "name") + if (!sdncResponseParamsToSkip.contains(vnfParameterName)) { + String vnfParameterValue = utils.getElementText(eElement, "value") + paramsMap.put("${vnfParameterName}", "${vnfParameterValue}") + } + } + } + + String vfModuleParamsChildNodes = utils.getChildNodes(vfModuleData, "param") + if(vfModuleParamsChildNodes == null || vfModuleParamsChildNodes.length() < 1){ + // No SDNC params for VF Module + }else{ + NodeList paramsList = responseXmlVfModule.getElementsByTagNameNS("*", "param") + for (int z = 0; z < paramsList.getLength(); z++) { + Node node = paramsList.item(z) + Element eElement = (Element) node + String vnfParameterName = utils.getElementText(eElement, "name") + if (!sdncResponseParamsToSkip.contains(vnfParameterName)) { + String vnfParameterValue = utils.getElementText(eElement, "value") + paramsMap.put("${vnfParameterName}", "${vnfParameterValue}") + } + } + } + + // make the sdnc_directives parameter + String sdncDirectives = "{}" + StringBuilder sdncDirectivesBuilder = new StringBuilder() + sdncDirectivesBuilder.append("{ \"attributes\": [") + int pcnt = 0 + for (Map.Entry entry : paramsMap.entrySet()) { + String attributeName = entry.getKey() + String attributeValue = entry.getValue() + if (pcnt > 0) { + sdncDirectivesBuilder.append(",") + } + pcnt++ + sdncDirectivesBuilder.append("{\"attribute_name\":\"${attributeName}\",") + sdncDirectivesBuilder.append("\"attribute_value\":\"${attributeValue}\"}") + } + if (pcnt > 0) { + sdncDirectives = sdncDirectivesBuilder.append("]}").toString() + } + paramsMap.put("sdnc_directives", "${sdncDirectives}") + + + // Parameters received from the request should overwrite any parameters received from SDNC + String userDirectives = "{}" + if (vnfParamsMap != null) { + StringBuilder userDirectivesBuilder = new StringBuilder() + userDirectivesBuilder.append("{ \"attributes\": [") + pcnt = 0 + for (Map.Entry entry : vnfParamsMap.entrySet()) { + String vnfKey = entry.getKey() + String vnfValue = entry.getValue() + paramsMap.put("$vnfKey", "$vnfValue") + if (pcnt > 0) { + userDirectivesBuilder.append(",") + } + pcnt++ + userDirectivesBuilder.append("{\"attribute_name\":\"${vnfKey}\",") + userDirectivesBuilder.append("\"attribute_value\":\"${vnfValue}\"}") + } + if (pcnt > 0) { + userDirectives = userDirectivesBuilder.append("]}").toString() + } + } + paramsMap.put("user_directives", "${userDirectives}") + + StringBuilder sbParams = new StringBuilder() + def vfModuleParams = "" + for (Map.Entry entry : paramsMap.entrySet()) { + String paramsXml + String paramName = entry.getKey() + String paramValue = entry.getValue() + paramsXml = + """ ${MsoUtils.xmlEscape(paramName)} ${MsoUtils.xmlEscape(paramValue)} """ - - vfModuleParams = sbParams.append(paramsXml) - } - - return vfModuleParams - - } - - - /* - * VBNG specific method that parses VNF parameters passed in on the - * incoming requests and SDNC parameters returned from SDNC get response - * and puts them into the format expected by VNF adapter. - * @param vnfParamsMap - map of VNF parameters passed in the request body - * @param sdncGetResponse - response string from SDNC GET topology request - * @param vnfId - * @param vnfName - * @param vfModuleId - * @param vfModuleName - * @return a String of key/value entries for vfModuleParams - */ - - protected String buildVfModuleParamsVbng(String vnfParams, String sdncGetResponse, String vnfId, String vnfName, - String vfModuleId, String vfModuleName) { - - //Get SDNC Response Data - - String data = utils.getNodeXml(sdncGetResponse, "response-data") - - - - // Add-on data - String vnfInfo = - """ + + vfModuleParams = sbParams.append(paramsXml) + } + + return vfModuleParams + + } + + + /* + * VBNG specific method that parses VNF parameters passed in on the + * incoming requests and SDNC parameters returned from SDNC get response + * and puts them into the format expected by VNF adapter. + * @param vnfParamsMap - map of VNF parameters passed in the request body + * @param sdncGetResponse - response string from SDNC GET topology request + * @param vnfId + * @param vnfName + * @param vfModuleId + * @param vfModuleName + * @return a String of key/value entries for vfModuleParams + */ + + protected String buildVfModuleParamsVbng(String vnfParams, String sdncGetResponse, String vnfId, String vnfName, + String vfModuleId, String vfModuleName) { + + //Get SDNC Response Data + + String data = utils.getNodeXml(sdncGetResponse, "response-data") + + + + // Add-on data + String vnfInfo = + """ vnf_id ${MsoUtils.xmlEscape(vnfId)} @@ -889,347 +974,352 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { ${MsoUtils.xmlEscape(vfModuleName)} """ - logger.debug("vnfInfo: " + vnfInfo) - InputSource source = new InputSource(new StringReader(data)); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - docFactory.setNamespaceAware(true) - DocumentBuilder docBuilder = docFactory.newDocumentBuilder() - Document responseXml = docBuilder.parse(source) - - - // Availability Zones Data - String aZones = "" - StringBuilder sbAZone = new StringBuilder() - NodeList aZonesList = responseXml.getElementsByTagNameNS("*", "availability-zones") - String aZonePosition = "0" - for (int z = 0; z < aZonesList.getLength(); z++) { - Node node = aZonesList.item(z) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - String aZoneValue = utils.getElementText(eElement, "availability-zone") - aZonePosition = z.toString() - String aZoneXml = - """ + logger.debug("vnfInfo: " + vnfInfo) + InputSource source = new InputSource(new StringReader(data)); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + docFactory.setNamespaceAware(true) + DocumentBuilder docBuilder = docFactory.newDocumentBuilder() + Document responseXml = docBuilder.parse(source) + + + // Availability Zones Data + String aZones = "" + StringBuilder sbAZone = new StringBuilder() + NodeList aZonesList = responseXml.getElementsByTagNameNS("*", "availability-zones") + String aZonePosition = "0" + for (int z = 0; z < aZonesList.getLength(); z++) { + Node node = aZonesList.item(z) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + String aZoneValue = utils.getElementText(eElement, "availability-zone") + aZonePosition = z.toString() + String aZoneXml = + """ availability_zone_${MsoUtils.xmlEscape(aZonePosition)} ${MsoUtils.xmlEscape(aZoneValue)} """ - aZones = sbAZone.append(aZoneXml) - } - } - - // Map of network-roles and network-tags from vm-networks - - NodeList vmNetworksListGlobal = responseXml.getElementsByTagNameNS("*", "vm-networks") - Map networkRoleMap = new HashMap() - for(int n = 0; n < vmNetworksListGlobal.getLength(); n++){ - Node nodeNetworkKey = vmNetworksListGlobal.item(n) - if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) { - Element eElementNetworkKey = (Element) nodeNetworkKey - String networkRole = utils.getElementText(eElementNetworkKey, "network-role") - String networkRoleValue = utils.getElementText(eElementNetworkKey, "network-role-tag") - if (networkRoleValue.isEmpty()) { - networkRoleValue = networkRole - } - networkRoleMap.put(networkRole, networkRoleValue) - } - } - - // VNF Networks Data - String vnfNetworkNetId = "" - String vnfNetworkNetName = "" - String vnfNetworkSubNetId = "" - String vnfNetworkV6SubNetId = "" - String vnfNetworkNetFqdn = "" - String vnfNetworksSriovVlanFilters = "" - StringBuilder sbNet = new StringBuilder() - StringBuilder sbNet2 = new StringBuilder() - StringBuilder sbNet3 = new StringBuilder() - StringBuilder sbNet4 = new StringBuilder() - StringBuilder sbNet5 = new StringBuilder() - StringBuilder sbNet6 = new StringBuilder() - NodeList vnfNetworkList = responseXml.getElementsByTagNameNS("*", "vnf-networks") - for (int x = 0; x < vnfNetworkList.getLength(); x++) { - Node node = vnfNetworkList.item(x) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - String vnfNetworkKey = utils.getElementText(eElement, "network-role-tag") - String networkRole = utils.getElementText(eElement, "network-role") - if (vnfNetworkKey.isEmpty()) { - vnfNetworkKey = networkRoleMap.get(networkRole) - if (vnfNetworkKey == null || vnfNetworkKey.isEmpty()) { - vnfNetworkKey = networkRole - } - } - String vnfNetworkNeutronIdValue = utils.getElementText(eElement, "neutron-id") - String vnfNetworkNetNameValue = utils.getElementText(eElement, "network-name") - String vnfNetworkSubNetIdValue = utils.getElementText(eElement, "subnet-id") - String vnfNetworkV6SubNetIdValue = utils.getElementText(eElement, "ipv6-subnet-id") - String vnfNetworkNetFqdnValue = utils.getElementText(eElement, "contrail-network-fqdn") - String vnfNetworkNetIdXml = - """ + aZones = sbAZone.append(aZoneXml) + } + } + + // Map of network-roles and network-tags from vm-networks + + NodeList vmNetworksListGlobal = responseXml.getElementsByTagNameNS("*", "vm-networks") + Map networkRoleMap = new HashMap() + for(int n = 0; n < vmNetworksListGlobal.getLength(); n++){ + Node nodeNetworkKey = vmNetworksListGlobal.item(n) + if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) { + Element eElementNetworkKey = (Element) nodeNetworkKey + String networkRole = utils.getElementText(eElementNetworkKey, "network-role") + String networkRoleValue = utils.getElementText(eElementNetworkKey, "network-role-tag") + if (networkRoleValue.isEmpty()) { + networkRoleValue = networkRole + } + networkRoleMap.put(networkRole, networkRoleValue) + } + } + + // VNF Networks Data + String vnfNetworkNetId = "" + String vnfNetworkNetName = "" + String vnfNetworkSubNetId = "" + String vnfNetworkV6SubNetId = "" + String vnfNetworkNetFqdn = "" + String vnfNetworksSriovVlanFilters = "" + StringBuilder sbNet = new StringBuilder() + StringBuilder sbNet2 = new StringBuilder() + StringBuilder sbNet3 = new StringBuilder() + StringBuilder sbNet4 = new StringBuilder() + StringBuilder sbNet5 = new StringBuilder() + StringBuilder sbNet6 = new StringBuilder() + NodeList vnfNetworkList = responseXml.getElementsByTagNameNS("*", "vnf-networks") + for (int x = 0; x < vnfNetworkList.getLength(); x++) { + Node node = vnfNetworkList.item(x) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + String vnfNetworkKey = utils.getElementText(eElement, "network-role-tag") + String networkRole = utils.getElementText(eElement, "network-role") + if (vnfNetworkKey.isEmpty()) { + vnfNetworkKey = networkRoleMap.get(networkRole) + if (vnfNetworkKey == null || vnfNetworkKey.isEmpty()) { + vnfNetworkKey = networkRole + } + } + String vnfNetworkNeutronIdValue = utils.getElementText(eElement, "neutron-id") + String vnfNetworkNetNameValue = utils.getElementText(eElement, "network-name") + String vnfNetworkSubNetIdValue = utils.getElementText(eElement, "subnet-id") + String vnfNetworkV6SubNetIdValue = utils.getElementText(eElement, "ipv6-subnet-id") + String vnfNetworkNetFqdnValue = utils.getElementText(eElement, "contrail-network-fqdn") + String vnfNetworkNetIdXml = + """ ${MsoUtils.xmlEscape(vnfNetworkKey)}_net_id ${MsoUtils.xmlEscape(vnfNetworkNeutronIdValue)} """ - vnfNetworkNetId = sbNet.append(vnfNetworkNetIdXml) - String vnfNetworkNetNameXml = - """ + vnfNetworkNetId = sbNet.append(vnfNetworkNetIdXml) + String vnfNetworkNetNameXml = + """ ${MsoUtils.xmlEscape(vnfNetworkKey)}_net_name ${MsoUtils.xmlEscape(vnfNetworkNetNameValue)} """ - vnfNetworkNetName = sbNet2.append(vnfNetworkNetNameXml) - String vnfNetworkSubNetIdXml = - """ + vnfNetworkNetName = sbNet2.append(vnfNetworkNetNameXml) + String vnfNetworkSubNetIdXml = + """ ${MsoUtils.xmlEscape(vnfNetworkKey)}_subnet_id ${MsoUtils.xmlEscape(vnfNetworkSubNetIdValue)} """ - vnfNetworkSubNetId = sbNet3.append(vnfNetworkSubNetIdXml) - String vnfNetworkV6SubNetIdXml = - """ + vnfNetworkSubNetId = sbNet3.append(vnfNetworkSubNetIdXml) + String vnfNetworkV6SubNetIdXml = + """ ${MsoUtils.xmlEscape(vnfNetworkKey)}_v6_subnet_id ${MsoUtils.xmlEscape(vnfNetworkV6SubNetIdValue)} """ - vnfNetworkV6SubNetId = sbNet5.append(vnfNetworkV6SubNetIdXml) - String vnfNetworkNetFqdnXml = - """ + vnfNetworkV6SubNetId = sbNet5.append(vnfNetworkV6SubNetIdXml) + String vnfNetworkNetFqdnXml = + """ ${MsoUtils.xmlEscape(vnfNetworkKey)}_net_fqdn ${MsoUtils.xmlEscape(vnfNetworkNetFqdnValue)} """ - vnfNetworkNetFqdn = sbNet4.append(vnfNetworkNetFqdnXml) - - NodeList sriovVlanFilterList = eElement.getElementsByTagNameNS("*","sriov-vlan-filter-list") - StringBuffer sriovFilterBuf = new StringBuffer() - String values = "" - for(int i = 0; i < sriovVlanFilterList.getLength(); i++){ - Node node1 = sriovVlanFilterList.item(i) - if (node1.getNodeType() == Node.ELEMENT_NODE) { - Element eElement1 = (Element) node1 - String value = utils.getElementText(eElement1, "sriov-vlan-filter") - if (i != sriovVlanFilterList.getLength() - 1) { - values = sriovFilterBuf.append(value + ",") - } - else { - values = sriovFilterBuf.append(value); - } - } - } - if (!values.isEmpty()) { - String vnfNetworkSriovVlanFilterXml = - """ + vnfNetworkNetFqdn = sbNet4.append(vnfNetworkNetFqdnXml) + + NodeList sriovVlanFilterList = eElement.getElementsByTagNameNS("*","sriov-vlan-filter-list") + StringBuffer sriovFilterBuf = new StringBuffer() + String values = "" + for(int i = 0; i < sriovVlanFilterList.getLength(); i++){ + Node node1 = sriovVlanFilterList.item(i) + if (node1.getNodeType() == Node.ELEMENT_NODE) { + Element eElement1 = (Element) node1 + String value = utils.getElementText(eElement1, "sriov-vlan-filter") + if (i != sriovVlanFilterList.getLength() - 1) { + values = sriovFilterBuf.append(value + ",") + } + else { + values = sriovFilterBuf.append(value); + } + } + } + if (!values.isEmpty()) { + String vnfNetworkSriovVlanFilterXml = + """ ${MsoUtils.xmlEscape(vnfNetworkKey)}_ATT_VF_VLAN_FILTER ${MsoUtils.xmlEscape(values)} """ - vnfNetworksSriovVlanFilters = sbNet6.append(vnfNetworkSriovVlanFilterXml) - } - } - } - - // VNF-VMS Data - String vnfVMS = "" - String vnfVMSPositions = "" - String vmNetworks = "" - String vmNetworksPositions = "" - String vmNetworksPositionsV6 = "" - String interfaceRoutePrefixes = "" - def key - def value - def networkKey - def networkValue - def floatingIPKey - def floatingIPKeyValue - def floatingIPV6Key - def floatingIPV6KeyValue - StringBuilder sb = new StringBuilder() - StringBuilder sbPositions = new StringBuilder() - StringBuilder sbVmNetworks = new StringBuilder() - StringBuilder sbNetworksPositions = new StringBuilder() - StringBuilder sbInterfaceRoutePrefixes = new StringBuilder() - StringBuilder sbNetworksPositionsV6 = new StringBuilder() - - NodeList vmsList = responseXml.getElementsByTagNameNS("*","vnf-vms") - for (int x = 0; x < vmsList.getLength(); x++) { - Node node = vmsList.item(x) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - key = utils.getElementText(eElement, "vm-type") - String values - String position = "0" - StringBuilder sb1 = new StringBuilder() - NodeList valueList = eElement.getElementsByTagNameNS("*","vm-names") - NodeList vmNetworksList = eElement.getElementsByTagNameNS("*","vm-networks") - for(int i = 0; i < valueList.getLength(); i++){ - Node node1 = valueList.item(i) - if (node1.getNodeType() == Node.ELEMENT_NODE) { - Element eElement1 = (Element) node1 - value = utils.getElementText(eElement1, "vm-name") - if (i != valueList.getLength() - 1) { - values = sb1.append(value + ",") - } - else { - values = sb1.append(value); - } - position = i.toString() - String vnfPositionXml = - """ + vnfNetworksSriovVlanFilters = sbNet6.append(vnfNetworkSriovVlanFilterXml) + } + } + } + + // VNF-VMS Data + String vnfVMS = "" + String vnfVMSPositions = "" + String vmNetworks = "" + String vmNetworksPositions = "" + String vmNetworksPositionsV6 = "" + String interfaceRoutePrefixes = "" + def key + def value + def networkKey + def networkValue + def floatingIPKey + def floatingIPKeyValue + def floatingIPV6Key + def floatingIPV6KeyValue + StringBuilder sb = new StringBuilder() + StringBuilder sbPositions = new StringBuilder() + StringBuilder sbVmNetworks = new StringBuilder() + StringBuilder sbNetworksPositions = new StringBuilder() + StringBuilder sbInterfaceRoutePrefixes = new StringBuilder() + StringBuilder sbNetworksPositionsV6 = new StringBuilder() + + NodeList vmsList = responseXml.getElementsByTagNameNS("*","vnf-vms") + for (int x = 0; x < vmsList.getLength(); x++) { + Node node = vmsList.item(x) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + key = utils.getElementText(eElement, "vm-type") + String values + String position = "0" + StringBuilder sb1 = new StringBuilder() + NodeList valueList = eElement.getElementsByTagNameNS("*","vm-names") + NodeList vmNetworksList = eElement.getElementsByTagNameNS("*","vm-networks") + for(int i = 0; i < valueList.getLength(); i++){ + Node node1 = valueList.item(i) + if (node1.getNodeType() == Node.ELEMENT_NODE) { + Element eElement1 = (Element) node1 + value = utils.getElementText(eElement1, "vm-name") + if (i != valueList.getLength() - 1) { + values = sb1.append(value + ",") + } + else { + values = sb1.append(value); + } + position = i.toString() + String vnfPositionXml = + """ ${MsoUtils.xmlEscape(key)}_name_${MsoUtils.xmlEscape(position)} ${MsoUtils.xmlEscape(value)} """ - nfVMSPositions = sbPositions.append(vnfPositionXml) - } - } - for(int n = 0; n < vmNetworksList.getLength(); n++){ - String floatingIpKeyValueStr = "" - String floatingIpV6KeyValueStr = "" - Node nodeNetworkKey = vmNetworksList.item(n) - if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) { - Element eElementNetworkKey = (Element) nodeNetworkKey - String ipAddressValues - String ipV6AddressValues - String networkPosition = "0" - StringBuilder sb2 = new StringBuilder() - StringBuilder sb3 = new StringBuilder() - StringBuilder sb4 = new StringBuilder() - networkKey = utils.getElementText(eElementNetworkKey, "network-role-tag") - if (networkKey.isEmpty()) { - networkKey = utils.getElementText(eElementNetworkKey, "network-role") - } - floatingIPKey = key + '_' + networkKey + '_floating_ip' - floatingIPKeyValue = utils.getElementText(eElementNetworkKey, "floating-ip") - if(!floatingIPKeyValue.isEmpty()){ - floatingIpKeyValueStr = """ + nfVMSPositions = sbPositions.append(vnfPositionXml) + } + } + for(int n = 0; n < vmNetworksList.getLength(); n++){ + String floatingIpKeyValueStr = "" + String floatingIpV6KeyValueStr = "" + Node nodeNetworkKey = vmNetworksList.item(n) + if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) { + Element eElementNetworkKey = (Element) nodeNetworkKey + String ipAddressValues + String ipV6AddressValues + String networkPosition = "0" + StringBuilder sb2 = new StringBuilder() + StringBuilder sb3 = new StringBuilder() + StringBuilder sb4 = new StringBuilder() + networkKey = utils.getElementText(eElementNetworkKey, "network-role-tag") + if (networkKey.isEmpty()) { + networkKey = utils.getElementText(eElementNetworkKey, "network-role") + } + floatingIPKey = key + '_' + networkKey + '_floating_ip' + floatingIPKeyValue = utils.getElementText(eElementNetworkKey, "floating-ip") + if(!floatingIPKeyValue.isEmpty()){ + floatingIpKeyValueStr = """ $floatingIPKey $floatingIPKeyValue """ - } - floatingIPV6Key = key + '_' + networkKey + '_floating_v6_ip' - floatingIPV6KeyValue = utils.getElementText(eElementNetworkKey, "floating-ip-v6") - if(!floatingIPV6KeyValue.isEmpty()){ - floatingIpV6KeyValueStr = """ + } + floatingIPV6Key = key + '_' + networkKey + '_floating_v6_ip' + floatingIPV6KeyValue = utils.getElementText(eElementNetworkKey, "floating-ip-v6") + if(!floatingIPV6KeyValue.isEmpty()){ + floatingIpV6KeyValueStr = """ $floatingIPV6Key $floatingIPV6KeyValue """ - } - NodeList networkIpsList = eElementNetworkKey.getElementsByTagNameNS("*","network-ips") - for(int a = 0; a < networkIpsList.getLength(); a++){ - Node ipAddress = networkIpsList.item(a) - if (ipAddress.getNodeType() == Node.ELEMENT_NODE) { - Element eElementIpAddress = (Element) ipAddress - String ipAddressValue = utils.getElementText(eElementIpAddress, "ip-address") - if (a != networkIpsList.getLength() - 1) { - ipAddressValues = sb2.append(ipAddressValue + ",") - } - else { - ipAddressValues = sb2.append(ipAddressValue); - } - networkPosition = a.toString() - String vmNetworksPositionsXml = - """ + } + NodeList networkIpsList = eElementNetworkKey.getElementsByTagNameNS("*","network-ips") + for(int a = 0; a < networkIpsList.getLength(); a++){ + Node ipAddress = networkIpsList.item(a) + if (ipAddress.getNodeType() == Node.ELEMENT_NODE) { + Element eElementIpAddress = (Element) ipAddress + String ipAddressValue = utils.getElementText(eElementIpAddress, "ip-address") + if (a != networkIpsList.getLength() - 1) { + ipAddressValues = sb2.append(ipAddressValue + ",") + } + else { + ipAddressValues = sb2.append(ipAddressValue); + } + networkPosition = a.toString() + String vmNetworksPositionsXml = + """ ${MsoUtils.xmlEscape(key)}_${MsoUtils.xmlEscape(networkKey)}_ip_${MsoUtils.xmlEscape(networkPosition)} ${MsoUtils.xmlEscape(ipAddressValue)} """ - vmNetworksPositions = sbNetworksPositions.append(vmNetworksPositionsXml) - } - } - vmNetworksPositions = sbNetworksPositions.append(floatingIpKeyValueStr).append(floatingIpV6KeyValueStr) - - String vmNetworksXml = - """ + vmNetworksPositions = sbNetworksPositions.append(vmNetworksPositionsXml) + } + } + vmNetworksPositions = sbNetworksPositions.append(floatingIpKeyValueStr).append(floatingIpV6KeyValueStr) + + String vmNetworksXml = + """ ${MsoUtils.xmlEscape(key)}_${MsoUtils.xmlEscape(networkKey)}_ips ${MsoUtils.xmlEscape(ipAddressValues)} """ - vmNetworks = sbVmNetworks.append(vmNetworksXml) - - NodeList interfaceRoutePrefixesList = eElementNetworkKey.getElementsByTagNameNS("*","interface-route-prefixes") - String interfaceRoutePrefixValues = sb3.append("[") - - for(int a = 0; a < interfaceRoutePrefixesList.getLength(); a++){ - Node interfaceRoutePrefix = interfaceRoutePrefixesList.item(a) - if (interfaceRoutePrefix.getNodeType() == Node.ELEMENT_NODE) { - Element eElementInterfaceRoutePrefix = (Element) interfaceRoutePrefix - String interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix-cidr") - if (interfaceRoutePrefixValue == null || interfaceRoutePrefixValue.isEmpty()) { - interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix") - } - if (a != interfaceRoutePrefixesList.getLength() - 1) { - interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}" + ",") - } - else { - interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}") - } - } - } - interfaceRoutePrefixValues = sb3.append("]") - if (interfaceRoutePrefixesList.getLength() > 0) { - String interfaceRoutePrefixesXml = - """ + vmNetworks = sbVmNetworks.append(vmNetworksXml) + + NodeList interfaceRoutePrefixesList = eElementNetworkKey.getElementsByTagNameNS("*","interface-route-prefixes") + String interfaceRoutePrefixValues = sb3.append("[") + + for(int a = 0; a < interfaceRoutePrefixesList.getLength(); a++){ + Node interfaceRoutePrefix = interfaceRoutePrefixesList.item(a) + if (interfaceRoutePrefix.getNodeType() == Node.ELEMENT_NODE) { + Element eElementInterfaceRoutePrefix = (Element) interfaceRoutePrefix + String interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix-cidr") + if (interfaceRoutePrefixValue == null || interfaceRoutePrefixValue.isEmpty()) { + interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix") + } + if (a != interfaceRoutePrefixesList.getLength() - 1) { + interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}" + ",") + } + else { + interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}") + } + } + } + interfaceRoutePrefixValues = sb3.append("]") + if (interfaceRoutePrefixesList.getLength() > 0) { + String interfaceRoutePrefixesXml = + """ ${MsoUtils.xmlEscape(key)}_${MsoUtils.xmlEscape(networkKey)}_route_prefixes ${MsoUtils.xmlEscape(interfaceRoutePrefixValues)} - """ - interfaceRoutePrefixes = sbInterfaceRoutePrefixes.append(interfaceRoutePrefixesXml) - } - - NodeList networkIpsV6List = eElementNetworkKey.getElementsByTagNameNS("*","network-ips-v6") - for(int a = 0; a < networkIpsV6List.getLength(); a++){ - Node ipV6Address = networkIpsV6List.item(a) - if (ipV6Address.getNodeType() == Node.ELEMENT_NODE) { - Element eElementIpV6Address = (Element) ipV6Address - String ipV6AddressValue = utils.getElementText(eElementIpV6Address, "ip-address-ipv6") - if (a != networkIpsV6List.getLength() - 1) { - ipV6AddressValues = sb4.append(ipV6AddressValue + ",") - } - else { - ipV6AddressValues = sb4.append(ipV6AddressValue); - } - networkPosition = a.toString() - String vmNetworksPositionsV6Xml = - """ + """ + interfaceRoutePrefixes = sbInterfaceRoutePrefixes.append(interfaceRoutePrefixesXml) + } + + NodeList networkIpsV6List = eElementNetworkKey.getElementsByTagNameNS("*","network-ips-v6") + for(int a = 0; a < networkIpsV6List.getLength(); a++){ + Node ipV6Address = networkIpsV6List.item(a) + if (ipV6Address.getNodeType() == Node.ELEMENT_NODE) { + Element eElementIpV6Address = (Element) ipV6Address + String ipV6AddressValue = utils.getElementText(eElementIpV6Address, "ip-address-ipv6") + if (a != networkIpsV6List.getLength() - 1) { + ipV6AddressValues = sb4.append(ipV6AddressValue + ",") + } + else { + ipV6AddressValues = sb4.append(ipV6AddressValue); + } + networkPosition = a.toString() + String vmNetworksPositionsV6Xml = + """ ${MsoUtils.xmlEscape(key)}_${MsoUtils.xmlEscape(networkKey)}_v6_ip_${MsoUtils.xmlEscape(networkPosition)} ${MsoUtils.xmlEscape(ipV6AddressValue)} """ - vmNetworksPositionsV6 = sbNetworksPositionsV6.append(vmNetworksPositionsV6Xml) - } - } - String vmNetworksV6Xml = - """ + vmNetworksPositionsV6 = sbNetworksPositionsV6.append(vmNetworksPositionsV6Xml) + } + } + String vmNetworksV6Xml = + """ ${MsoUtils.xmlEscape(key)}_${MsoUtils.xmlEscape(networkKey)}_v6_ips ${MsoUtils.xmlEscape(ipV6AddressValues)} """ - vmNetworks = sbVmNetworks.append(vmNetworksV6Xml) - } - } - String vnfXml = - """ + vmNetworks = sbVmNetworks.append(vmNetworksV6Xml) + } + } + String vnfXml = + """ ${MsoUtils.xmlEscape(key)}_names ${MsoUtils.xmlEscape(values)} """ - vnfVMS = sb.append(vnfXml) - } - } - //SDNC Response Params - String sdncResponseParams = "" - List sdncResponseParamsToSkip = ["vnf_id", "vf_module_id", "vnf_name", "vf_module_name"] - String vnfParamsChildNodes = utils.getChildNodes(data, "vnf-parameters") - if(vnfParamsChildNodes == null || vnfParamsChildNodes.length() < 1){ - // No SDNC params - }else{ - 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") - if (!sdncResponseParamsToSkip.contains(vnfParameterName)) { - String vnfParameterValue = utils.getElementText(eElement, "vnf-parameter-value") - String paraEntry = - """ + vnfVMS = sb.append(vnfXml) + } + } + //SDNC Response Params + String sdncResponseParams = "" + List sdncResponseParamsToSkip = [ + "vnf_id", + "vf_module_id", + "vnf_name", + "vf_module_name" + ] + String vnfParamsChildNodes = utils.getChildNodes(data, "vnf-parameters") + if(vnfParamsChildNodes == null || vnfParamsChildNodes.length() < 1){ + // No SDNC params + }else{ + 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") + if (!sdncResponseParamsToSkip.contains(vnfParameterName)) { + String vnfParameterValue = utils.getElementText(eElement, "vnf-parameter-value") + String paraEntry = + """ ${MsoUtils.xmlEscape(vnfParameterName)} ${MsoUtils.xmlEscape(vnfParameterValue)} """ - sdncResponseParams = sb.append(paraEntry) - } - } - } - - - def vfModuleParams = """ + sdncResponseParams = sb.append(paraEntry) + } + } + } + + + def vfModuleParams = """ ${vnfInfo} ${aZones} ${vnfNetworkNetId} @@ -1247,8 +1337,8 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { ${vnfParams} ${sdncResponseParams}""" - return vfModuleParams + return vfModuleParams - } + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy index 6b4fc840f7..ea9987e2ec 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy @@ -270,11 +270,11 @@ public class DoCreateVfModule extends VfModuleBase { Map vfModuleInputParams = execution.getVariable("vfModuleInputParams") if (oofDirectives != null && vfModuleInputParams != null) { vfModuleInputParams.put("oof_directives", oofDirectives) - vfModuleInputParams.put("sdnc_directives", "{}") + //vfModuleInputParams.put("sdnc_directives", "{}") logger.debug("OofDirectives are: " + oofDirectives) } else if (vfModuleInputParams != null) { vfModuleInputParams.put("oof_directives", "{}") - vfModuleInputParams.put("sdnc_directives", "{}") + //vfModuleInputParams.put("sdnc_directives", "{}") } if (vfModuleInputParams != null) { execution.setVariable("DCVFM_vnfParamsMap", vfModuleInputParams) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleTest.groovy index faa6a0e395..5a6ad4291e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -47,6 +47,9 @@ import static org.mockito.Mockito.* class DoCreateVfModuleTest { def prefix = "DCVFM_" + @Rule + public WireMockRule wireMockRule = new WireMockRule(8090); + @Captor static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) @@ -54,7 +57,7 @@ class DoCreateVfModuleTest { void init() throws IOException { MockitoAnnotations.initMocks(this); } - + @Test void testQueryAAIVfModule() { ExecutionEntity mockExecution = setupMock() @@ -90,7 +93,7 @@ class DoCreateVfModuleTest { Mockito.verify(mockExecution).setVariable("DCVFM_queryAAIVfModuleForStatusResponseCode", 200) } - + @Test void testPreProcessVNFAdapterRequest() { @@ -122,7 +125,7 @@ class DoCreateVfModuleTest { map.put("vrr_image_name", "MDT17"); map.put("availability_zone_0", "nova"); map.put("vrr_flavor_name", "ns.c16r32d128.v1"); - when(mockExecution.getVariable("vnfParamsMap")).thenReturn(map) + when(mockExecution.getVariable(prefix + "vnfParamsMap")).thenReturn(map) when(mockExecution.getVariable("mso-request-id")).thenReturn("testRequestId-1503410089303") when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn("true") when(mockExecution.getVariable("mso.workflow.message.endpoint")).thenReturn("http://localhost:28080/mso/WorkflowMesssage") @@ -155,7 +158,7 @@ class DoCreateVfModuleTest { Mockito.verify(mockExecution).setVariable(prefix + "queryCloudRegionReturnCode", "200") } - + @Test void testCreateNetworkPoliciesInAAI() { @@ -181,7 +184,7 @@ class DoCreateVfModuleTest { Mockito.verify(mockExecution).setVariable(prefix + "aaiQqueryNetworkPolicyByFqdnReturnCode", 200) } - + private static ExecutionEntity setupMock() { ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/DoCreateVfModule/createVnfARequest.xml b/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/DoCreateVfModule/createVnfARequest.xml index f78d38f802..782936c382 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/DoCreateVfModule/createVnfARequest.xml +++ b/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/DoCreateVfModule/createVnfARequest.xml @@ -1,5 +1,6 @@ RDM2WAGPLCP + null fba1bd1e195a404cacb9ce17a9b2b421 skask skask-test @@ -46,6 +47,10 @@ workload_context null + + user_directives + { "attributes": [{"attribute_name":"vrr_image_name","attribute_value":"MDT17"},{"attribute_name":"availability_zone_0","attribute_value":"nova"},{"attribute_name":"vrr_flavor_name","attribute_value":"ns.c16r32d128.v1"}]} + vf_module_name PCRF::module-0-2 @@ -70,6 +75,10 @@ ADIG_SRIOV_1_subnet_id + + vrr_flavor_name + ns.c16r32d128.v1 + ADIG_SRIOV_2_net_name ADIG_SRIOV_2 @@ -102,6 +111,10 @@ vrra_ADIG_SRIOV_2_ips null + + sdnc_directives + { "attributes": [{"attribute_name":"vf_module_id","attribute_value":"cb510af0-5b21-4bc7-86d9-323cb396ce32"},{"attribute_name":"vrra_Internal-Network1_ips","attribute_value":"null"},{"attribute_name":"ADIG_SRIOV_2_subnet_id","attribute_value":""},{"attribute_name":"vrra_ADIGOam.OAM_v6_ips","attribute_value":"null"},{"attribute_name":"vnf_name","attribute_value":"skask-test"},{"attribute_name":"ADIGOam.OAM_v6_subnet_id","attribute_value":""},{"attribute_name":"workload_context","attribute_value":"null"},{"attribute_name":"vf_module_name","attribute_value":"PCRF::module-0-2"},{"attribute_name":"vnf_id","attribute_value":"skask"},{"attribute_name":"ADIG_SRIOV_2_v6_subnet_id","attribute_value":""},{"attribute_name":"vrra_ADIG_SRIOV_1_ips","attribute_value":"null"},{"attribute_name":"ADIG_SRIOV_1_v6_subnet_id","attribute_value":""},{"attribute_name":"ADIG_SRIOV_1_subnet_id","attribute_value":""},{"attribute_name":"ADIG_SRIOV_2_net_name","attribute_value":"ADIG_SRIOV_2"},{"attribute_name":"ADIGOam.OAM_subnet_id","attribute_value":""},{"attribute_name":"ADIGOam.OAM_net_id","attribute_value":"491c7cef-a3f4-4990-883e-b0af397466d0"},{"attribute_name":"environment_context","attribute_value":"null"},{"attribute_name":"ADIG_SRIOV_1_net_fqdn","attribute_value":""},{"attribute_name":"ADIGOam.OAM_net_name","attribute_value":"ADIGOAM.OAM"},{"attribute_name":"vrra_name_0","attribute_value":"frkdevRvrra24"},{"attribute_name":"vrra_ADIG_SRIOV_2_ips","attribute_value":"null"},{"attribute_name":"ADIG_SRIOV_2_net_fqdn","attribute_value":""},{"attribute_name":"vrra_Internal-Network2_ips","attribute_value":"null"},{"attribute_name":"ADIG_SRIOV_1_net_name","attribute_value":"ADIG_SRIOV_1"},{"attribute_name":"vrra_ADIG_SRIOV_1_v6_ips","attribute_value":"null"},{"attribute_name":"vrra_ADIGOam.OAM_ips","attribute_value":"null"},{"attribute_name":"vrra_Internal-Network1_v6_ips","attribute_value":"null"},{"attribute_name":"ADIGOam.OAM_net_fqdn","attribute_value":""},{"attribute_name":"vrra_names","attribute_value":"frkdevRvrra24"},{"attribute_name":"ADIG_SRIOV_1_net_id","attribute_value":"491c7cef-a3f4-4990-883e-b0af397466d0"},{"attribute_name":"vrra_Internal-Network2_v6_ips","attribute_value":"null"},{"attribute_name":"vrra_ADIG_SRIOV_2_v6_ips","attribute_value":"null"},{"attribute_name":"ADIG_SRIOV_2_net_id","attribute_value":"491c7cef-a3f4-4990-883e-b0af397466d0"},{"attribute_name":"vf_module_index","attribute_value":"index"},{"attribute_name":"availability_zone_0","attribute_value":"frkde-esx-az01"}]} + ADIG_SRIOV_2_net_fqdn @@ -126,6 +139,10 @@ vrra_Internal-Network1_v6_ips null + + vrr_image_name + MDT17 + ADIGOam.OAM_net_fqdn @@ -156,9 +173,10 @@ availability_zone_0 - frkde-esx-az01 + nova + testRequestId @@ -166,4 +184,4 @@ testRequestId-1503410089303-1513204371234 http://localhost:28080/mso/WorkflowMesssage/VNFAResponse/testRequestId-1503410089303-1513204371234 - \ No newline at end of file + -- cgit 1.2.3-korg From eee110cb38b47745cadc65ca7cbb5c64a1965418 Mon Sep 17 00:00:00 2001 From: Elena Kuleshov Date: Sun, 5 May 2019 07:51:49 -0400 Subject: Fix deployment of workflows on start Fix deployment of workflows on start Change-Id: Iaa5cb96020da20c96bedb81e0829f73c7461b67f Issue-ID: SO-1837 Signed-off-by: Kuleshov, Elena --- .../so/db/catalog/client/CatalogDbClientTest.java | 15 ++++++ .../MSOInfrastructureApplication.java | 58 ++++++++++++---------- .../onap/so/db/catalog/client/CatalogDbClient.java | 8 +++ .../data/repository/WorkflowRepository.java | 2 + .../data/repository/WorkflowRepositoryTest.java | 10 ++++ 5 files changed, 67 insertions(+), 26 deletions(-) (limited to 'bpmn') diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index 51b44b0d3a..9265e5aa54 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -673,4 +673,19 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { Assert.assertNull(workflow); } + @Test + public void getWorkflowBySource_validSource_expectedOutput() { + List workflows = client.findWorkflowBySource("sdc"); + assertTrue(workflows != null); + assertTrue(workflows.size() != 0); + + assertEquals("testingWorkflow", workflows.get(0).getArtifactName()); + } + + @Test + public void getWorkflowBySource_invalidSource_nullOutput() { + List workflow = client.findWorkflowBySource("abc"); + Assert.assertNull(workflow); + } + } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java index c61808ebb1..8168d2a4b8 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java @@ -24,14 +24,14 @@ package org.onap.so.bpmn.infrastructure; import java.util.List; import java.util.concurrent.Executor; -import org.camunda.bpm.application.PostDeploy; +import javax.annotation.PostConstruct; import org.camunda.bpm.application.PreUndeploy; import org.camunda.bpm.application.ProcessApplicationInfo; import org.camunda.bpm.engine.ProcessEngine; import org.camunda.bpm.engine.repository.DeploymentBuilder; import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator; import org.onap.so.db.catalog.beans.Workflow; -import org.onap.so.db.catalog.data.repository.WorkflowRepository; +import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,13 +39,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.Primary; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @@ -56,17 +54,17 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @SpringBootApplication @EnableAsync -@EnableJpaRepositories("org.onap.so.db.catalog.data.repository") -@EntityScan({"org.onap.so.db.catalog.beans"}) @ComponentScan(basePackages = {"org.onap"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class, excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)}) public class MSOInfrastructureApplication { private static final Logger logger = LoggerFactory.getLogger(MSOInfrastructureApplication.class); + @Autowired + private ProcessEngine processEngine; @Autowired - private WorkflowRepository workflowRepository; + private CatalogDbClient catalogDbClient; @Value("${mso.async.core-pool-size}") private int corePoolSize; @@ -79,6 +77,7 @@ public class MSOInfrastructureApplication { private static final String LOGS_DIR = "logs_dir"; private static final String BPMN_SUFFIX = ".bpmn"; + private static final String SDC_SOURCE = "sdc"; private static void setLogsDir() { @@ -93,10 +92,14 @@ public class MSOInfrastructureApplication { setLogsDir(); } - @PostDeploy - public void postDeploy(ProcessEngine processEngineInstance) { - DeploymentBuilder deploymentBuilder = processEngineInstance.getRepositoryService().createDeployment(); - deployCustomWorkflows(deploymentBuilder); + @PostConstruct + public void postConstruct() { + try { + DeploymentBuilder deploymentBuilder = processEngine.getRepositoryService().createDeployment(); + deployCustomWorkflows(deploymentBuilder); + } catch (Exception e) { + logger.warn("Unable to invoke deploymentBuilder: " + e.getMessage()); + } } @PreUndeploy @@ -117,23 +120,26 @@ public class MSOInfrastructureApplication { } public void deployCustomWorkflows(DeploymentBuilder deploymentBuilder) { - if (workflowRepository == null) { - return; - } - List workflows = workflowRepository.findAll(); - if (workflows != null && workflows.size() != 0) { - for (Workflow workflow : workflows) { - String workflowName = workflow.getName(); - String workflowBody = workflow.getBody(); - if (!workflowName.endsWith(BPMN_SUFFIX)) { - workflowName += BPMN_SUFFIX; - } - if (workflowBody != null) { - logger.info("{} {}", "Deploying custom workflow", workflowName); - deploymentBuilder.addString(workflowName, workflowBody); + logger.debug("Attempting to deploy custom workflows"); + try { + List workflows = catalogDbClient.findWorkflowBySource(SDC_SOURCE); + if (workflows != null && workflows.size() != 0) { + for (Workflow workflow : workflows) { + String workflowName = workflow.getName(); + String workflowBody = workflow.getBody(); + if (!workflowName.endsWith(BPMN_SUFFIX)) { + workflowName += BPMN_SUFFIX; + } + if (workflowBody != null) { + logger.info("{} {}", "Deploying custom workflow", workflowName); + deploymentBuilder.addString(workflowName, workflowBody); + } } + deploymentBuilder.enableDuplicateFiltering(true); + deploymentBuilder.deploy(); } - deploymentBuilder.deploy(); + } catch (Exception e) { + logger.warn("Unable to deploy custom workflows, " + e.getMessage()); } } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java index 19200468ae..ab5fdb939c 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java @@ -145,6 +145,7 @@ public class CatalogDbClient { private static final String CLOUD_VERSION = "cloudVersion"; private static final String HOMING_INSTANCE = "/homingInstance"; private static final String ARTIFACT_UUID = "artifactUUID"; + private static final String SOURCE = "source"; private static final String TARGET_ENTITY = "SO:CatalogDB"; private static final String ASTERISK = "*"; @@ -191,6 +192,7 @@ public class CatalogDbClient { private String findPnfResourceCustomizationByModelUuid = "/findPnfResourceCustomizationByModelUuid"; private String findWorkflowByArtifactUUID = "/findByArtifactUUID"; private String findWorkflowByModelUUID = "/findWorkflowByModelUUID"; + private String findWorkflowBySource = "/findBySource"; private String findVnfResourceCustomizationByModelUuid = "/findVnfResourceCustomizationByModelUuid"; private String serviceURI; @@ -333,6 +335,7 @@ public class CatalogDbClient { findWorkflowByArtifactUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByArtifactUUID; findWorkflowByModelUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByModelUUID; + findWorkflowBySource = endpoint + WORKFLOW + SEARCH + findWorkflowBySource; findVnfResourceCustomizationByModelUuid = endpoint + VNF_RESOURCE_CUSTOMIZATION + SEARCH + findVnfResourceCustomizationByModelUuid; @@ -889,4 +892,9 @@ public class CatalogDbClient { return this.getMultipleResources(workflowClient, getUri(UriBuilder.fromUri(findWorkflowByModelUUID) .queryParam(VNF_RESOURCE_MODEL_UUID, vnfResourceModelUUID).build().toString())); } + + public List findWorkflowBySource(String source) { + return this.getMultipleResources(workflowClient, + getUri(UriBuilder.fromUri(findWorkflowBySource).queryParam(SOURCE, source).build().toString())); + } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java index 89df52182c..8bcc60c8be 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java @@ -31,6 +31,8 @@ public interface WorkflowRepository extends JpaRepository { Workflow findByArtifactUUID(String artifactUUID); + List findBySource(String source); + /** * Used to fetch the @{link Workflow} by the Model UUID. * diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java index 547b8e50a4..171d4b29f5 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java @@ -44,4 +44,14 @@ public class WorkflowRepositoryTest extends BaseTest { Assert.assertTrue("testingWorkflow".equals(workflows.get(0).getArtifactName())); } + @Test + public void findBySourceTest() throws Exception { + List workflows = workflowRepository.findBySource("sdc"); + + Assert.assertTrue(workflows != null); + Assert.assertTrue(workflows.size() != 0); + + Assert.assertTrue("testingWorkflow".equals(workflows.get(0).getArtifactName())); + } + } -- cgit 1.2.3-korg From f3eb27f45d205b2d498e4a8bdd307bdb5696b610 Mon Sep 17 00:00:00 2001 From: seshukm Date: Mon, 6 May 2019 14:24:39 +0530 Subject: remove jtosca dependency from BPMN Infra Issue-ID: SO-1834 Change-Id: I94886972032bff3bcd9cb033ccd337ad9e597bf4 Signed-off-by: seshukm --- bpmn/MSOCommonBPMN/pom.xml | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'bpmn') diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml index 891a57d0f2..20be69c006 100644 --- a/bpmn/MSOCommonBPMN/pom.xml +++ b/bpmn/MSOCommonBPMN/pom.xml @@ -363,16 +363,6 @@ org.glassfish.jersey.media jersey-media-json-jackson - - org.onap.sdc.sdc-tosca - sdc-tosca - 1.4.4 - - - org.onap.sdc.jtosca - jtosca - 1.4.4 - org.springframework.boot spring-boot-starter-test -- cgit 1.2.3-korg From ff70bfacf24da3e9d606bc68f344c982b6dd0419 Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Mon, 13 May 2019 13:52:15 -0700 Subject: Fix GR_API no homing path Set correct variable name "homing" in AAICreateTasks.createVNF to ensure GR_API no homing path does not fail. Issue-ID: SO-1870 Change-Id: Ie19d9b5d475d2e3c5bec1f744975906813ab8723 Signed-off-by: Marcus G K Williams --- .../java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java index 4d4b7c9ad2..d23f9c52ea 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java @@ -195,7 +195,7 @@ public class AAICreateTasks { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); - execution.setVariable("callHoming", Boolean.TRUE.equals(vnf.isCallHoming())); + execution.setVariable("homing", Boolean.TRUE.equals(vnf.isCallHoming())); aaiVnfResources.createVnfandConnectServiceInstance(vnf, serviceInstance); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); -- cgit 1.2.3-korg From b6571203e371d28229ee1c0c6fda2bfcac59a5b5 Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Tue, 14 May 2019 17:04:53 -0700 Subject: Fix build, update sdnc nb version Fix sdnc generic-resource-api-client version by using the released version of the artifact 1.5.1 instead of 1.5.1-SNAPSHOT Issue-ID: SO-1877 Change-Id: Id0419e44ffd88b206a9d183bfd27e4f1da98e60e Signed-off-by: Marcus G K Williams --- bpmn/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bpmn') diff --git a/bpmn/pom.xml b/bpmn/pom.xml index 9beb02e329..c4aad4ba69 100644 --- a/bpmn/pom.xml +++ b/bpmn/pom.xml @@ -24,7 +24,7 @@ 2.4.0 UTF-8 UTF-8 - 1.5.1-SNAPSHOT + 1.5.1 -- cgit 1.2.3-korg From e987cf53cb03f19cb77a23b805dda270efe62385 Mon Sep 17 00:00:00 2001 From: sarada prasad sahoo Date: Thu, 16 May 2019 15:07:16 +0530 Subject: Fix DeleteE2EServiceInstance flow Fixed the issue when subprocess 'DoDeleteE2EServiceInstance' calls 'AAI GenericGetService' sub-process which is deleted from SO common-bpmn Change-Id: Ie170b430a21df6dc8e7ff95a9d7f2091c11a600b Issue-ID: SO-1809 Signed-off-by: sarada prasad sahoo --- .../onap/so/bpmn/common/recipe/ResourceInput.java | 3 +- .../scripts/DeleteSDNCNetworkResource.groovy | 13 +- .../scripts/DoDeleteE2EServiceInstance.groovy | 201 +++++++++--------- .../scripts/DoDeleteResourcesV1.groovy | 9 +- .../subprocess/DoDeleteE2EServiceInstance.bpmn | 232 +++++++++------------ 5 files changed, 215 insertions(+), 243 deletions(-) (limited to 'bpmn') diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java index 2bb024897c..340addcabf 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java @@ -21,6 +21,7 @@ */ package org.onap.so.bpmn.common.recipe; +import java.io.Serializable; import org.onap.so.bpmn.core.domain.ModelInfo; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -43,7 +44,7 @@ import org.slf4j.LoggerFactory; "operationId", "serviceModelInfo", "resourceModelInfo", "resourceInstancenUuid", "resourceParameters", "operationType"}) @JsonRootName("variables") -public class ResourceInput { +public class ResourceInput implements Serializable { private static Logger logger = LoggerFactory.getLogger(ResourceInput.class); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy index 20134a77a9..dd9991bbd4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy @@ -152,6 +152,7 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { logger.debug( msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } + logger.info(" ***** Exit preProcessRequest *****") } /** @@ -174,6 +175,8 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") String source = execution.getVariable("source") String sdnc_service_id = execution.getVariable(Prefix + "sdncServiceId") + String resourceInput = execution.getVariable(Prefix + "resourceInput") + logger.info("The resourceInput is: " + resourceInput) ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class) String serviceType = resourceInputObj.getServiceType() String serviceModelInvariantUuid = resourceInputObj.getServiceModelInfo().getModelInvariantUuid() @@ -373,6 +376,8 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { } public void prepareUpdateBeforeDeleteSDNCResource(DelegateExecution execution) { + logger.debug( " *** prepareUpdateBeforeDeleteSDNCResource *** ") + String resourceInput = execution.getVariable(Prefix + "resourceInput"); ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class) String operType = resourceInputObj.getOperationType() String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid() @@ -402,10 +407,13 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { """; setProgressUpdateVariables(execution, body) + logger.debug(" ***** Exit prepareUpdateBeforeDeleteSDNCResource *****") } public void prepareUpdateAfterDeleteSDNCResource(DelegateExecution execution) { + logger.debug( " *** prepareUpdateAfterDeleteSDNCResource *** ") + String resourceInput = execution.getVariable(Prefix + "resourceInput"); ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class) String operType = resourceInputObj.getOperationType() String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid() @@ -435,15 +443,16 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { """; setProgressUpdateVariables(execution, body) + logger.debug(" ***** Exit prepareUpdateAfterDeleteSDNCResource *****") } public void postDeleteSDNCCall(DelegateExecution execution){ - logger.info(" ***** Started prepareSDNCRequest *****") + logger.info(" ***** Started postDeleteSDNCCall *****") String responseCode = execution.getVariable(Prefix + "sdncDeleteReturnCode") String responseObj = execution.getVariable(Prefix + "SuccessIndicator") logger.info("response from sdnc, response code :" + responseCode + " response object :" + responseObj) - logger.info(" ***** Exit prepareSDNCRequest *****") + logger.info(" ***** Exit postDeleteSDNCCall *****") } public void sendSyncResponse (DelegateExecution execution) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy index f2af481f66..e5b8d52376 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy @@ -28,6 +28,10 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.json.JSONArray import org.json.JSONObject +import org.onap.aai.domain.yang.RelatedToProperty +import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.RelationshipData +import org.onap.aai.domain.yang.ServiceInstance import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils @@ -38,6 +42,11 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient import org.onap.so.client.HttpClientFactory +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.slf4j.Logger import org.slf4j.LoggerFactory import org.onap.so.utils.TargetEntity @@ -46,6 +55,7 @@ import org.w3c.dom.Document import org.w3c.dom.Node import org.xml.sax.InputSource +import javax.ws.rs.NotFoundException import javax.ws.rs.core.Response import javax.xml.parsers.DocumentBuilder import javax.xml.parsers.DocumentBuilderFactory @@ -113,7 +123,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) } - String sdncCallbackUrl = UrnPropertiesReader.getVariable('URN_mso_workflow_sdncadapter_callback', execution) + String sdncCallbackUrl = UrnPropertiesReader.getVariable('mso.workflow.sdncadapter.callback', execution) if (isBlank(sdncCallbackUrl)) { msg = "URN_mso_workflow_sdncadapter_callback is null" logger.info(msg) @@ -161,80 +171,60 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { String msg = "" try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") - String serviceType = "" - if(foundInAAI){ - logger.debug("Found Service-instance in AAI") + String serviceInstanceId = execution.getVariable('serviceInstanceId') + String globalSubscriberId = execution.getVariable('globalSubscriberId') + String serviceType = execution.getVariable('serviceType') - String siData = execution.getVariable("GENGS_service") - logger.debug("SI Data") - if (isBlank(siData)) - { - msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId - logger.error(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - else - { - InputSource source = new InputSource(new StringReader(siData)); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = docFactory.newDocumentBuilder() - Document serviceXml = docBuilder.parse(source) - serviceXml.getDocumentElement().normalize() - // get model invariant id - // Get Template uuid and version - if (utils.nodeExists(siData, "model-invariant-id") && utils.nodeExists(siData, "model-version-id") ) { - logger.debug("SI Data model-invariant-id and model-version-id exist") - def modelInvariantId = serviceXml.getElementsByTagName("model-invariant-id").item(0).getTextContent() - def modelVersionId = serviceXml.getElementsByTagName("model-version-id").item(0).getTextContent() - - // Set Original Template info - execution.setVariable("model-invariant-id-original", modelInvariantId) - execution.setVariable("model-version-id-original", modelVersionId) - } - logger.debug("SI Data" + siData) - //Confirm there are no related service instances (vnf/network or volume) - if (utils.nodeExists(siData, "relationship-list")) { - logger.debug("SI Data relationship-list exists") - JSONArray jArray = new JSONArray() + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId) - XmlParser xmlParser = new XmlParser() - Node root = xmlParser.parseText(siData) - def relation_list = utils.getChildNode(root, 'relationship-list') - def relationships = utils.getIdenticalChildren(relation_list, 'relationship') + if (!resourceClient.exists(serviceInstanceUri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") + } - for (def relation: relationships) { - def jObj = getRelationShipData(relation, isDebugEnabled) - jArray.put(jObj) - } + AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class) - execution.setVariable("serviceRelationShip", jArray.toString()) - execution.setVariable("serviceRelationShip", jArray.toString()) - } + Optional si = wrapper.asBean(ServiceInstance.class) + + // found in AAI + if (si.isPresent() && StringUtils.isNotEmpty(si.get().getServiceInstanceName())) { + logger.debug("Found Service-instance in AAI") + execution.setVariable("serviceInstanceName", si.get().getServiceInstanceName()) + // get model invariant id + // Get Template uuid and version + if ((null != si.get().getModelInvariantId()) && (null != si.get().getModelVersionId())) { + logger.debug("SI Data model-invariant-id and model-version-id exist") + + // Set Original Template info + execution.setVariable("model-invariant-id-original", si.get().getModelInvariantId()) + execution.setVariable("model-version-id-original", si.get().getModelVersionId()) } - }else{ - boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") - if(!succInAAI){ - logger.debug("Error getting Service-instance from AAI :" + serviceInstanceId) - WorkflowException workflowException = execution.getVariable("WorkflowException") - if(workflowException != null){ - logger.error("workflowException: " + workflowException) - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - else { - msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI - logger.error(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + + if ((null != si.get().getRelationshipList()) && (null != si.get().getRelationshipList().getRelationship())) { + logger.debug("SI Data relationship-list exists") + List relationshipList = si.get().getRelationshipList().getRelationship() + JSONArray jArray = new JSONArray() + for (Relationship relationship : relationshipList) { + def jObj = getRelationShipData(relationship) + jArray.put(jObj) } + + execution.setVariable("serviceRelationShip", jArray.toString()) } - logger.debug("Service-instance NOT found in AAI. Silent Success") + } else { + + msg = "Service-instance: " + serviceInstanceId + " NOT found in AAI." + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) } - }catch (BpmnError e) { + } catch (BpmnError e) { throw e + } catch (NotFoundException e) { + logger.debug("Service Instance does not exist AAI") + exceptionUtil.buildAndThrowWorkflowException(execution, 404, "Service Instance was not found in aai") } catch (Exception ex) { msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIGET. " + ex.getMessage() logger.debug(msg) @@ -243,50 +233,50 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { logger.debug(" *** Exit postProcessAAIGET *** ") } - private JSONObject getRelationShipData(node, isDebugEnabled){ - JSONObject jObj = new JSONObject() + private JSONObject getRelationShipData(Relationship relationship) { + JSONObject jObj = new JSONObject() - def relation = utils.nodeToString(node) - def rt = utils.getNodeText(relation, "related-to") - def rl = utils.getNodeText(relation, "related-link") - logger.debug("ServiceInstance Related NS/Configuration :" + rl) + def rt = relationship.getRelatedTo() - def rl_datas = utils.getIdenticalChildren(node, "relationship-data") - for(def rl_data : rl_datas) { - def eKey = utils.getChildNodeText(rl_data, "relationship-key") - def eValue = utils.getChildNodeText(rl_data, "relationship-value") + def rl = relationship.getRelatedLink() + logger.debug("ServiceInstance Related NS/Configuration :" + rl) - if ((rt == "service-instance" && eKey.equals("service-instance.service-instance-id")) - //for overlay/underlay - || (rt == "configuration" && eKey.equals("configuration.configuration-id") - )){ - jObj.put("resourceInstanceId", eValue) - } - // for sp-partner and others - else if(eKey.endsWith("-id")){ - jObj.put("resourceInstanceId", eValue) - String resourceName = rt + eValue; - jObj.put("resourceType", resourceName) - } + List rl_datas = relationship.getRelationshipData() + for (RelationshipData rl_data : rl_datas) { + def eKey = rl_data.getRelationshipKey() + def eValue = rl_data.getRelationshipValue() - jObj.put("resourceLinkUrl", rl) - } + if ((rt.equals("service-instance") && eKey.equals("service-instance.service-instance-id")) + //for overlay/underlay + || (rt.equals("configuration") && eKey.equals("configuration.configuration-id") + )) { + jObj.put("resourceInstanceId", eValue) + } + // for sp-partner and others + else if (eKey.endsWith("-id")) { + jObj.put("resourceInstanceId", eValue) + String resourceName = rt + eValue; + jObj.put("resourceType", resourceName) + } - def rl_props = utils.getIdenticalChildren(node, "related-to-property") - for(def rl_prop : rl_props) { - def eKey = utils.getChildNodeText(rl_prop, "property-key") - def eValue = utils.getChildNodeText(rl_prop, "property-value") - if((rt == "service-instance" && eKey.equals("service-instance.service-instance-name")) - //for overlay/underlay - || (rt == "configuration" && eKey.equals("configuration.configuration-type"))){ - jObj.put("resourceType", eValue) - } - } + jObj.put("resourceLinkUrl", rl) + } - logger.debug("Relationship related to Resource:" + jObj.toString()) - return jObj - } + List rl_props = relationship.getRelatedToProperty() + for (RelatedToProperty rl_prop : rl_props) { + def eKey = rl_prop.getPropertyKey() + def eValue = rl_prop.getPropertyValue() + if ((rt.equals("service-instance") && eKey.equals("service-instance.service-instance-name")) + //for overlay/underlay + || (rt.equals("configuration") && eKey.equals("configuration.configuration-type"))) { + jObj.put("resourceType", eValue) + } + } + + logger.debug("Relationship related to Resource:" + jObj.toString()) + return jObj + } public void getCurrentNS(DelegateExecution execution){ logger.info( "======== Start getCurrentNS Process ======== ") @@ -392,7 +382,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { } public void postDecomposeService(DelegateExecution execution) { - logger.debug(" ***** Inside processDecomposition() of delete generic e2e service flow ***** ") + logger.debug(" ***** Inside postDecomposeService() of delete generic e2e service flow ***** ") try { ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") @@ -439,7 +429,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { // only delete real existing resources execution.setVariable("deleteResourceList", deleteRealResourceList) - + boolean isDeleteResourceListValid = false if(deleteRealResourceList.size() > 0) { isDeleteResourceListValid = true @@ -452,7 +442,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { logger.error(exceptionMessage) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) } - logger.debug( " ***** exit processDecomposition() of delete generic e2e service flow ***** ") + logger.debug( " ***** exit postDecomposeService() of delete generic e2e service flow ***** ") } public void preInitResourcesOperStatus(DelegateExecution execution){ @@ -506,7 +496,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { } logger.debug("======== COMPLETED preInitResourcesOperStatus Process ======== ") } - + public void prepareUpdateServiceOperationStatus(DelegateExecution execution){ logger.debug(" ======== STARTED prepareUpdateServiceOperationStatus Process ======== ") try{ @@ -517,7 +507,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { String progress = execution.getVariable("progress") String reason = "" String operationContent = execution.getVariable("operationContent") - + serviceId = UriUtils.encode(serviceId,"UTF-8") def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution) @@ -560,4 +550,5 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { //to do } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy index 7e194657fb..0d096f3b16 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy @@ -102,7 +102,7 @@ public class DoDeleteResourcesV1 extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) } - String sdncCallbackUrl = UrnPropertiesReader.getVariable('URN_mso_workflow_sdncadapter_callback', execution) + String sdncCallbackUrl = UrnPropertiesReader.getVariable('mso.workflow.sdncadapter.callback', execution) if (isBlank(sdncCallbackUrl)) { msg = "URN_mso_workflow_sdncadapter_callback is null" logger.error(msg) @@ -263,9 +263,10 @@ public class DoDeleteResourcesV1 extends AbstractServiceTaskProcessor { resourceInput.setServiceModelInfo(serviceDecomposition.getModelInfo()); resourceInput.setServiceType(serviceType) - String recipeURL = BPMNProperties.getProperty("bpelURL", "http://mso:8080") + recipeUri - - HttpResponse resp = BpmnRestClient.post(recipeURL, requestId, recipeTimeout, action, serviceInstanceId, serviceType, resourceInput.toString(), recipeParamXsd) + String recipeURL = BPMNProperties.getProperty("bpelURL", "http://so-bpmn-infra.onap:8081") + recipeUri + + BpmnRestClient bpmnRestClient = new BpmnRestClient() + HttpResponse resp = bpmnRestClient.post(recipeURL, requestId, recipeTimeout, action, serviceInstanceId, serviceType, resourceInput.toString(), recipeParamXsd) logger.debug(" ======== END executeResourceDelete Process ======== ") }catch(BpmnError b){ logger.error("Rethrowing MSOWorkflowException") diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteE2EServiceInstance.bpmn index 9f9d58fa19..4d0324e478 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteE2EServiceInstance.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_0vz7cd9 @@ -7,28 +7,28 @@ SequenceFlow_0vz7cd9 SequenceFlow_11e6bfy - import org.onap.so.bpmn.infrastructure.scripts.* def ddsi = new DoDeleteE2EServiceInstance() ddsi.preProcessRequest(execution) -]]> + SequenceFlow_0e7inkl - SequenceFlow_188ejvu + SequenceFlow_11e6bfy SequenceFlow_0vi0sv6 - import org.onap.so.bpmn.infrastructure.scripts.* def ddsi = new DoDeleteE2EServiceInstance() -ddsi.postProcessAAIGET(execution)]]> +ddsi.postProcessAAIGET(execution) SequenceFlow_1cevtpy SequenceFlow_12rr1yy SequenceFlow_0e7inkl - import org.onap.so.bpmn.infrastructure.scripts.* def ddsi = new DoCustomDeleteE2EServiceInstance() -ddsi.deleteServiceInstance(execution)]]> +ddsi.deleteServiceInstance(execution) @@ -41,22 +41,22 @@ ddsi.deleteServiceInstance(execution)]]> SequenceFlow_1921mo3 SequenceFlow_18vlzfo - import org.onap.so.bpmn.common.scripts.* ExceptionUtil ex = new ExceptionUtil() -ex.processJavaException(execution)]]> +ex.processJavaException(execution) - + SequenceFlow_1961633 SequenceFlow_1ym9otf - import org.onap.so.bpmn.infrastructure.scripts.* def ddsi = new DoDeleteE2EServiceInstance() -ddsi.preInitResourcesOperStatus(execution)]]> +ddsi.preInitResourcesOperStatus(execution) @@ -81,22 +81,6 @@ ddsi.preInitResourcesOperStatus(execution)]]> SequenceFlow_1j08ko3 - - - - - - - - - - - - - SequenceFlow_11e6bfy - SequenceFlow_188ejvu - - @@ -108,9 +92,9 @@ ddsi.preInitResourcesOperStatus(execution)]]> SequenceFlow_1q2mqnm SequenceFlow_0fo5vw5 - import org.onap.so.bpmn.infrastructure.scripts.* def dcsi= new DoDeleteE2EServiceInstance() -dcsi.prepareDecomposeService(execution)]]> +dcsi.prepareDecomposeService(execution) @@ -130,9 +114,9 @@ dcsi.prepareDecomposeService(execution)]]> SequenceFlow_0orw2f8 SequenceFlow_013rime - import org.onap.so.bpmn.infrastructure.scripts.* def dcsi= new DoDeleteE2EServiceInstance() -dcsi.postDecomposeService(execution)]]> +dcsi.postDecomposeService(execution) @@ -177,7 +161,7 @@ dcsi.postDecomposeService(execution)]]> - + #{(execution.getVariable("isDeleteResourceListValid" ) == true)} @@ -206,12 +190,12 @@ dcsi.postDecomposeService(execution)]]> SequenceFlow_0h5c1bd SequenceFlow_1ab3vex - import org.onap.so.bpmn.infrastructure.scripts.* execution.setVariable("progress", "100") execution.setVariable("result", "finished") execution.setVariable("operationContent", "No actual resoure in service instance") def csi= new DoDeleteE2EServiceInstance() -csi.prepareUpdateServiceOperationStatus(execution)]]> +csi.prepareUpdateServiceOperationStatus(execution) SequenceFlow_0h5c1bd @@ -224,263 +208,249 @@ csi.prepareUpdateServiceOperationStatus(execution)]]> - + - + - + - + - + - + - + - - - - + + + + - - - - + + - - + + - + - + - + - - + + - - + + - + - + - - + + - - - - - - - - - - - - - - + + - - - - + + + + - - - - + + + + - + - + - - + + - + - + - + - + - - + + - + - + - - + + - + - + - - - - + + + + - + - + - + - + - + - + - - + + - + - - + + - - + + - + - + - + - + - - + + - - + + - - - - + + + + -- cgit 1.2.3-korg From c0650e43c4228596831e5c49934a26ba4c221099 Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Thu, 16 May 2019 17:42:38 -0700 Subject: Fix homing gateway in AssignVnfBB Issue-ID: SO-1870 Change-Id: Id750d961276c5a4074363ed4746e95c9b67cceeb Signed-off-by: Marcus G K Williams --- .../src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn index 7bb97939dd..d522f3445e 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn @@ -24,7 +24,7 @@ - + -- cgit 1.2.3-korg From 969333e6374d3e2259ab5fbbdbcbb3f4c12a134e Mon Sep 17 00:00:00 2001 From: Elena Kuleshov Date: Mon, 20 May 2019 11:45:55 -0400 Subject: Check for null requestInfo Check for null requestInfo Issue-ID: SO-1900 Signed-off-by: Kuleshov, Elena Change-Id: I2a3eb7ddbee396b19bcc71a2f647b9cf90082ed4 --- .../tasks/BBInputSetupMapperLayer.java | 6 ++++- .../tasks/BBInputSetupMapperLayerTest.java | 13 ++++++++++ ...estDetailsInput_mapReqContextNoRequestInfo.json | 29 ++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_mapReqContextNoRequestInfo.json (limited to 'bpmn') diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index 177c918305..b90ae19ca6 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -378,7 +378,11 @@ public class BBInputSetupMapperLayer { protected OrchestrationContext mapOrchestrationContext(RequestDetails requestDetails) { OrchestrationContext context = new OrchestrationContext(); - context.setIsRollbackEnabled(!(requestDetails.getRequestInfo().getSuppressRollback())); + if (requestDetails.getRequestInfo() != null) { + context.setIsRollbackEnabled(!(requestDetails.getRequestInfo().getSuppressRollback())); + } else { + context.setIsRollbackEnabled(false); + } return context; } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java index e7afa9ec8b..39650a2142 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java @@ -570,6 +570,19 @@ public class BBInputSetupMapperLayerTest { assertThat(actual, sameBeanAs(expected)); } + @Test + public void testMapOrchestrationContextNoRequestInfo() throws IOException { + OrchestrationContext expected = new OrchestrationContext(); + expected.setIsRollbackEnabled(false); + + RequestDetails requestDetails = mapper.readValue( + new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContextNoRequestInfo.json"), RequestDetails.class); + + OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails); + + assertThat(actual, sameBeanAs(expected)); + } + @Test public void testMapLocationContext() { CloudRegion expected = new CloudRegion(); diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_mapReqContextNoRequestInfo.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_mapReqContextNoRequestInfo.json new file mode 100644 index 0000000000..41f0fde834 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_mapReqContextNoRequestInfo.json @@ -0,0 +1,29 @@ +{ + "requestParameters": { + "subscriptionServiceType": "subscriptionServiceType", + "userParams": [ + { + "name" : "mns_vfw_protected_route_prefixes", + "value" : [ { + "interface_route_table_routes_route" : "1.1.1.1/32" + }, { + "interface_route_table_routes_route" : "0::1/128" + } ] + }, + { + "name": "name1", + "value": "value1" + }, + { + "ignore": "false", + "skip": "ignore" + }] + }, + "configurationParameters": [ + { + "availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]", + "xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]" + } + ] +} + -- cgit 1.2.3-korg From e6e0c906bddeb9bb5b67b16b4b9530d6b0c1946c Mon Sep 17 00:00:00 2001 From: Elena Kuleshov Date: Mon, 20 May 2019 17:22:18 -0400 Subject: Change serviceInstance CM retrieval Change serviceInstance CM retrieval Issue-ID: SO-1903 Signed-off-by: Kuleshov, Elena Change-Id: I6bc1e3f0d219d6c9feff083ce43cd6afdec1c439 --- .../bpmn/servicedecomposition/tasks/ExtractPojosForBB.java | 9 +++++++-- .../so/bpmn/servicedecomposition/ExtractPojosForBBTest.java | 12 ++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'bpmn') diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java index 86bbead9a4..b76316bf0e 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java @@ -57,8 +57,13 @@ public class ExtractPojosForBB { GenericVnf vnf; switch (key) { case SERVICE_INSTANCE_ID: - result = lookupObjectInList(gBBInput.getCustomer().getServiceSubscription().getServiceInstances(), - value); + if (gBBInput.getCustomer().getServiceSubscription() == null + && gBBInput.getServiceInstance() != null) { + result = Optional.of((T) gBBInput.getServiceInstance()); + } else { + result = lookupObjectInList( + gBBInput.getCustomer().getServiceSubscription().getServiceInstances(), value); + } break; case GENERIC_VNF_ID: serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java index 8ab2c8e155..7bd2beeb92 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java @@ -227,4 +227,16 @@ public class ExtractPojosForBBTest extends BaseTest { gBBInput.setCustomer(customer); extractPojos.extractByKey(execution, ResourceKey.VPN_BONDING_LINK_ID); } + + @Test + public void getServiceInstanceWithNoCustomer() throws BBObjectNotFoundException { + ServiceInstance serviceInstancePend = new ServiceInstance(); + serviceInstancePend.setServiceInstanceId("abc"); + lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstancePend.getServiceInstanceId()); + Customer customer = new Customer(); + gBBInput.setCustomer(customer); + gBBInput.setServiceInstance(serviceInstancePend); + ServiceInstance extractServPend = extractPojos.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); + assertEquals(extractServPend.getServiceInstanceId(), serviceInstancePend.getServiceInstanceId()); + } } -- cgit 1.2.3-korg From da706c74e561962a73b8c79dae133c3f59e1cffd Mon Sep 17 00:00:00 2001 From: Elena Kuleshov Date: Tue, 21 May 2019 02:49:48 -0400 Subject: Send syncAck on first Activity Send syncAck on first Activity Issue-ID: SO-1905 Signed-off-by: Kuleshov, Elena Change-Id: I0965b8247aa88a19be4417e2b5d58bce2d5dab27 --- .../onap/so/bpmn/infrastructure/activity/ExecuteActivity.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java index 05d4f56fdc..426ef931b6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java @@ -31,6 +31,7 @@ import org.camunda.bpm.engine.delegate.JavaDelegate; import org.camunda.bpm.engine.runtime.ProcessInstanceWithVariables; import org.camunda.bpm.engine.variable.VariableMap; import org.onap.so.bpmn.core.WorkflowException; +import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionBBTasks; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; @@ -55,6 +56,7 @@ public class ExecuteActivity implements JavaDelegate { private static final String G_REQUEST_ID = "mso-request-id"; private static final String VNF_ID = "vnfId"; private static final String SERVICE_INSTANCE_ID = "serviceInstanceId"; + private static final String WORKFLOW_SYNC_ACK_SENT = "workflowSyncAckSent"; private static final String SERVICE_TASK_IMPLEMENTATION_ATTRIBUTE = "implementation"; private static final String ACTIVITY_PREFIX = "activity:"; @@ -65,12 +67,19 @@ public class ExecuteActivity implements JavaDelegate { private RuntimeService runtimeService; @Autowired private ExceptionBuilder exceptionBuilder; + @Autowired + private WorkflowActionBBTasks workflowActionBBTasks; @Override public void execute(DelegateExecution execution) throws Exception { final String requestId = (String) execution.getVariable(G_REQUEST_ID); try { + Boolean workflowSyncAckSent = (Boolean) execution.getVariable(WORKFLOW_SYNC_ACK_SENT); + if (workflowSyncAckSent == null || workflowSyncAckSent == false) { + workflowActionBBTasks.sendSyncAck(execution); + execution.setVariable(WORKFLOW_SYNC_ACK_SENT, Boolean.TRUE); + } final String implementationString = execution.getBpmnModelElementInstance().getAttributeValue(SERVICE_TASK_IMPLEMENTATION_ATTRIBUTE); logger.debug("activity implementation String: {}", implementationString); -- cgit 1.2.3-korg From 064752304122e631bcefe9c8f471171ca2ec1da4 Mon Sep 17 00:00:00 2001 From: Lukasz Rajewski Date: Tue, 14 May 2019 14:07:20 +0200 Subject: Missing modifications for DistributeTraffic actions Added input parameters for DistributeTraffic and DistributeTrafficCheck action Change-Id: I423979f6e8a682bff2aaff02bba4d79d2fbe22c8 Issue-ID: SO-1553 Signed-off-by: Lukasz Rajewski --- .../db/migration/R__WorkflowDesignerData.sql | 15 +++++ .../onap/so/bpmn/appc/payload/PayloadClient.java | 35 ++++++++++ .../ConfigurationParametersDistributeTraffic.java | 78 ++++++++++++++++++++++ .../payload/beans/DistributeTrafficAction.java | 44 ++++++++++++ .../beans/DistributeTrafficCheckAction.java | 44 ++++++++++++ .../client/appc/ApplicationControllerAction.java | 31 ++++++++- 6 files changed, 245 insertions(+), 2 deletions(-) create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersDistributeTraffic.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/DistributeTrafficAction.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/DistributeTrafficCheckAction.java (limited to 'bpmn') diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__WorkflowDesignerData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__WorkflowDesignerData.sql index 054fb1af57..fd7fcd48d0 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__WorkflowDesignerData.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__WorkflowDesignerData.sql @@ -148,6 +148,9 @@ VALUES ('existing_software_version','userParams','Existing Software Version','text','',1,50,''), ('tenantId','cloudConfiguration','Tenant/Project ID','text','',1,36,''), ('new_software_version','userParams','New Software Version','text','',1,50,''), +('book_name','userParams','Name of Commands Book Set','text','',1,50,''), +('node_list','userParams','List of Nodes','text','',1,200,''), +('file_parameter_content','userParams','Configuration File Content','text','',1,50000,''), ('lcpCloudRegionId','cloudConfiguration','Cloud Region ID','text','',1,7,''); INSERT INTO `activity_spec_to_user_parameters`(`ACTIVITY_SPEC_ID`,`USER_PARAMETERS_ID`) @@ -166,6 +169,18 @@ VALUES (select ID from user_parameters where NAME='tenantId')), ((select ID from activity_spec where NAME='VNFQuiesceTrafficActivity' and VERSION=1.0), (select ID from user_parameters where NAME='operations_timeout')), +((select ID from activity_spec where NAME='DistributeTrafficActivity' and VERSION=1.0), +(select ID from user_parameters where NAME='book_name')), +((select ID from activity_spec where NAME='DistributeTrafficActivity' and VERSION=1.0), +(select ID from user_parameters where NAME='node_list')), +((select ID from activity_spec where NAME='DistributeTrafficActivity' and VERSION=1.0), +(select ID from user_parameters where NAME='file_parameter_content')), +((select ID from activity_spec where NAME='DistributeTrafficCheckActivity' and VERSION=1.0), +(select ID from user_parameters where NAME='book_name')), +((select ID from activity_spec where NAME='DistributeTrafficCheckActivity' and VERSION=1.0), +(select ID from user_parameters where NAME='node_list')), +((select ID from activity_spec where NAME='DistributeTrafficCheckActivity' and VERSION=1.0), +(select ID from user_parameters where NAME='file_parameter_content')), ((select ID from activity_spec where NAME='VNFUpgradeBackupActivity' and VERSION=1.0), (select ID from user_parameters where NAME='existing_software_version')), ((select ID from activity_spec where NAME='VNFUpgradeBackupActivity' and VERSION=1.0), diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java index 3b768cbc3b..9e9c4b5cfa 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java @@ -24,11 +24,14 @@ import java.util.Optional; import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersHealthCheck; import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersQuiesce; import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersResumeTraffic; +import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersDistributeTraffic; import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersUpgrade; import org.onap.so.bpmn.appc.payload.beans.HealthCheckAction; import org.onap.so.bpmn.appc.payload.beans.QuiesceTrafficAction; import org.onap.so.bpmn.appc.payload.beans.RequestParametersHealthCheck; import org.onap.so.bpmn.appc.payload.beans.ResumeTrafficAction; +import org.onap.so.bpmn.appc.payload.beans.DistributeTrafficAction; +import org.onap.so.bpmn.appc.payload.beans.DistributeTrafficCheckAction; import org.onap.so.bpmn.appc.payload.beans.SnapshotAction; import org.onap.so.bpmn.appc.payload.beans.StartStopAction; import org.onap.so.bpmn.appc.payload.beans.UpgradeAction; @@ -56,6 +59,38 @@ public class PayloadClient { return Optional.of(mapper.writeValueAsString(payloadResult)); } + public static Optional distributeTrafficFormat(Optional payload, String vnfName) + throws JsonProcessingException { + DistributeTrafficAction payloadResult = new DistributeTrafficAction(); + ConfigurationParametersDistributeTraffic configParams = new ConfigurationParametersDistributeTraffic(); + String payloadString = payload.isPresent() ? payload.get() : ""; + String bookName = JsonUtils.getJsonValue(payloadString, "book_name"); + String nodeList = JsonUtils.getJsonValue(payloadString, "node_list"); + String fileParameterContent = JsonUtils.getJsonValue(payloadString, "file_parameter_content"); + configParams.setBookName(bookName); + configParams.setNodeList(nodeList); + configParams.setFileParameterContent(fileParameterContent); + configParams.setVnfName(vnfName); + payloadResult.setConfigurationParameters(configParams); + return Optional.of(mapper.writeValueAsString(payloadResult)); + } + + public static Optional distributeTrafficCheckFormat(Optional payload, String vnfName) + throws JsonProcessingException { + DistributeTrafficCheckAction payloadResult = new DistributeTrafficCheckAction(); + ConfigurationParametersDistributeTraffic configParams = new ConfigurationParametersDistributeTraffic(); + String payloadString = payload.isPresent() ? payload.get() : ""; + String bookName = JsonUtils.getJsonValue(payloadString, "book_name"); + String nodeList = JsonUtils.getJsonValue(payloadString, "node_list"); + String fileParameterContent = JsonUtils.getJsonValue(payloadString, "file_parameter_content"); + configParams.setBookName(bookName); + configParams.setNodeList(nodeList); + configParams.setFileParameterContent(fileParameterContent); + configParams.setVnfName(vnfName); + payloadResult.setConfigurationParameters(configParams); + return Optional.of(mapper.writeValueAsString(payloadResult)); + } + public static Optional resumeTrafficFormat(String vnfName) throws JsonProcessingException { ResumeTrafficAction payloadResult = new ResumeTrafficAction(); ConfigurationParametersResumeTraffic configParams = new ConfigurationParametersResumeTraffic(); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersDistributeTraffic.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersDistributeTraffic.java new file mode 100644 index 0000000000..a4ffdbfdba --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersDistributeTraffic.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"vnf_name", "book_name", "node_list", "file_parameter_content"}) +public class ConfigurationParametersDistributeTraffic { + @JsonProperty("vnf_name") + private String vnfName; + @JsonProperty("book_name") + private String bookName; + @JsonProperty("node_list") + private String nodeList; + @JsonProperty("file_parameter_content") + private String fileParameterContent; + + @JsonProperty("vnf_name") + public String getVnfName() { + return vnfName; + } + + @JsonProperty("vnf_name") + public void setVnfName(String vnfName) { + this.vnfName = vnfName; + } + + @JsonProperty("book_name") + public String getBookName() { + return bookName; + } + + @JsonProperty("book_name") + public void setBookName(String bookName) { + this.bookName = bookName; + } + + @JsonProperty("node_list") + public String getNodeList() { + return nodeList; + } + + @JsonProperty("node_list") + public void setNodeList(String nodeList) { + this.nodeList = nodeList; + } + + @JsonProperty("file_parameter_content") + public String getFileParameterContent() { + return fileParameterContent; + } + + @JsonProperty("file_parameter_content") + public void setFileParameterContent(String fileParameterContent) { + this.fileParameterContent = fileParameterContent; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/DistributeTrafficAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/DistributeTrafficAction.java new file mode 100644 index 0000000000..9b7856e33f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/DistributeTrafficAction.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Orange Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"configuration-parameters"}) +public class DistributeTrafficAction { + + @JsonProperty("configuration-parameters") + private ConfigurationParametersDistributeTraffic configurationParameters; + + @JsonProperty("configuration-parameters") + public ConfigurationParametersDistributeTraffic getConfigurationParameters() { + return configurationParameters; + } + + @JsonProperty("configuration-parameters") + public void setConfigurationParameters(ConfigurationParametersDistributeTraffic configurationParameters) { + this.configurationParameters = configurationParameters; + } +} + diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/DistributeTrafficCheckAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/DistributeTrafficCheckAction.java new file mode 100644 index 0000000000..b9831a90c4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/DistributeTrafficCheckAction.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Orange Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"configuration-parameters"}) +public class DistributeTrafficCheckAction { + + @JsonProperty("configuration-parameters") + private ConfigurationParametersDistributeTraffic configurationParameters; + + @JsonProperty("configuration-parameters") + public ConfigurationParametersDistributeTraffic getConfigurationParameters() { + return configurationParameters; + } + + @JsonProperty("configuration-parameters") + public void setConfigurationParameters(ConfigurationParametersDistributeTraffic configurationParameters) { + this.configurationParameters = configurationParameters; + } +} + diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java index eccd81217f..b97b9ac1ca 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java @@ -68,6 +68,12 @@ public class ApplicationControllerAction { case QuiesceTraffic: appCStatus = quiesceTrafficAction(msoRequestId, vnfId, payload, vnfName, controllerType); break; + case DistributeTraffic: + appCStatus = distributeTrafficAction(msoRequestId, vnfId, payload, vnfName, controllerType); + break; + case DistributeTrafficCheck: + appCStatus = distributeTrafficCheckAction(msoRequestId, vnfId, payload, vnfName, controllerType); + break; case HealthCheck: appCStatus = healthCheckAction(msoRequestId, vnfId, vnfName, vnfHostIpAddress, controllerType); break; @@ -91,8 +97,6 @@ public class ApplicationControllerAction { break; case ConfigModify: case ConfigScaleOut: - case DistributeTraffic: - case DistributeTrafficCheck: appCStatus = payloadAction(action, msoRequestId, vnfId, payload, controllerType); break; case UpgradePreCheck: @@ -158,6 +162,29 @@ public class ApplicationControllerAction { return client.vnfCommand(action, msoRequestId, vnfId, Optional.empty(), payload, controllerType); } + private Status distributeTrafficAction(String msoRequestId, String vnfId, Optional payload, String vnfName, + String controllerType) + throws JsonProcessingException, IllegalArgumentException, ApplicationControllerOrchestratorException { + if (!(payload.isPresent())) { + throw new IllegalArgumentException("Payload is not present for " + Action.DistributeTraffic.toString()); + } + payload = PayloadClient.distributeTrafficFormat(payload, vnfName); + return client.vnfCommand(Action.DistributeTraffic, msoRequestId, vnfId, Optional.empty(), payload, + controllerType); + } + + private Status distributeTrafficCheckAction(String msoRequestId, String vnfId, Optional payload, + String vnfName, String controllerType) + throws JsonProcessingException, IllegalArgumentException, ApplicationControllerOrchestratorException { + if (!(payload.isPresent())) { + throw new IllegalArgumentException( + "Payload is not present for " + Action.DistributeTrafficCheck.toString()); + } + payload = PayloadClient.distributeTrafficCheckFormat(payload, vnfName); + return client.vnfCommand(Action.DistributeTrafficCheck, msoRequestId, vnfId, Optional.empty(), payload, + controllerType); + } + private Status resumeTrafficAction(String msoRequestId, String vnfId, String vnfName, String controllerType) throws JsonProcessingException, ApplicationControllerOrchestratorException { Optional payload = PayloadClient.resumeTrafficFormat(vnfName); -- cgit 1.2.3-korg From f18614794608d81d6a6b868fa2e580e44e7ee6a8 Mon Sep 17 00:00:00 2001 From: "Smokowski, Steve (ss835w)" Date: Tue, 21 May 2019 11:18:44 -0400 Subject: Set Variable Fix issue here variable is not set if SI is found. Issue-ID: SO-1419 Change-Id: If9a75fc57e280c2aba5361096e4ebf01ab13056f Signed-off-by: Smokowski, Steve (ss835w) --- .../onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy index 0c676b5589..1acadbdad8 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy @@ -290,7 +290,8 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) - if(resourceClient.exists(uri)){ + if(resourceClient.exists(uri)){ + execution.setVariable("GENGS_FoundIndicator", true) execution.setVariable("GENGS_siResourceLink", uri.build().toString()) Map keys = uri.getURIKeys() String globalSubscriberId = execution.getVariable("globalSubscriberId") -- cgit 1.2.3-korg From d8644b26c6d411870b704a04dec8470184d0f081 Mon Sep 17 00:00:00 2001 From: "marios.iakovidis" Date: Wed, 22 May 2019 21:53:05 +0300 Subject: removed unused CatalogDbUtils instantiation Issue-ID: SO-1910 Signed-off-by: MariosIakovidis Change-Id: I50a2c75e2ce59a4eb7b6fb60076a34cae5482344 --- .../bpmn/infrastructure/scripts/HandlePNF.groovy | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandlePNF.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandlePNF.groovy index 90c2b923b0..261f107140 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandlePNF.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandlePNF.groovy @@ -23,7 +23,6 @@ package org.onap.so.bpmn.infrastructure.scripts import org.apache.commons.lang3.StringUtils import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.onap.so.bpmn.common.scripts.CatalogDbUtils import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames @@ -35,11 +34,10 @@ public class HandlePNF extends AbstractServiceTaskProcessor{ ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() - CatalogDbUtils cutils = new CatalogDbUtils() @Override void preProcessRequest(DelegateExecution execution) { - msoLogger.debug("Start preProcess for HandlePNF") + logger.debug("Start preProcess for HandlePNF") // set correlation ID def resourceInput = execution.getVariable("resourceInput") @@ -47,38 +45,38 @@ public class HandlePNF extends AbstractServiceTaskProcessor{ String correlationId = jsonUtil.getJsonValue(serInput, "service.parameters.requestInputs.ont_ont_pnf_name") if (!StringUtils.isEmpty(correlationId)) { execution.setVariable(ExecutionVariableNames.CORRELATION_ID, correlationId) - msoLogger.debug("Found correlation id : " + correlationId) + logger.debug("Found correlation id : " + correlationId) } else { - msoLogger.error("== correlation id is empty ==") + logger.error("== correlation id is empty ==") exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "correlation id is not provided") } // next task will set the uuid - msoLogger.debug("exit preProcess for HandlePNF") + logger.debug("exit preProcess for HandlePNF") } void postProcessRequest(DelegateExecution execution) { - msoLogger.debug("start postProcess for HandlePNF") + logger.debug("start postProcess for HandlePNF") - msoLogger.debug("exit postProcess for HandlePNF") + logger.debug("exit postProcess for HandlePNF") } public void sendSyncResponse (DelegateExecution execution) { - msoLogger.debug(" *** sendSyncResponse *** ") + logger.debug(" *** sendSyncResponse *** ") try { String operationStatus = "finished" // RESTResponse for main flow String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim() - msoLogger.debug(" sendSyncResponse to APIH:" + "\n" + resourceOperationResp) + logger.debug(" sendSyncResponse to APIH:" + "\n" + resourceOperationResp) sendWorkflowResponse(execution, 202, resourceOperationResp) execution.setVariable("sentSyncResponse", true) } catch (Exception ex) { String msg = "Exception in sendSyncResponse:" + ex.getMessage() - msoLogger.debug(msg) + logger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - msoLogger.debug(" ***** Exit sendSyncResponse *****") + logger.debug(" ***** Exit sendSyncResponse *****") } } -- cgit 1.2.3-korg From b87ccbbf96a0eac4261f5a2d51c03e18b4243ddb Mon Sep 17 00:00:00 2001 From: Elena Kuleshov Date: Wed, 22 May 2019 21:11:42 -0400 Subject: Handle case of null requestInfo Handle case of null requestInfo Issue-ID: SO-1918 Signed-off-by: Kuleshov, Elena Change-Id: Ie8a0dd9e27734d96442eceaa378e5d1e64667b06 --- .../servicedecomposition/tasks/BBInputSetupMapperLayer.java | 4 +++- bpmn/mso-infrastructure-bpmn/pom.xml | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'bpmn') diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index b90ae19ca6..6f3710835c 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -335,7 +335,9 @@ public class BBInputSetupMapperLayer { public RequestContext mapRequestContext(RequestDetails requestDetails) { RequestContext context = new RequestContext(); - modelMapper.map(requestDetails.getRequestInfo(), context); + if (null != requestDetails.getRequestInfo()) { + modelMapper.map(requestDetails.getRequestInfo(), context); + } org.onap.so.serviceinstancebeans.RequestParameters requestParameters = requestDetails.getRequestParameters(); if (null != requestParameters) { context.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType()); diff --git a/bpmn/mso-infrastructure-bpmn/pom.xml b/bpmn/mso-infrastructure-bpmn/pom.xml index 4dd7a467ea..e9ed15aa0f 100644 --- a/bpmn/mso-infrastructure-bpmn/pom.xml +++ b/bpmn/mso-infrastructure-bpmn/pom.xml @@ -152,12 +152,12 @@ org.camunda.bpm.springboot camunda-bpm-spring-boot-starter-rest ${camunda.springboot.version} - - - org.camunda.bpmn - camunda-engine-rest-core - - + + + org.camunda.bpmn + camunda-engine-rest-core + + org.camunda.bpm.springboot -- cgit 1.2.3-korg From 8ef2ec86175055aba4158f7ae571e259c7ddeddf Mon Sep 17 00:00:00 2001 From: eeginux Date: Thu, 23 May 2019 10:51:36 +0100 Subject: exception handling Update the appc client jar version Throw exception for non success cds call Fix CreateVcpeResCustServiceSimplifiedTest IT Issue-ID: SO-1857 SO-1779 Change-Id: Ifee080600051c92fd964a92d16efb67e4ab05d5d Signed-off-by: eeginux --- bpmn/MSOCommonBPMN/pom.xml | 4 +- .../client/cds/AbstractCDSProcessingBBUtils.java | 18 +++++- bpmn/pom.xml | 1 + .../resources/process/ConfigurePnfResource.bpmn | 4 +- .../CreateVcpeResCustServiceSimplifiedTest.java | 70 ++++++++++------------ 5 files changed, 55 insertions(+), 42 deletions(-) (limited to 'bpmn') diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml index 20be69c006..e233e6a7c6 100644 --- a/bpmn/MSOCommonBPMN/pom.xml +++ b/bpmn/MSOCommonBPMN/pom.xml @@ -311,7 +311,7 @@ org.onap.appc.client client-lib - 1.5.0-SNAPSHOT + ${appc.client.version} org.mockito @@ -330,7 +330,7 @@ org.onap.appc.client client-kit - 1.5.0-SNAPSHOT + ${appc.client.version} org.mockito diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java index 6bfa67502d..5498b5be31 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java @@ -34,6 +34,7 @@ import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOu import org.onap.so.client.PreconditionFailedException; import org.onap.so.client.RestPropertiesLoader; import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; +import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.ExceptionBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,6 +59,12 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { private static final String FAILED = "Failed"; private static final String PROCESSING = "Processing"; + /** + * indicate exception thrown. + */ + private static final String EXCEPTION = "Exception"; + + private final AtomicReference cdsResponse = new AtomicReference<>(); @Autowired @@ -132,7 +139,15 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { } if (cdsResponse != null) { - execution.setVariable("CDSStatus", cdsResponse.get()); + String cdsResponseStatus = cdsResponse.get(); + execution.setVariable("CDSStatus", cdsResponseStatus); + + /** + * throw CDS failed exception. + */ + if (cdsResponseStatus != SUCCESS) { + throw new BadResponseException("CDS call failed with status: " + cdsResponseStatus); + } } } catch (Exception ex) { @@ -177,6 +192,7 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { public void onError(Throwable t) { Status status = Status.fromThrowable(t); logger.error("Failed processing blueprint {}", status, t); + cdsResponse.set(EXCEPTION); } } diff --git a/bpmn/pom.xml b/bpmn/pom.xml index c4aad4ba69..fd070bb81b 100644 --- a/bpmn/pom.xml +++ b/bpmn/pom.xml @@ -25,6 +25,7 @@ UTF-8 UTF-8 1.5.1 + 1.6.0-SNAPSHOT diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn index f489a27052..9a1a7ed628 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn @@ -30,7 +30,7 @@ SequenceFlow_17llfxw SequenceFlow_0p0aqtx - + SequenceFlow_0p0aqtx SequenceFlow_1owbpsy SequenceFlow_1w4p9f7 @@ -49,7 +49,7 @@ SequenceFlow_0jfgn7n SequenceFlow_08voj55 - + SequenceFlow_08voj55 SequenceFlow_1n080up SequenceFlow_0d24h26 diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java index f51ea006d2..35f8f45999 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java @@ -33,10 +33,8 @@ import com.google.protobuf.Struct; import java.io.IOException; import java.util.List; import java.util.UUID; -import org.camunda.bpm.engine.runtime.Execution; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; @@ -52,12 +50,13 @@ import org.springframework.beans.factory.annotation.Autowired; /** * Basic Integration test for createVcpeResCustService_Simplified.bpmn workflow. */ -@Ignore public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { - private static final long WORKFLOW_WAIT_TIME = 1000L; private Logger logger = LoggerFactory.getLogger(getClass()); + private static final long WORKFLOW_WAIT_TIME = 1000L; + private static final int DMAAP_DELAY_TIME_MS = 2000; + private static final String TEST_PROCESSINSTANCE_KEY = "CreateVcpeResCustService_simplified"; private String testBusinessKey; @@ -113,17 +112,9 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { ProcessInstance pi = runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, variables); - assertThat(pi).isNotNull(); - - Thread.sleep(WORKFLOW_WAIT_TIME); - - Execution execution = runtimeService.createExecutionQuery().processInstanceBusinessKey(testBusinessKey) - .messageEventSubscriptionName("WorkflowMessage").singleResult(); - - assertThat(execution).isNotNull(); int waitCount = 10; - while (!pi.isEnded() && waitCount >= 0) { + while (!isProcessInstanceEnded() && waitCount >= 0) { Thread.sleep(WORKFLOW_WAIT_TIME); waitCount--; } @@ -145,6 +136,11 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { } } + private boolean isProcessInstanceEnded() { + return runtimeService.createProcessInstanceQuery().processDefinitionKey(TEST_PROCESSINSTANCE_KEY) + .singleResult() == null; + } + private void checkConfigAssign(ExecutionServiceInput executionServiceInput) { logger.info("Checking the configAssign request"); @@ -154,26 +150,26 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { * the fields of actionIdentifiers should match the one in the * response/createVcpeResCustServiceSimplifiedTest_catalogdb.json. */ - assertThat(actionIdentifiers.getBlueprintName()).matches("test_configuration_restconf"); - assertThat(actionIdentifiers.getBlueprintVersion()).matches("1.0.0"); - assertThat(actionIdentifiers.getActionName()).matches("config-assign"); - assertThat(actionIdentifiers.getMode()).matches("sync"); + assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_configuration_restconf"); + assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0"); + assertThat(actionIdentifiers.getActionName()).isEqualTo("config-assign"); + assertThat(actionIdentifiers.getMode()).isEqualTo("sync"); CommonHeader commonHeader = executionServiceInput.getCommonHeader(); - assertThat(commonHeader.getOriginatorId()).matches("SO"); - assertThat(commonHeader.getRequestId()).matches(msoRequestId); + assertThat(commonHeader.getOriginatorId()).isEqualTo("SO"); + assertThat(commonHeader.getRequestId()).isEqualTo(msoRequestId); Struct payload = executionServiceInput.getPayload(); Struct requeststruct = payload.getFieldsOrThrow("config-assign-request").getStructValue(); - assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).matches("PNFDemo"); + assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).isEqualTo("PNFDemo"); Struct propertiesStruct = requeststruct.getFieldsOrThrow("config-assign-properties").getStructValue(); - assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).matches("PNFDemo"); + assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo("PNFDemo"); assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()) - .matches("f2daaac6-5017-4e1e-96c8-6a27dfbe1421"); + .isEqualTo("f2daaac6-5017-4e1e-96c8-6a27dfbe1421"); assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue()) - .matches("68dc9a92-214c-11e7-93ae-92361f002680"); + .isEqualTo("68dc9a92-214c-11e7-93ae-92361f002680"); } private void checkConfigDeploy(ExecutionServiceInput executionServiceInput) { @@ -185,32 +181,32 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { * the fields of actionIdentifiers should match the one in the * response/createVcpeResCustServiceSimplifiedTest_catalogdb.json. */ - assertThat(actionIdentifiers.getBlueprintName()).matches("test_configuration_restconf"); - assertThat(actionIdentifiers.getBlueprintVersion()).matches("1.0.0"); - assertThat(actionIdentifiers.getActionName()).matches("config-deploy"); - assertThat(actionIdentifiers.getMode()).matches("async"); + assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_configuration_restconf"); + assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0"); + assertThat(actionIdentifiers.getActionName()).isEqualTo("config-deploy"); + assertThat(actionIdentifiers.getMode()).isEqualTo("async"); CommonHeader commonHeader = executionServiceInput.getCommonHeader(); - assertThat(commonHeader.getOriginatorId()).matches("SO"); - assertThat(commonHeader.getRequestId()).matches(msoRequestId); + assertThat(commonHeader.getOriginatorId()).isEqualTo("SO"); + assertThat(commonHeader.getRequestId()).isEqualTo(msoRequestId); Struct payload = executionServiceInput.getPayload(); Struct requeststruct = payload.getFieldsOrThrow("config-deploy-request").getStructValue(); - assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).matches("PNFDemo"); + assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).isEqualTo("PNFDemo"); Struct propertiesStruct = requeststruct.getFieldsOrThrow("config-deploy-properties").getStructValue(); - assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).matches("PNFDemo"); + assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo("PNFDemo"); assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()) - .matches("f2daaac6-5017-4e1e-96c8-6a27dfbe1421"); + .isEqualTo("f2daaac6-5017-4e1e-96c8-6a27dfbe1421"); assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue()) - .matches("68dc9a92-214c-11e7-93ae-92361f002680"); + .isEqualTo("68dc9a92-214c-11e7-93ae-92361f002680"); /** * IP addresses match the OAM ip addresses from AAI. */ - assertThat(propertiesStruct.getFieldsOrThrow("pnf-ipv4-address").getStringValue()).matches("1.1.1.1"); - assertThat(propertiesStruct.getFieldsOrThrow("pnf-ipv6-address").getStringValue()).matches("::/128"); + assertThat(propertiesStruct.getFieldsOrThrow("pnf-ipv4-address").getStringValue()).isEqualTo("1.1.1.1"); + assertThat(propertiesStruct.getFieldsOrThrow("pnf-ipv6-address").getStringValue()).isEqualTo("::/128"); } /** @@ -223,8 +219,8 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { /** * Get the events from PNF topic */ - wireMockServer - .stubFor(get(urlPathMatching("/events/pnfReady/consumerGroup.*")).willReturn(okJson(pnfResponse))); + wireMockServer.stubFor(get(urlPathMatching("/events/pnfReady/consumerGroup.*")) + .willReturn(okJson(pnfResponse).withFixedDelay(DMAAP_DELAY_TIME_MS))); } private void mockAai() { -- cgit 1.2.3-korg From acc7ff95a7e34daf0c1ded4a29ba98b4855ef68f Mon Sep 17 00:00:00 2001 From: seshukm Date: Fri, 24 May 2019 11:07:06 +0530 Subject: Update the version to release Issue-ID: SO-1921 Change-Id: Ib178c25b1d8704f77efa7499d724e0dead85728a Signed-off-by: seshukm --- bpmn/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bpmn') diff --git a/bpmn/pom.xml b/bpmn/pom.xml index fd070bb81b..85a45db6ba 100644 --- a/bpmn/pom.xml +++ b/bpmn/pom.xml @@ -25,7 +25,7 @@ UTF-8 UTF-8 1.5.1 - 1.6.0-SNAPSHOT + 1.5.0 -- cgit 1.2.3-korg From 03c7d857ca9aea9efd59223b6eaec7ee30545727 Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Fri, 24 May 2019 11:37:34 -0700 Subject: Fix Missing Import in OofHoming.groovy Issue-ID: SO-1926 Change-Id: Idee7eb0ab789fd8ac335b8c97b344b6e4f4b7fba Signed-off-by: Marcus G K Williams --- .../src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bpmn') diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy index d17a3c42a6..623d5a67e3 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy @@ -36,9 +36,11 @@ import org.onap.so.client.HttpClient import org.onap.so.client.HttpClientFactory import org.slf4j.Logger import org.slf4j.LoggerFactory +import org.onap.so.db.catalog.beans.AuthenticationType import org.onap.so.db.catalog.beans.CloudIdentity import org.onap.so.db.catalog.beans.CloudSite import org.onap.so.db.catalog.beans.HomingInstance +import org.onap.so.db.catalog.beans.ServerType import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.utils.TargetEntity -- cgit 1.2.3-korg From 253a7e17c7b89acfc3cb8748239a544bade75437 Mon Sep 17 00:00:00 2001 From: Yang Xu Date: Fri, 24 May 2019 16:17:50 -0400 Subject: Typo in bpmn mso-request-id variable name Change-Id: I50e7f33a3a38e77c84874d75ab33c5f9bb693f8b Issue-ID: SO-1922 Signed-off-by: Yang Xu --- .../src/main/resources/subprocess/DoCreateVnf.bpmn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnf.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnf.bpmn index 50436352ea..df95cf0210 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnf.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnf.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1 @@ -90,7 +90,7 @@ createVnf.preProcessSDNCActivateRequest(execution)]]> - + -- cgit 1.2.3-korg From 0d9e1e9383e17e715fdabac7744c6b930eca1b20 Mon Sep 17 00:00:00 2001 From: "marios.iakovidis" Date: Thu, 23 May 2019 18:29:10 +0300 Subject: fixed typos and added SERVICE_INSTANCE_ID Change-Id: I68174bf2e67280a4bf65d8f26b04793b76896f04 Issue-ID: SO-1913 Signed-off-by: MariosIakovidis --- .../org/onap/so/bpmn/infrastructure/scripts/HandlePNF.groovy | 12 ++++++++++-- .../src/main/resources/process/HandlePNF.bpmn | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandlePNF.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandlePNF.groovy index 261f107140..f06d71cec4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandlePNF.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandlePNF.groovy @@ -38,18 +38,26 @@ public class HandlePNF extends AbstractServiceTaskProcessor{ @Override void preProcessRequest(DelegateExecution execution) { logger.debug("Start preProcess for HandlePNF") - // set correlation ID def resourceInput = execution.getVariable("resourceInput") String serInput = jsonUtil.getJsonValue(resourceInput, "requestsInputs") String correlationId = jsonUtil.getJsonValue(serInput, "service.parameters.requestInputs.ont_ont_pnf_name") if (!StringUtils.isEmpty(correlationId)) { - execution.setVariable(ExecutionVariableNames.CORRELATION_ID, correlationId) + execution.setVariable(ExecutionVariableNames.PNF_CORRELATION_ID, correlationId) logger.debug("Found correlation id : " + correlationId) } else { logger.error("== correlation id is empty ==") exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "correlation id is not provided") } + + String serviceInstanceID = jsonUtil.getJsonValue(resourceInput, ExecutionVariableNames.SERVICE_INSTANCE_ID) + if (!StringUtils.isEmpty(serviceInstanceID)) { + execution.setVariable(ExecutionVariableNames.SERVICE_INSTANCE_ID, serviceInstanceID) + logger.debug("found serviceInstanceID: "+serviceInstanceID) + } else { + logger.error("== serviceInstance ID is empty ==") + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "serviceInstance ID is not provided") + } // next task will set the uuid logger.debug("exit preProcess for HandlePNF") diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/HandlePNF.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/HandlePNF.bpmn index c81b289737..01ca152e61 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/HandlePNF.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/HandlePNF.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1c92ks3_activate @@ -21,8 +21,9 @@ handlePNF.preProcessRequest(execution) - + + SequenceFlow_1apj1fn SequenceFlow_0pujwl4 -- cgit 1.2.3-korg From f3655618ffadc982bd8b45488e3b3bc2bc01ec02 Mon Sep 17 00:00:00 2001 From: "marios.iakovidis" Date: Mon, 27 May 2019 22:54:42 +0300 Subject: Fixed errors in HandlePnf flow Change-Id: I1cf49f98f26e322b4785cc14f96ee63a5830117e Issue-ID: SO-1930 Signed-off-by: MariosIakovidis --- .../src/main/resources/process/HandlePNF.bpmn | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/HandlePNF.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/HandlePNF.bpmn index 01ca152e61..257a0dee64 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/HandlePNF.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/HandlePNF.bpmn @@ -6,14 +6,12 @@ SequenceFlow_1c92ks3_activate - SequenceFlow_17xr584 SequenceFlow_12q67gd import org.onap.so.bpmn.infrastructure.scripts.* def handlePNF = new HandlePNF() handlePNF.preProcessRequest(execution) - SequenceFlow_02fi1yn @@ -24,6 +22,7 @@ handlePNF.preProcessRequest(execution) + SequenceFlow_1apj1fn SequenceFlow_0pujwl4 @@ -31,7 +30,6 @@ handlePNF.preProcessRequest(execution) SequenceFlow_0pujwl4 SequenceFlow_1la8oih - SequenceFlow_1ezf4gu import org.onap.so.bpmn.infrastructure.scripts.* def handlePNF = new HandlePNF() handlePNF.postProcessRequest(execution) @@ -40,13 +38,10 @@ handlePNF.postProcessRequest(execution) SequenceFlow_12q67gd - SequenceFlow_17xr584 SequenceFlow_1apj1fn - - SequenceFlow_1ezf4gu SequenceFlow_1la8oih SequenceFlow_02fi1yn import org.onap.so.bpmn.infrastructure.scripts.* @@ -69,10 +64,6 @@ handlePNF.sendSyncResponse(execution) - - - - @@ -95,19 +86,15 @@ handlePNF.sendSyncResponse(execution) - + - + - + - - - - -- cgit 1.2.3-korg From 019a4125af612b59f11571f52e4f369cfa59ba0c Mon Sep 17 00:00:00 2001 From: Yang Xu Date: Tue, 28 May 2019 01:09:11 -0400 Subject: Set response code in UpdateAAIGenericVnf Change-Id: I67fb789d40ea86a82379e76b94c2da1bd552cd31 Issue-ID: SO-1927 Signed-off-by: Yang Xu --- .../groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bpmn') diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy index a40bf59097..ebab6ad0ac 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy @@ -226,6 +226,8 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { try { getAAIClient().update(uri,payload) + execution.setVariable('UAAIGenVnf_updateGenericVnfResponseCode', 200) + execution.setVariable('UAAIGenVnf_updateGenericVnfResponse', "Success") } catch (Exception ex) { logger.debug('Exception occurred while executing AAI PATCH: {}', ex.getMessage(), ex) execution.setVariable('UAAIGenVnf_updateGenericVnfResponseCode', 500) -- cgit 1.2.3-korg From 55eef418214449ce11bf2247019389ddfd01af2e Mon Sep 17 00:00:00 2001 From: "marios.iakovidis" Date: Tue, 28 May 2019 13:01:41 +0300 Subject: Corrected instance names Issue-ID: SO-1931 Signed-off-by: MariosIakovidis Change-Id: I4c3700cdc1cc058f3a37a77d087d38b2aadad29d --- .../bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy index 3e059e53bf..3f9d10eaa4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy @@ -152,12 +152,12 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { execution.setVariable("isActivateRequired", "true") break - case ~/[\w\s\W]*OLT[\w\s\W]*/ : + case ~/[\w\s\W]*AccessConnectivity[\w\s\W]*/ : operationType = "AccessConnectivity" execution.setVariable("isActivateRequired", "false") break - case ~/[\w\s\W]*EdgeInternetProfile[\w\s\W]*/ : + case ~/[\w\s\W]*InternetProfile[\w\s\W]*/ : operationType = "InternetProfile" execution.setVariable("isActivateRequired", "false") break @@ -225,7 +225,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { String serInput = jsonUtil.getJsonValue(resourceInputTmp, "requestsInputs") switch (modelName) { - case ~/[\w\s\W]*OLT[\w\s\W]*/ : + case ~/[\w\s\W]*AccessConnectivity[\w\s\W]*/ : // get the required properties and update in resource input def resourceInput = resourceInputObj.getResourceParameters() @@ -252,7 +252,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { msoLogger.debug("new resource Input :" + resourceInputObj.toString()) break - case ~/[\w\s\W]*EdgeInternetProfile[\w\s\W]*/ : + case ~/[\w\s\W]*InternetProfile[\w\s\W]*/ : // get the required properties and update in resource input def resourceInput = resourceInputObj.getResourceParameters() String incomingRequest = resourceInputObj.getRequestsInputs() -- cgit 1.2.3-korg From 4db782068934ebd20caa8405cd8644a2bf922934 Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Tue, 28 May 2019 20:46:03 -0700 Subject: Fix UriBuilder import in OofUtils Import all changes from Casablanca that were incorrectly removed during merge from Casablanca back into master. Issue-ID: SO-1926 Change-Id: I8355e804586aa80e291f3c72a00bf69ce424316b Signed-off-by: Marcus G K Williams --- .../onap/so/bpmn/common/scripts/OofHoming.groovy | 36 ++++++++++++---------- .../onap/so/bpmn/common/scripts/OofUtils.groovy | 35 ++++++--------------- .../main/java/org/onap/so/utils/TargetEntity.java | 2 +- 3 files changed, 31 insertions(+), 42 deletions(-) (limited to 'bpmn') diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy index 623d5a67e3..6583ded413 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy @@ -32,17 +32,18 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.Subscriber import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.DefaultProperties import org.onap.so.client.HttpClient import org.onap.so.client.HttpClientFactory -import org.slf4j.Logger -import org.slf4j.LoggerFactory +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.db.catalog.beans.AuthenticationType import org.onap.so.db.catalog.beans.CloudIdentity import org.onap.so.db.catalog.beans.CloudSite import org.onap.so.db.catalog.beans.HomingInstance import org.onap.so.db.catalog.beans.ServerType -import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.utils.TargetEntity +import org.slf4j.Logger +import org.slf4j.LoggerFactory import org.json.JSONArray import org.json.JSONObject @@ -108,12 +109,12 @@ class OofHoming extends AbstractServiceTaskProcessor { if (isBlank(subscriberInfo)) { subscriber = new Subscriber("", "", "") } else { - String subId = jsonUtil.getJsonValue(subscriberInfo, "globalSubscriberId") - String subName = jsonUtil.getJsonValue(subscriberInfo, "subscriberName") - String subCommonSiteId = "" - if (jsonUtil.jsonElementExist(subscriberInfo, "subscriberCommonSiteId")) { - subCommonSiteId = jsonUtil.getJsonValue(subscriberInfo, "subscriberCommonSiteId") - } + String subId = jsonUtil.getJsonValue(subscriberInfo, "globalSubscriberId") + String subName = jsonUtil.getJsonValue(subscriberInfo, "subscriberName") + String subCommonSiteId = "" + if (jsonUtil.jsonElementExist(subscriberInfo, "subscriberCommonSiteId")) { + subCommonSiteId = jsonUtil.getJsonValue(subscriberInfo, "subscriberCommonSiteId") + } subscriber = new Subscriber(subId, subName, subCommonSiteId) } @@ -163,21 +164,24 @@ class OofHoming extends AbstractServiceTaskProcessor { logger.debug( "Posting to OOF Url: " + urlString) - URL url = new URL(urlString); - HttpClient httpClient = new HttpClientFactory().newJsonClient(url, TargetEntity.SNIRO) + URL url = new URL(urlString) + HttpClient httpClient = new HttpClientFactory().newJsonClient(url, TargetEntity.OOF) httpClient.addAdditionalHeader("Authorization", authHeader) - Response httpResponse = httpClient.post(oofRequest) + Response httpResponse = httpClient.post(oofRequest) - int responseCode = httpResponse.getStatus() - logger.debug("OOF sync response code is: " + responseCode) + int responseCode = httpResponse.getStatus() + logger.debug("OOF sync response code is: " + responseCode) + if(responseCode != 202){ + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") + } logger.debug( "*** Completed Homing Call OOF ***") } } catch (BpmnError b) { throw b } catch (Exception e) { - logger.error(e); + logger.error(e); exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Homing callOof: " + e.getMessage()) } @@ -360,7 +364,7 @@ class OofHoming extends AbstractServiceTaskProcessor { throw b } catch (Exception e) { logger.debug( "ProcessHomingSolution Exception: " + e) - logger.error(e); + logger.error(e); exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occurred in Homing ProcessHomingSolution") } } 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 2f46630715..4bfb29bc45 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 @@ -25,6 +25,7 @@ package org.onap.so.bpmn.common.scripts import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.util.OofInfraUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.domain.HomingSolution import org.onap.so.bpmn.core.domain.ModelInfo @@ -53,6 +54,7 @@ import org.slf4j.LoggerFactory import javax.ws.rs.core.MediaType import javax.ws.rs.core.Response +import javax.ws.rs.core.UriBuilder import javax.xml.ws.http.HTTPException import static org.onap.so.bpmn.common.scripts.GenericUtils.* @@ -62,6 +64,7 @@ class OofUtils { ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() + OofInfraUtils oofInfraUtils = new OofInfraUtils() private AbstractServiceTaskProcessor utils @@ -504,27 +507,8 @@ class OofUtils { * * @return void */ - Void createCloudSiteCatalogDb(CloudSite cloudSite, DelegateExecution execution) { - - String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution) - String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution) - String uri = "/cloudSite" - - URL url = new URL(endpoint + uri) - HttpClient client = new HttpClientFactory().newJsonClient(url, TargetEntity.EXTERNAL) - client.addAdditionalHeader(HttpHeaders.AUTHORIZATION, auth) - client.addAdditionalHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON) - - Response response = client.post(request.getBody().toString()) - - int responseCode = response.getStatus() - logger.debug("CatalogDB response code is: " + responseCode) - String syncResponse = response.readEntity(String.class) - logger.debug("CatalogDB response is: " + syncResponse) - - if(responseCode != 202){ - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from CatalogDB.") - } + Void createCloudSite(CloudSite cloudSite, DelegateExecution execution) { + oofInfraUtils.createCloudSite(cloudSite, execution) } /** @@ -537,11 +521,12 @@ class OofUtils { Void createHomingInstance(HomingInstance homingInstance, DelegateExecution execution) { oofInfraUtils.createHomingInstance(homingInstance, execution) } - String getMsbHost(DelegateExecution execution) { - String msbHost = UrnPropertiesReader.getVariable("mso.msb.host", execution, "msb-iag.onap") - Integer msbPort = UrnPropertiesReader.getVariable("mso.msb.port", execution, "80").toInteger() + String getMsbHost(DelegateExecution execution) { + String msbHost = UrnPropertiesReader.getVariable("mso.msb.host", execution, "msb-iag.onap") + + Integer msbPort = UrnPropertiesReader.getVariable("mso.msb.port", execution, "80").toInteger() - return UriBuilder.fromPath("").host(msbHost).port(msbPort).scheme("http").build().toString() + return UriBuilder.fromPath("").host(msbHost).port(msbPort).scheme("http").build().toString() } } diff --git a/common/src/main/java/org/onap/so/utils/TargetEntity.java b/common/src/main/java/org/onap/so/utils/TargetEntity.java index 5f87378b79..ea0b70413b 100644 --- a/common/src/main/java/org/onap/so/utils/TargetEntity.java +++ b/common/src/main/java/org/onap/so/utils/TargetEntity.java @@ -23,7 +23,7 @@ package org.onap.so.utils; import java.util.EnumSet; public enum TargetEntity { - OPENSTACK_ADAPTER, BPMN, GRM, AAI, DMAAP, POLICY, CATALOG_DB, REQUEST_DB, VNF_ADAPTER, SDNC_ADAPTER, SNIRO, SDC, EXTERNAL, MULTICLOUD; + OPENSTACK_ADAPTER, BPMN, GRM, AAI, DMAAP, POLICY, CATALOG_DB, REQUEST_DB, VNF_ADAPTER, SDNC_ADAPTER, SNIRO, SDC, EXTERNAL, MULTICLOUD, OOF; private static final String PREFIX = "SO"; -- cgit 1.2.3-korg From 7fd0f0846a860d4daf4f6d48e757dc03882c0ffc Mon Sep 17 00:00:00 2001 From: "marios.iakovidis" Date: Tue, 28 May 2019 22:35:44 +0300 Subject: Renamed accessId to remoteid Issue-ID: SO-1933 Signed-off-by: MariosIakovidis Change-Id: I6b63286f10ebc129b72a36cf41f0bb85b797f9ef --- .../bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy index 3f9d10eaa4..b16a3060f4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy @@ -234,7 +234,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { String requestInputs = JsonUtils.getJsonValue(serviceParameters, "requestInputs") String cvlan = "10" String svlan = "100" - String accessId = "AC9.0234.0337" + String remoteId = "AC9.0234.0337" String manufacturer = jsonUtil.getJsonValue(serInput, "service.parameters.requestInputs.ont_ont_manufacturer") String ontsn = jsonUtil.getJsonValue(serInput, @@ -242,7 +242,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { String uResourceInput = jsonUtil.addJsonValue(resourceInput, "requestInputs.CVLAN", cvlan) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.SVLAN", svlan) - uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.accessID", accessId) + uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.remote_id", remoteId) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.manufacturer", manufacturer) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ONTSN", ontsn) @@ -264,14 +264,14 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { String svlan = "1000" String manufacturer = jsonUtil.getJsonValue(serInput, "service.parameters.requestInputs.ont_ont_manufacturer") - String accessId = "AC9.0234.0337" + String remoteId = "AC9.0234.0337" String ontsn = jsonUtil.getJsonValue(serInput, "service.parameters.requestInputs.ont_ont_serial_num") String uResourceInput = jsonUtil.addJsonValue(resourceInput, "requestInputs.c_vlan", cvlan) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.s_vlan", svlan) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.manufacturer", manufacturer) - uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_access_id", accessId) + uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_remote_id", remoteId) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ont_sn", ontsn) msoLogger.debug("old resource input:" + resourceInputObj.toString()) resourceInputObj.setResourceParameters(uResourceInput) -- cgit 1.2.3-korg From f8270fc54d69ed3765ef788db1292bf27a68a351 Mon Sep 17 00:00:00 2001 From: "waqas.ikram" Date: Thu, 30 May 2019 09:48:21 +0000 Subject: Fixing ETSI BB execution failure Change-Id: Icbcd43be40c7717a714bc866bf153ac3ea0e427c Issue-ID: SO-1934 Signed-off-by: waqas.ikram --- .../subprocess/BuildingBlock/EtsiVnfInstantiateBB.bpmn | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfInstantiateBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfInstantiateBB.bpmn index 13bd107fdb..38bbdc1134 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfInstantiateBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfInstantiateBB.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_18fsqzd @@ -25,16 +25,22 @@ - - + + + + SequenceFlow_0hp0ka1 SequenceFlow_1owx4yu + + + + SequenceFlow_1owx4yu SequenceFlow_0n57z81 -- cgit 1.2.3-korg From 10c70c41244d74b04292ee1fa5c369169c07b7c9 Mon Sep 17 00:00:00 2001 From: "marios.iakovidis" Date: Thu, 30 May 2019 13:12:39 +0300 Subject: added extra parameters Issue-ID: SO-1933 Signed-off-by: MariosIakovidis Change-Id: I7fdd9ff5373e2f27d225f265ff13b4e14a8b3abc --- .../scripts/CreateSDNCNetworkResource.groovy | 56 ++++++++++++++-------- 1 file changed, 37 insertions(+), 19 deletions(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy index b16a3060f4..b0749ded86 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy @@ -232,24 +232,27 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { String incomingRequest = resourceInputObj.getRequestsInputs() String serviceParameters = JsonUtils.getJsonValue(incomingRequest, "service.parameters") String requestInputs = JsonUtils.getJsonValue(serviceParameters, "requestInputs") - String cvlan = "10" - String svlan = "100" - String remoteId = "AC9.0234.0337" + String cvlan = jsonUtil.getJsonValue(serInput, + "service.parameters.requestInputs.cvlan") + String svlan = jsonUtil.getJsonValue(serInput, + "service.parameters.requestInputs.svlan") + String remoteId = jsonUtil.getJsonValue(serInput, + "service.parameters.requestInputs.edgeinternetprofile_ip_remote_id") String manufacturer = jsonUtil.getJsonValue(serInput, "service.parameters.requestInputs.ont_ont_manufacturer") String ontsn = jsonUtil.getJsonValue(serInput, "service.parameters.requestInputs.ont_ont_serial_num") - String uResourceInput = jsonUtil.addJsonValue(resourceInput, "requestInputs.CVLAN", cvlan) - uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.SVLAN", svlan) + String uResourceInput = jsonUtil.addJsonValue(resourceInput, "requestInputs.c_vlan", cvlan) + uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.s_vlan", svlan) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.remote_id", remoteId) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.manufacturer", manufacturer) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ONTSN", ontsn) - msoLogger.debug("old resource input:" + resourceInputObj.toString()) + logger.debug("old resource input:" + resourceInputObj.toString()) resourceInputObj.setResourceParameters(uResourceInput) execution.setVariable(Prefix + "resourceInput", resourceInputObj.toString()) - msoLogger.debug("new resource Input :" + resourceInputObj.toString()) + logger.debug("new resource Input :" + resourceInputObj.toString()) break case ~/[\w\s\W]*InternetProfile[\w\s\W]*/ : @@ -260,23 +263,38 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { String requestInputs = JsonUtils.getJsonValue(serviceParameters, "requestInputs") JSONObject inputParameters = new JSONObject(requestInputs) - String cvlan = "100" - String svlan = "1000" + String cvlan = jsonUtil.getJsonValue(serInput, + "service.parameters.requestInputs.cvlan") + String svlan = jsonUtil.getJsonValue(serInput, + "service.parameters.requestInputs.svlan") String manufacturer = jsonUtil.getJsonValue(serInput, "service.parameters.requestInputs.ont_ont_manufacturer") - String remoteId = "AC9.0234.0337" + String remoteId = jsonUtil.getJsonValue(serInput, + "service.parameters.requestInputs.edgeinternetprofile_ip_remote_id") String ontsn = jsonUtil.getJsonValue(serInput, "service.parameters.requestInputs.ont_ont_serial_num") + String serviceType = jsonUtil.getJsonValue(serInput, + "service.parameters.requestInputs.edgeinternetprofile_ip_service_type") + String macAddr = jsonUtil.getJsonValue(serInput, + "service.parameters.requestInputs.edgeinternetprofile_ip_rg_mac_addr") + String upStream = jsonUtil.getJsonValue(serInput, + "service.parameters.requestInputs.edgeinternetprofile_ip_upstream_speed") + String downStream = jsonUtil.getJsonValue(serInput, + "service.parameters.requestInputs.edgeinternetprofile_ip_downstream_speed") String uResourceInput = jsonUtil.addJsonValue(resourceInput, "requestInputs.c_vlan", cvlan) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.s_vlan", svlan) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.manufacturer", manufacturer) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_remote_id", remoteId) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ont_sn", ontsn) - msoLogger.debug("old resource input:" + resourceInputObj.toString()) + uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_service_type", serviceType) + uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_rg_mac_addr", macAddr) + uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_upstream_speed", upStream) + uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_downstream_speed", downStream) + logger.debug("old resource input:" + resourceInputObj.toString()) resourceInputObj.setResourceParameters(uResourceInput) execution.setVariable(Prefix + "resourceInput", resourceInputObj.toString()) - msoLogger.debug("new resource Input :" + resourceInputObj.toString()) + logger.debug("new resource Input :" + resourceInputObj.toString()) break @@ -308,13 +326,13 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { def vpnName = StringUtils.containsIgnoreCase(modelName, "sotnvpnattachment") ? "sotnvpnattachmentvf_sotncondition_sotnVpnName" : "sdwanvpnattachmentvf_sdwancondition_sdwanVpnName" String parentServiceName = jsonUtil.getJsonValueForKey(resourceInputObj.getRequestsInputs(), vpnName) - AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, customer, serviceType).queryParam("service-instance-name", parentServiceName) - ServiceInstances sis = client.get(uri).asBean(ServiceInstances.class).get() - ServiceInstance si = sis.getServiceInstance().get(0) + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, customer, serviceType).queryParam("service-instance-name", parentServiceName) + ServiceInstances sis = client.get(uri).asBean(ServiceInstances.class).get() + ServiceInstance si = sis.getServiceInstance().get(0) - def parentServiceInstanceId = si.getServiceInstanceId() - execution.setVariable("parentServiceInstanceId", parentServiceInstanceId) + def parentServiceInstanceId = si.getServiceInstanceId() + execution.setVariable("parentServiceInstanceId", parentServiceInstanceId) break default: @@ -646,7 +664,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { val = response."response-data"."RequestData"."output"."connection-attachment-response-information"."instance-id" break - // for SDWANConnectivity and SOTNConnectivity and default: + // for SDWANConnectivity and SOTNConnectivity and default: default: val = response."response-data"."RequestData"."output"."network-response-information"."instance-id" break -- cgit 1.2.3-korg From f8ef6b32ba67831c485330f6349ea773be566183 Mon Sep 17 00:00:00 2001 From: Eric Multanen Date: Thu, 30 May 2019 07:35:13 -0700 Subject: Remove oof_directives from user_directives Oof_directives - when populated with a json string, breaks the parsing of the user_directives. Since it is not needed in the user_directives, remove it. Change-Id: I0e2c3deef8266df52ac73b95209843ac31f986ef Issue-ID: SO-1939 Signed-off-by: Eric Multanen --- .../org/onap/so/bpmn/common/scripts/VfModuleBase.groovy | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'bpmn') diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy index 07d8ec9b8e..e261fb9fdd 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy @@ -519,12 +519,14 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { String vnfKey = entry.getKey() String vnfValue = entry.getValue() paramsMap.put("$vnfKey", "$vnfValue") - if (pcnt > 0) { - userDirectivesBuilder.append(",") + if (!"oof_directives".equals(vnfKey)) { + if (pcnt > 0) { + userDirectivesBuilder.append(",") + } + pcnt++ + userDirectivesBuilder.append("{\"attribute_name\":\"${vnfKey}\",") + userDirectivesBuilder.append("\"attribute_value\":\"${vnfValue}\"}") } - pcnt++ - userDirectivesBuilder.append("{\"attribute_name\":\"${vnfKey}\",") - userDirectivesBuilder.append("\"attribute_value\":\"${vnfValue}\"}") } if (pcnt > 0) { userDirectives = userDirectivesBuilder.append("]}").toString() -- cgit 1.2.3-korg From 53791d7d6434eb5ae821cba4572a96796d65c2ee Mon Sep 17 00:00:00 2001 From: "waqas.ikram" Date: Thu, 30 May 2019 13:15:16 +0000 Subject: Fixing infinte loop of flow Change-Id: I80dc144750406d5afcec9b4da717a55a3840e503 Issue-ID: SO-1946 Signed-off-by: waqas.ikram --- .../adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java | 17 ++++++++++++----- .../adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java | 16 ++++++++++++---- .../vnfm/tasks/VnfmAdapterServiceProviderImpl.java | 2 +- .../vnfm/tasks/VnfmAdapterServiceProviderImplTest.java | 5 ++--- 4 files changed, 27 insertions(+), 13 deletions(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java index 4645680fc2..4c84bcaa1f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java @@ -55,11 +55,18 @@ public class MonitorVnfmCreateJobTask extends MonitorVnfmJobTask { * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl} */ public void getCurrentOperationStatus(final BuildingBlockExecution execution) { - LOGGER.debug("Executing getCurrentOperationStatus ..."); - final CreateVnfResponse vnfInstantiateResponse = execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME); - execution.setVariable(OPERATION_STATUS_PARAM_NAME, - getOperationStatus(execution, vnfInstantiateResponse.getJobId())); - LOGGER.debug("Finished executing getCurrentOperationStatus ..."); + try { + LOGGER.debug("Executing getCurrentOperationStatus ..."); + final CreateVnfResponse vnfInstantiateResponse = execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME); + execution.setVariable(OPERATION_STATUS_PARAM_NAME, + getOperationStatus(execution, vnfInstantiateResponse.getJobId())); + LOGGER.debug("Finished executing getCurrentOperationStatus ..."); + } catch (final Exception exception) { + final String message = "Unable to invoke get current Operation status"; + LOGGER.error(message); + exceptionUtil.buildAndThrowWorkflowException(execution, 1209, message); + + } } /** diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java index e91f362d53..34e3efa8f5 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java @@ -56,10 +56,18 @@ public class MonitorVnfmDeleteJobTask extends MonitorVnfmJobTask { * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl} */ public void getCurrentOperationStatus(final BuildingBlockExecution execution) { - LOGGER.debug("Executing getCurrentOperationStatus ..."); - final DeleteVnfResponse deleteVnfResponse = execution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME); - execution.setVariable(OPERATION_STATUS_PARAM_NAME, getOperationStatus(execution, deleteVnfResponse.getJobId())); - LOGGER.debug("Finished executing getCurrentOperationStatus ..."); + try { + LOGGER.debug("Executing getCurrentOperationStatus ..."); + final DeleteVnfResponse deleteVnfResponse = execution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME); + execution.setVariable(OPERATION_STATUS_PARAM_NAME, + getOperationStatus(execution, deleteVnfResponse.getJobId())); + LOGGER.debug("Finished executing getCurrentOperationStatus ..."); + } catch (final Exception exception) { + final String message = "Unable to invoke get current Operation status"; + LOGGER.error(message); + exceptionUtil.buildAndThrowWorkflowException(execution, 1216, message); + + } } /** diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java index f193967a32..4a51891184 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java @@ -145,7 +145,7 @@ public class VnfmAdapterServiceProviderImpl implements VnfmAdapterServiceProvide return Optional.of(response.getBody()); } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) { LOGGER.error("Unexpected error while processing job request", httpInvocationException); - return Optional.absent(); + throw httpInvocationException; } } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java index 7bd6435b60..e94d7c2923 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java @@ -228,7 +228,7 @@ public class VnfmAdapterServiceProviderImplTest { assertFalse(actual.isPresent()); } - @Test + @Test(expected = RestProcessingException.class) public void testGetInstantiateOperationJobStatus_Exception() { when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL), @@ -237,8 +237,7 @@ public class VnfmAdapterServiceProviderImplTest { final VnfmAdapterServiceProvider objUnderTest = new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider); - final Optional actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID); - assertFalse(actual.isPresent()); + objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID); } private QueryJobResponse getQueryJobResponse() { -- cgit 1.2.3-korg From a737222ca2fa0fcf87c2062c52fca8577aab87b9 Mon Sep 17 00:00:00 2001 From: Eric Multanen Date: Fri, 31 May 2019 06:44:05 -0700 Subject: Remove oof_directives from user_directives BB path Remove oof_directives from user_directives in the BB code path (as was done for the groovy code path). Change-Id: I018c3c85cc4a68ab128a2be869567b44fda08e48 Issue-ID: SO-1939 Signed-off-by: Eric Multanen --- .../vnf/mapper/VnfAdapterVfModuleObjectMapper.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index 94e95687db..b0ba0595d5 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -205,14 +205,22 @@ public class VnfAdapterVfModuleObjectMapper { private void buildDirectivesParamFromMap(Map paramsMap, String directive, Map srcMap) { StringBuilder directives = new StringBuilder(); - if (srcMap.size() > 0) { + int no_directives_size = 0; + if (directives.equals(MsoMulticloudUtils.USER_DIRECTIVES) + && srcMap.containsKey(MsoMulticloudUtils.OOF_DIRECTIVES)) { + no_directives_size = 1; + } + if (srcMap.size() > no_directives_size) { directives.append("{ \"attributes\": [ "); int i = 0; for (String attributeName : srcMap.keySet()) { - directives.append(new AttributeNameValue(attributeName, srcMap.get(attributeName).toString())); - if (i < (srcMap.size() - 1)) - directives.append(", "); - i++; + if (!(MsoMulticloudUtils.USER_DIRECTIVES.equals(directives) + && attributeName.equals(MsoMulticloudUtils.OOF_DIRECTIVES))) { + directives.append(new AttributeNameValue(attributeName, srcMap.get(attributeName).toString())); + if (i < (srcMap.size() - 1 + no_directives_size)) + directives.append(", "); + i++; + } } directives.append("] }"); } else { -- cgit 1.2.3-korg From 2eb4e1106010db7ed404f5e65257321e18fe3eb5 Mon Sep 17 00:00:00 2001 From: "waqas.ikram" Date: Fri, 31 May 2019 16:50:25 +0000 Subject: Fixing Null Value Exception Change-Id: I07553affad2297e1fa1e4e67b27bb08c51e4b8c3 Issue-ID: SO-1968 Signed-off-by: waqas.ikram --- .../subprocess/BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn index 6d54262dc5..e7d40e84b5 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn @@ -1,6 +1,6 @@ - - + + SequenceFlow_1miob62 @@ -56,7 +56,7 @@ - + -- cgit 1.2.3-korg From f5034c75fb4178791a51fd16e1322e80c05b44a8 Mon Sep 17 00:00:00 2001 From: "waqas.ikram" Date: Sun, 2 Jun 2019 15:24:20 +0000 Subject: Fixing EtSI BB ClassCastException Change-Id: Ia5a37f80392693f603d6597760ca9725882de169 Issue-ID: SO-1971 Signed-off-by: waqas.ikram --- .../BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn | 2 +- .../BuildingBlock/MonitorVnfmDeleteNodeStatus.bpmn | 4 +- .../vnfm/tasks/MonitorInstantiateVnfmNodeTask.java | 53 +++++++++ .../vnfm/tasks/MonitorTerminateVnfmNodeTask.java | 53 +++++++++ .../adapter/vnfm/tasks/MonitorVnfmNodeTask.java | 53 ++++++--- .../exception/GenericVnfNotFoundException.java | 33 ++++++ .../tasks/MonitorInstantiateVnfmNodeTaskTest.java | 129 +++++++++++++++++++++ .../tasks/MonitorTerminateVnfmNodeTaskTest.java | 113 ++++++++++++++++++ .../adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java | 111 ------------------ 9 files changed, 424 insertions(+), 127 deletions(-) create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorInstantiateVnfmNodeTask.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorTerminateVnfmNodeTask.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/exception/GenericVnfNotFoundException.java create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorInstantiateVnfmNodeTaskTest.java create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorTerminateVnfmNodeTaskTest.java delete mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java (limited to 'bpmn') diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn index e7d40e84b5..9712ca8ab7 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn @@ -24,7 +24,7 @@ SequenceFlow_1rxbeqi - + SequenceFlow_1moaz0q SequenceFlow_09t51ao SequenceFlow_0qvy3sn diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmDeleteNodeStatus.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmDeleteNodeStatus.bpmn index 8fababaffe..668cfaa44a 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmDeleteNodeStatus.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmDeleteNodeStatus.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_0spr34x @@ -28,7 +28,7 @@ ${execution.getVariable("deleteVnfNodeStatus")} - + SequenceFlow_17vvpzi SequenceFlow_11rfobu SequenceFlow_1unicf9 diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorInstantiateVnfmNodeTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorInstantiateVnfmNodeTask.java new file mode 100644 index 0000000000..b885cc2ee5 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorInstantiateVnfmNodeTask.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Ericsson. All rights reserved. + * ================================================================================ + * 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.adapter.vnfm.tasks; + +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_NODE_STATUS; +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_CREATED; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.AAIVnfResources; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @author waqas.ikram@est.tech + * + */ +@Component +public class MonitorInstantiateVnfmNodeTask extends MonitorVnfmNodeTask { + + @Autowired + public MonitorInstantiateVnfmNodeTask(final ExtractPojosForBB extractPojosForBB, + final ExceptionBuilder exceptionUtil, final AAIVnfResources aaiVnfResources) { + super(extractPojosForBB, exceptionUtil, aaiVnfResources); + } + + @Override + public String getNodeStatusVariableName() { + return CREATE_VNF_NODE_STATUS; + } + + @Override + public boolean isOrchestrationStatusValid(final String orchestrationStatus) { + return VNF_CREATED.equalsIgnoreCase(orchestrationStatus); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorTerminateVnfmNodeTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorTerminateVnfmNodeTask.java new file mode 100644 index 0000000000..34296c20d6 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorTerminateVnfmNodeTask.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Ericsson. All rights reserved. + * ================================================================================ + * 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.adapter.vnfm.tasks; + +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.DELETE_VNF_NODE_STATUS; +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_ASSIGNED; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.AAIVnfResources; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @author waqas.ikram@est.tech + * + */ +@Component +public class MonitorTerminateVnfmNodeTask extends MonitorVnfmNodeTask { + + @Autowired + public MonitorTerminateVnfmNodeTask(final ExtractPojosForBB extractPojosForBB, final ExceptionBuilder exceptionUtil, + final AAIVnfResources aaiVnfResources) { + super(extractPojosForBB, exceptionUtil, aaiVnfResources); + } + + @Override + public String getNodeStatusVariableName() { + return DELETE_VNF_NODE_STATUS; + } + + @Override + public boolean isOrchestrationStatusValid(final String orchestrationStatus) { + return VNF_ASSIGNED.equalsIgnoreCase(orchestrationStatus); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeTask.java index 65b05e21f5..a7a4eadb33 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeTask.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeTask.java @@ -19,38 +19,39 @@ */ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks; -import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_NODE_STATUS; -import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.DELETE_VNF_NODE_STATUS; -import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_ASSIGNED; -import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_CREATED; import static org.onap.so.bpmn.servicedecomposition.entities.ResourceKey.GENERIC_VNF_ID; +import java.util.Optional; import org.onap.aai.domain.yang.GenericVnf; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.exception.GenericVnfNotFoundException; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.AAIVnfResources; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; /** * * @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech) + * @author Waqas Ikram (waqas.ikram@est.tech) * */ -@Component -public class MonitorVnfmNodeTask { +public abstract class MonitorVnfmNodeTask { private static final Logger LOGGER = LoggerFactory.getLogger(MonitorVnfmNodeTask.class); private final ExtractPojosForBB extractPojosForBB; private final ExceptionBuilder exceptionUtil; + private final AAIVnfResources aaiVnfResources; @Autowired - public MonitorVnfmNodeTask(final ExtractPojosForBB extractPojosForBB, final ExceptionBuilder exceptionUtil) { + public MonitorVnfmNodeTask(final ExtractPojosForBB extractPojosForBB, final ExceptionBuilder exceptionUtil, + final AAIVnfResources aaiVnfResources) { this.exceptionUtil = exceptionUtil; this.extractPojosForBB = extractPojosForBB; + this.aaiVnfResources = aaiVnfResources; } /** @@ -61,17 +62,43 @@ public class MonitorVnfmNodeTask { public void getNodeStatus(final BuildingBlockExecution execution) { try { LOGGER.debug("Executing getNodeStatus ..."); - final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID); - String orchestrationStatus = vnf.getOrchestrationStatus(); - LOGGER.debug("Orchestration Status in AAI {}", orchestrationStatus); - execution.setVariable(CREATE_VNF_NODE_STATUS, VNF_CREATED.equalsIgnoreCase(orchestrationStatus)); - execution.setVariable(DELETE_VNF_NODE_STATUS, VNF_ASSIGNED.equalsIgnoreCase(orchestrationStatus)); + + final org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = + extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID); + + final String vnfId = vnf.getVnfId(); + LOGGER.debug("Query A&AI for generic VNF using vnfID: {}", vnfId); + final Optional aaiGenericVnfOptional = aaiVnfResources.getGenericVnf(vnfId); + + if (!aaiGenericVnfOptional.isPresent()) { + throw new GenericVnfNotFoundException("Unable to find generic vnf in A&AI using vnfID: " + vnfId); + } + final GenericVnf genericVnf = aaiGenericVnfOptional.get(); + final String orchestrationStatus = genericVnf.getOrchestrationStatus(); + LOGGER.debug("Found generic vnf with orchestration status : {}", orchestrationStatus); + + execution.setVariable(getNodeStatusVariableName(), isOrchestrationStatusValid(orchestrationStatus)); + } catch (final Exception exception) { LOGGER.error("Unable to get vnf from AAI", exception); exceptionUtil.buildAndThrowWorkflowException(execution, 1220, exception); } } + /** + * Get variable to store in execution context + * + * @return the variable name + */ + public abstract String getNodeStatusVariableName(); + + /** + * @param orchestrationStatus the orchestration status from A&AI + * @return true if valid + */ + public abstract boolean isOrchestrationStatusValid(final String orchestrationStatus); + + /** * Log and throw exception on timeout for job status * diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/exception/GenericVnfNotFoundException.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/exception/GenericVnfNotFoundException.java new file mode 100644 index 0000000000..d33d0bc895 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/exception/GenericVnfNotFoundException.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Ericsson. All rights reserved. + * ================================================================================ + * 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.adapter.vnfm.tasks.exception; + +/** + * @author waqas.ikram@est.tech + * + */ +public class GenericVnfNotFoundException extends Exception { + private static final long serialVersionUID = -2049370314818025597L; + + public GenericVnfNotFoundException(final String message) { + super(message); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorInstantiateVnfmNodeTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorInstantiateVnfmNodeTaskTest.java new file mode 100644 index 0000000000..effcf24a8d --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorInstantiateVnfmNodeTaskTest.java @@ -0,0 +1,129 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 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.adapter.vnfm.tasks; + +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_NODE_STATUS; +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_CREATED; +import java.util.Optional; +import java.util.UUID; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.client.orchestration.AAIVnfResources; + +/** + * + * @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech) + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class MonitorInstantiateVnfmNodeTaskTest extends BaseTaskTest { + + private static final String VNF_ID = UUID.randomUUID().toString(); + + private static final String VNF_NAME = "VNF_NAME"; + + private MonitorVnfmNodeTask objUnderTest; + + @Mock + private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider; + + @Mock + private AAIVnfResources mockedAaiVnfResources; + + private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution(); + + @Before + public void setUp() { + objUnderTest = getEtsiVnfMonitorNodeJobTask(); + } + + @Test + public void testGetNodeStatus_genericVnfWithOrchStatusCreated_executionVariableSetToCreate() throws Exception { + final org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = getGenericVnf(); + final GenericVnf aaiGenericVnf = getAAIGenericVnf(); + aaiGenericVnf.setOrchestrationStatus(VNF_CREATED); + + when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf); + when(mockedAaiVnfResources.getGenericVnf(eq(VNF_ID))).thenReturn(Optional.of(aaiGenericVnf)); + objUnderTest.getNodeStatus(stubbedxecution); + assertTrue(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS)); + } + + @Test + public void testGetNodeStatus_noGenericVnfFoundInAAI_throwException() throws Exception { + final org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = getGenericVnf(); + + when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf); + when(mockedAaiVnfResources.getGenericVnf(eq(VNF_ID))).thenReturn(Optional.empty()); + objUnderTest.getNodeStatus(stubbedxecution); + verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1220), + any(Exception.class)); + assertNull(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS)); + + } + + @Test + public void testGetNodeStatusException() throws Exception { + when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class); + objUnderTest.getNodeStatus(stubbedxecution); + assertNull(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS)); + verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1220), + any(Exception.class)); + } + + @Test + public void testTimeOutLogFailue() throws Exception { + objUnderTest.timeOutLogFailue(stubbedxecution); + verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1221), + eq("Node operation time out")); + } + + private GenericVnf getAAIGenericVnf() { + final GenericVnf genericVnf = new GenericVnf(); + genericVnf.setVnfId(VNF_ID); + genericVnf.setVnfName(VNF_NAME); + return genericVnf; + } + + private org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf getGenericVnf() { + final org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf = + new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf(); + genericVnf.setVnfId(VNF_ID); + return genericVnf; + + } + + private MonitorInstantiateVnfmNodeTask getEtsiVnfMonitorNodeJobTask() { + return new MonitorInstantiateVnfmNodeTask(extractPojosForBB, exceptionUtil, mockedAaiVnfResources); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorTerminateVnfmNodeTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorTerminateVnfmNodeTaskTest.java new file mode 100644 index 0000000000..04831733e1 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorTerminateVnfmNodeTaskTest.java @@ -0,0 +1,113 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 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.adapter.vnfm.tasks; + +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.DELETE_VNF_NODE_STATUS; +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_ASSIGNED; +import java.util.Optional; +import java.util.UUID; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.client.orchestration.AAIVnfResources; + +/** + * + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class MonitorTerminateVnfmNodeTaskTest extends BaseTaskTest { + + private static final String VNF_ID = UUID.randomUUID().toString(); + + private static final String VNF_NAME = "VNF_NAME"; + + private MonitorVnfmNodeTask objUnderTest; + + @Mock + private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider; + + @Mock + private AAIVnfResources mockedAaiVnfResources; + + private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution(); + + @Before + public void setUp() { + objUnderTest = getEtsiVnfMonitorNodeJobTask(); + } + + @Test + public void testGetNodeStatusDelete() throws Exception { + final org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = getGenericVnf(); + final GenericVnf aaiGenericVnf = getAAIGenericVnf(); + aaiGenericVnf.setOrchestrationStatus(VNF_ASSIGNED); + + when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf); + when(mockedAaiVnfResources.getGenericVnf(eq(VNF_ID))).thenReturn(Optional.of(aaiGenericVnf)); + + objUnderTest.getNodeStatus(stubbedxecution); + assertTrue(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS)); + } + + @Test + public void testGetNodeStatus_noGenericVnfFoundInAAI_throwException() throws Exception { + final org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = getGenericVnf(); + + when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf); + when(mockedAaiVnfResources.getGenericVnf(eq(VNF_ID))).thenReturn(Optional.empty()); + objUnderTest.getNodeStatus(stubbedxecution); + verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1220), + any(Exception.class)); + assertNull(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS)); + + } + + private GenericVnf getAAIGenericVnf() { + final GenericVnf genericVnf = new GenericVnf(); + genericVnf.setVnfId(VNF_ID); + genericVnf.setVnfName(VNF_NAME); + return genericVnf; + } + + private org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf getGenericVnf() { + final org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf = + new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf(); + genericVnf.setVnfId(VNF_ID); + return genericVnf; + + } + + private MonitorTerminateVnfmNodeTask getEtsiVnfMonitorNodeJobTask() { + return new MonitorTerminateVnfmNodeTask(extractPojosForBB, exceptionUtil, mockedAaiVnfResources); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java deleted file mode 100644 index 6b84f6a918..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 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.adapter.vnfm.tasks; - -import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_NODE_STATUS; -import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.DELETE_VNF_NODE_STATUS; -import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_CREATED; -import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_ASSIGNED; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import java.util.UUID; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.so.bpmn.BaseTaskTest; -import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; - -/** - * - * @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech) - * - */ -public class MonitorVnfmNodeJobTest extends BaseTaskTest { - - private static final String VNF_ID = UUID.randomUUID().toString(); - - private static final String VNF_NAME = "VNF_NAME"; - - private MonitorVnfmNodeTask objUnderTest; - - @Mock - private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider; - - private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution(); - - @Before - public void setUp() { - objUnderTest = getEtsiVnfMonitorNodeJobTask(); - } - - @Test - public void testGetNodeStatusCreate() throws Exception { - GenericVnf vnf = getGenericVnf(); - vnf.setOrchestrationStatus(VNF_CREATED); - when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf); - objUnderTest.getNodeStatus(stubbedxecution); - assertTrue(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS)); - } - - @Test - public void testGetNodeStatusDelete() throws Exception { - GenericVnf vnf = getGenericVnf(); - vnf.setOrchestrationStatus(VNF_ASSIGNED); - when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf); - objUnderTest.getNodeStatus(stubbedxecution); - assertTrue(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS)); - } - - @Test - public void testGetNodeStatusException() throws Exception { - when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class); - objUnderTest.getNodeStatus(stubbedxecution); - assertNull(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS)); - assertNull(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS)); - verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1220), - any(Exception.class)); - } - - @Test - public void testTimeOutLogFailue() throws Exception { - objUnderTest.timeOutLogFailue(stubbedxecution); - verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1221), - eq("Node operation time out")); - } - - private GenericVnf getGenericVnf() { - final GenericVnf genericVnf = new GenericVnf(); - genericVnf.setVnfId(VNF_ID); - genericVnf.setVnfName(VNF_NAME); - return genericVnf; - } - - private MonitorVnfmNodeTask getEtsiVnfMonitorNodeJobTask() { - return new MonitorVnfmNodeTask(extractPojosForBB, exceptionUtil); - } - -} -- cgit 1.2.3-korg From 6f0f3ab69de1013f6d3e5951223e014f2b3daa48 Mon Sep 17 00:00:00 2001 From: "marios.iakovidis" Date: Mon, 3 Jun 2019 00:31:21 +0300 Subject: Added orchestration status to service Issue-ID: SO-1938 Signed-off-by: MariosIakovidis Change-Id: I78cc401a746ef4dbca41a869729b9791210038f4 --- .../scripts/CreateCustomE2EServiceInstance.groovy | 43 +++++++ .../scripts/CreateSDNCNetworkResource.groovy | 5 +- .../scripts/DoCreateResources.groovy | 5 + .../process/CreateCustomE2EServiceInstance.bpmn | 35 +++-- .../subprocess/DoCreateE2EServiceInstance.bpmn | 141 +++++++++++---------- 5 files changed, 147 insertions(+), 82 deletions(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy index bd465eb9a8..a771741e18 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy @@ -23,6 +23,13 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.VnfResource +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.logger.ErrorCode; import static org.apache.commons.lang3.StringUtils.* @@ -332,5 +339,41 @@ public class CreateCustomE2EServiceInstance extends AbstractServiceTaskProcessor } logger.trace("finished prepareInitServiceOperationStatus") } + + public void updateAAIOrchStatus (DelegateExecution execution){ + logger.debug(" ***** start updateAAIOrchStatus ***** ") + String msg = "" + String serviceInstanceId = execution.getVariable("serviceInstanceId") + logger.debug("serviceInstanceId: "+serviceInstanceId) + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + + try { + ServiceInstance si = execution.getVariable("serviceInstanceData") + boolean allActive = true + for (VnfResource resource : serviceDecomposition.vnfResources) { + logger.debug("resource.modelInfo.getModelName: " + resource.modelInfo.getModelName() +" | resource.getOrchestrationStatus: "+resource.getOrchestrationStatus()) + if (resource.getOrchestrationStatus() != "Active") { + allActive = false + } + } + + if (allActive){ + si.setOrchestrationStatus("Active") + }else { + si.setOrchestrationStatus("Pending") + } + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + client.update(uri, si) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in org.onap.so.bpmn.common.scripts.CompleteMsoProcess.updateAAIOrchStatus " + ex.getMessage() + logger.info( msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + logger.debug(" ***** end updateAAIOrchStatus ***** ") + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy index b0749ded86..b70797c63b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy @@ -243,12 +243,11 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { String ontsn = jsonUtil.getJsonValue(serInput, "service.parameters.requestInputs.ont_ont_serial_num") - String uResourceInput = jsonUtil.addJsonValue(resourceInput, "requestInputs.c_vlan", cvlan) - uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.s_vlan", svlan) + String uResourceInput = jsonUtil.addJsonValue(resourceInput, "requestInputs.CVLAN", cvlan) + uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.SVLAN", svlan) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.remote_id", remoteId) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.manufacturer", manufacturer) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ONTSN", ontsn) - logger.debug("old resource input:" + resourceInputObj.toString()) resourceInputObj.setResourceParameters(uResourceInput) execution.setVariable(Prefix + "resourceInput", resourceInputObj.toString()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy index 98def612de..b49f00a247 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy @@ -280,5 +280,10 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ public void postConfigRequest(DelegateExecution execution){ //now do noting + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + for (VnfResource resource : serviceDecomposition.vnfResources) { + resource.setOrchestrationStatus("Active") + } + execution.setVariable("serviceDecomposition", serviceDecomposition) } } diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn index 04ff48d4ed..c1b5ef82de 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_0s2spoq @@ -44,6 +44,8 @@ ex.processJavaException(execution) + + SequenceFlow_19eilro SequenceFlow_0klbpxx @@ -74,7 +76,7 @@ csi.prepareCompletionRequest(execution) - SequenceFlow_0je30si + SequenceFlow_0kaz8ac SequenceFlow_0yayvrf @@ -140,7 +142,7 @@ csi.sendSyncResponse(execution) #{execution.getVariable("WorkflowException") == null} - + #{execution.getVariable("WorkflowException") != null} @@ -175,6 +177,14 @@ csi.prepareInitServiceOperationStatus(execution) SequenceFlow_081z8l2 + + + SequenceFlow_0je30si + SequenceFlow_0kaz8ac + import org.onap.so.bpmn.infrastructure.scripts.* +def csi = new CreateCustomE2EServiceInstance() +csi.updateAAIOrchStatus(execution) + @@ -192,9 +202,9 @@ csi.prepareInitServiceOperationStatus(execution) - + - + @@ -204,7 +214,7 @@ csi.prepareInitServiceOperationStatus(execution) - + @@ -246,8 +256,8 @@ csi.prepareInitServiceOperationStatus(execution) - - + + @@ -270,7 +280,7 @@ csi.prepareInitServiceOperationStatus(execution) - + @@ -386,6 +396,13 @@ csi.prepareInitServiceOperationStatus(execution) + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn index eccb9486dd..76dd6facd6 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1qiiycn @@ -7,10 +7,10 @@ SequenceFlow_1qiiycn SequenceFlow_0w9t6tc - import org.onap.so.bpmn.infrastructure.scripts.* def dcsi = new DoCreateE2EServiceInstance() dcsi.preProcessRequest(execution) -]]> + @@ -36,28 +36,28 @@ dcsi.preProcessRequest(execution) SequenceFlow_0tgrn11 SequenceFlow_1lqktwf - import org.onap.so.bpmn.infrastructure.scripts.* def dcsi = new DoCreateE2EServiceInstance() dcsi.preProcessRollback(execution) -]]> + SequenceFlow_0eumzpf SequenceFlow_1xzgv5k - import org.onap.so.bpmn.infrastructure.scripts.* def dcsi = new DoCreateE2EServiceInstance() dcsi.postProcessRollback(execution) -]]> + SequenceFlow_012h7yx SequenceFlow_1tkgqu3 - import org.onap.so.bpmn.infrastructure.scripts.* def ddsi = new DoCreateE2EServiceInstance() -ddsi.createServiceInstance(execution)]]> +ddsi.createServiceInstance(execution) SequenceFlow_0w9t6tc @@ -66,9 +66,9 @@ ddsi.createServiceInstance(execution)]]> SequenceFlow_0xjwb45 SequenceFlow_012h7yx - import org.onap.so.bpmn.infrastructure.scripts.* def dcsi= new DoCreateE2EServiceInstance() -dcsi.processDecomposition(execution)]]> +dcsi.processDecomposition(execution) @@ -85,9 +85,9 @@ dcsi.processDecomposition(execution)]]> SequenceFlow_166w91p SequenceFlow_0qxzgvq - import org.onap.so.bpmn.infrastructure.scripts.* def dcsi= new DoCreateE2EServiceInstance() -dcsi.prepareDecomposeService(execution)]]> +dcsi.prepareDecomposeService(execution) SequenceFlow_166w91p @@ -111,9 +111,9 @@ dcsi.prepareDecomposeService(execution)]]> SequenceFlow_1y9rkfr SequenceFlow_0n7nbx3 - import org.onap.so.bpmn.infrastructure.scripts.* def ddsi = new DoCreateE2EServiceInstance() -ddsi.preInitResourcesOperStatus(execution)]]> +ddsi.preInitResourcesOperStatus(execution) @@ -154,6 +154,7 @@ ddsi.preInitResourcesOperStatus(execution)]]> + SequenceFlow_0b1dsaj SequenceFlow_0sphcy5 @@ -161,16 +162,16 @@ ddsi.preInitResourcesOperStatus(execution)]]> SequenceFlow_022onug SequenceFlow_0b1dsaj - import org.onap.so.bpmn.infrastructure.scripts.* def csi = new DoCreateE2EServiceInstance() -csi.preProcessForAddResource(execution)]]> +csi.preProcessForAddResource(execution) SequenceFlow_0sphcy5 SequenceFlow_18gnns6 - import org.onap.so.bpmn.infrastructure.scripts.* def csi = new DoCreateE2EServiceInstance() -csi.postProcessForAddResource(execution)]]> +csi.postProcessForAddResource(execution) SequenceFlow_18gnns6 @@ -178,16 +179,16 @@ csi.postProcessForAddResource(execution)]]> SequenceFlow_0yuzaen SequenceFlow_1y9rkfr - import org.onap.so.bpmn.infrastructure.scripts.* def dcsi= new DoCreateE2EServiceInstance() -dcsi.doProcessSiteLocation(execution)]]> +dcsi.doProcessSiteLocation(execution) SequenceFlow_0ckto7v SequenceFlow_022onug - import org.onap.so.bpmn.infrastructure.scripts.* def dcsi= new DoCreateE2EServiceInstance() -dcsi.doTPResourcesAllocation(execution)]]> +dcsi.doTPResourcesAllocation(execution) @@ -230,15 +231,15 @@ dcsi.doTPResourcesAllocation(execution)]]> - - + + - - + + @@ -250,8 +251,8 @@ dcsi.doTPResourcesAllocation(execution)]]> - - + + @@ -260,10 +261,10 @@ dcsi.doTPResourcesAllocation(execution)]]> - - - - + + + + @@ -290,29 +291,29 @@ dcsi.doTPResourcesAllocation(execution)]]> - - + + - - + + - - + + - - + + @@ -324,19 +325,19 @@ dcsi.doTPResourcesAllocation(execution)]]> - - - - + + + + - - - - + + + + @@ -348,10 +349,10 @@ dcsi.doTPResourcesAllocation(execution)]]> - - - - + + + + @@ -384,61 +385,61 @@ dcsi.doTPResourcesAllocation(execution)]]> - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - \ No newline at end of file + -- cgit 1.2.3-korg From d6d76e63c5eeaf1090efa4f28f5a8e3d6beb3781 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Mon, 3 Jun 2019 09:58:07 -0400 Subject: Fix ConfigAssignVnfBB and ConfigDeployVnfBB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: If5a175ee26e279cf71e38c996a75fa627e5e2c00 Issue-ID: SO-1981 Signed-off-by: Alexis de Talhouët --- .../main/resources/db/migration/R__MacroData.sql | 5 ++++ .../BuildingBlock/ConfigAssignVnfBB.bpmn | 30 +++++++++++----------- .../flowspecific/tasks/ConfigAssignVnf.java | 10 +++++--- 3 files changed, 27 insertions(+), 18 deletions(-) (limited to 'bpmn') diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql index 2183d3b6d3..3d19b3a471 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql @@ -806,3 +806,8 @@ VALUES ('VnfInPlaceSoftwareUpdate', 'NO_VALIDATE', 'CUSTOM'); UPDATE northbound_request_ref_lookup SET SERVICE_TYPE = '*' WHERE SERVICE_TYPE = NULL; + +INSERT INTO building_block_detail(BUILDING_BLOCK_NAME, RESOURCE_TYPE, TARGET_ACTION) +VALUES +('ConfigAssignVnfBB', 'NO_VALIDATE', 'CUSTOM'), +('ConfigDeployVnfBB', 'NO_VALIDATE', 'CUSTOM'); diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigAssignVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigAssignVnfBB.bpmn index 9892fbdd91..11d77bf97a 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigAssignVnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigAssignVnfBB.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_0gmfit3 @@ -23,7 +23,7 @@ SequenceFlow_1mkhog2 - + SequenceFlow_0gmfit3 SequenceFlow_05qembo @@ -34,7 +34,7 @@ - #{execution.getVariable("CDSStatus").equals("Success")} + SequenceFlow_15gxql1 @@ -49,15 +49,15 @@ - - + + - - + + @@ -66,8 +66,8 @@ - - + + @@ -76,12 +76,12 @@ - - + + - - + + @@ -90,8 +90,8 @@ - - + + diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java index 8a24330093..b2058b25a0 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java @@ -20,6 +20,7 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks; +import java.util.List; import java.util.Map; import java.util.UUID; import org.onap.so.bpmn.common.BuildingBlockExecution; @@ -68,7 +69,8 @@ public class ConfigAssignVnf { ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); - Map userParams = execution.getGeneralBuildingBlock().getRequestContext().getUserParams(); + List> userParams = + execution.getGeneralBuildingBlock().getRequestContext().getRequestParameters().getUserParams(); ConfigAssignPropertiesForVnf configAssignPropertiesForVnf = new ConfigAssignPropertiesForVnf(); configAssignPropertiesForVnf.setServiceInstanceId(serviceInstance.getServiceInstanceId()); @@ -79,8 +81,10 @@ public class ConfigAssignVnf { configAssignPropertiesForVnf.setVnfId(vnf.getVnfId()); configAssignPropertiesForVnf.setVnfName(vnf.getVnfName()); - for (Map.Entry entry : userParams.entrySet()) { - configAssignPropertiesForVnf.setUserParam(entry.getKey(), entry.getValue()); + for (Map params : userParams) { + for (Map.Entry entry : params.entrySet()) { + configAssignPropertiesForVnf.setUserParam(entry.getKey(), entry.getValue()); + } } ConfigAssignRequestVnf configAssignRequestVnf = new ConfigAssignRequestVnf(); -- cgit 1.2.3-korg From b802b088c9a46ba34ae1cdfe7c70ba8a8a51cbb5 Mon Sep 17 00:00:00 2001 From: "Bonkur, Venkat (vb8416)" Date: Mon, 3 Jun 2019 15:36:31 -0400 Subject: Add SO Turn off OpenStack heat stack audit UPDATE these files so/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml so/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml should have mso: infra: auditInventory: false Issue-ID: SO-1974 Signed-off-by: Bonkur, Venkat (vb8416) Change-Id: I57bb396604e9eb2787122199cdf8a2d1ce54048a --- bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml | 4 ++-- .../mso-api-handler-infra/src/main/resources/application.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'bpmn') diff --git a/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml b/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml index a91cb9d88d..e364981a66 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml +++ b/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml @@ -4,7 +4,7 @@ server: max-threads: 50 mso: infra: - auditInventory: true + auditInventory: false spring: datasource: driver-class-name: org.mariadb.jdbc.Driver @@ -36,4 +36,4 @@ management: export: prometheus: enabled: true # Whether exporting of metrics to Prometheus is enabled. - step: 1m # Step size (i.e. reporting frequency) to use. \ No newline at end of file + step: 1m # Step size (i.e. reporting frequency) to use. diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml index e709758223..03934edf20 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml +++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml @@ -7,7 +7,7 @@ server: mso: infra: - auditInventory: true + auditInventory: false default: versions: apiMinorVersion: 0 @@ -70,4 +70,4 @@ org: so: adapters: network: - encryptionKey: aa3871669d893c7fb8abbcda31b88b4f \ No newline at end of file + encryptionKey: aa3871669d893c7fb8abbcda31b88b4f -- cgit 1.2.3-korg From b50847def6ec0a4912f06e7b57b3b316bd2f8e02 Mon Sep 17 00:00:00 2001 From: sunilb Date: Wed, 5 Jun 2019 05:00:15 +0530 Subject: Fix ConfigAssign/Deploy null return of BlueprintName/Version Fix ConfigAssign/Deploy null return of BlueprintName/Version Issue-ID: SO-1985 Signed-off-by: sunilb Change-Id: I15b6d38a21320eae6ca58a1e3d515813b9c243fd --- .../modelinfo/ModelInfoGenericVnf.java | 19 +++++++++++++++ .../ModelInfoGenericVnfExpected.json | 4 +++- .../VnfResourceCustomizationInput.json | 2 ++ .../flowspecific/tasks/ConfigAssignVnf.java | 5 ++-- .../flowspecific/tasks/ConfigDeployVnf.java | 6 +++-- .../workflow/tasks/WorkflowActionBBTasks.java | 5 ++-- .../workflow/tasks/WorkflowActionBBTasksTest.java | 28 ++++++++++++---------- 7 files changed, 49 insertions(+), 20 deletions(-) (limited to 'bpmn') diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoGenericVnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoGenericVnf.java index 14327a3583..a558057979 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoGenericVnf.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoGenericVnf.java @@ -55,7 +55,26 @@ public class ModelInfoGenericVnf extends ModelInfoMetadata implements Serializab private String MultiStageDesign; @JsonProperty("created") private String Created; + @JsonProperty("blueprintName") + private String blueprintName; + @JsonProperty("blueprintVersion") + private String blueprintVersion; + public String getBlueprintName() { + return blueprintName; + } + + public void setBlueprintName(String blueprintName) { + this.blueprintName = blueprintName; + } + + public String getBlueprintVersion() { + return blueprintVersion; + } + + public void setBlueprintVersion(String blueprintVersion) { + this.blueprintVersion = blueprintVersion; + } public String getToscaNodeType() { return ToscaNodeType; diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ModelInfoGenericVnfExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ModelInfoGenericVnfExpected.json index 98f966e753..9703b9c105 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ModelInfoGenericVnfExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ModelInfoGenericVnfExpected.json @@ -17,5 +17,7 @@ "model-version" : "modelVersion", "model-invariant-uuid" : "modelInvariantUUID", "model-name" : "modelName", - "model-uuid" : "modelUUID" + "model-uuid" : "modelUUID", + "blueprintName" : "testBlueprintName", + "blueprintVersion" : "testBlueprintVersion" } \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/VnfResourceCustomizationInput.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/VnfResourceCustomizationInput.json index 26516ce907..95b116cec8 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/VnfResourceCustomizationInput.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/VnfResourceCustomizationInput.json @@ -9,6 +9,8 @@ "nfRole" : "nfRole", "nfNamingCode" : "nfNamingCode", "multiStageDesign" : "multiStageDesign", + "blueprintName" : "testBlueprintName", + "blueprintVersion" : "testBlueprintVersion", "vnfResources" : { "modelUUID" : "modelUUID", "modelInvariantUUID" : "modelInvariantUUID", diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java index b2058b25a0..bc71fc6f67 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java @@ -91,8 +91,9 @@ public class ConfigAssignVnf { configAssignRequestVnf.setResolutionKey(vnf.getVnfName()); configAssignRequestVnf.setConfigAssignPropertiesForVnf(configAssignPropertiesForVnf); - String blueprintName = vnf.getBlueprintName(); - String blueprintVersion = vnf.getBlueprintVersion(); + String blueprintName = vnf.getModelInfoGenericVnf().getBlueprintName(); + String blueprintVersion = vnf.getModelInfoGenericVnf().getBlueprintVersion(); + logger.debug(" BlueprintName : " + blueprintName + " BlueprintVersion : " + blueprintVersion); AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean(); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java index 359f19285f..6e7ca5f4e5 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java @@ -92,8 +92,10 @@ public class ConfigDeployVnf { configDeployRequestVnf.setResolutionKey(vnf.getVnfName()); configDeployRequestVnf.setConfigDeployPropertiesForVnf(configDeployPropertiesForVnf); - String blueprintName = vnf.getBlueprintName(); - String blueprintVersion = vnf.getBlueprintVersion(); + String blueprintName = vnf.getModelInfoGenericVnf().getBlueprintName(); + String blueprintVersion = vnf.getModelInfoGenericVnf().getBlueprintVersion(); + logger.debug(" BlueprintName : " + blueprintName + " BlueprintVersion : " + blueprintVersion); + AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean(); abstractCDSPropertiesBean.setBlueprintName(blueprintName); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index f0a102dfeb..8ec283032f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -87,11 +87,10 @@ public class WorkflowActionBBTasks { if (ebb.getBuildingBlock().getBpmnFlowName().equals("ConfigAssignVnfBB") || ebb.getBuildingBlock().getBpmnFlowName().equals("ConfigDeployVnfBB")) { - String serviceInstanceId = ebb.getWorkflowResourceIds().getServiceInstanceId(); String vnfCustomizationUUID = ebb.getBuildingBlock().getKey(); - List vnfResourceCustomizations = - catalogDbClient.getVnfResourceCustomizationByModelUuid(serviceInstanceId); + List vnfResourceCustomizations = catalogDbClient + .getVnfResourceCustomizationByModelUuid(ebb.getRequestDetails().getModelInfo().getModelUuid()); if (vnfResourceCustomizations != null && vnfResourceCustomizations.size() >= 1) { VnfResourceCustomization vrc = catalogDbClient.findVnfResourceCustomizationInList(vnfCustomizationUUID, vnfResourceCustomizations); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index a60927d694..1013cc8330 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -48,6 +48,8 @@ import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.RequestDetails; import org.springframework.core.env.Environment; public class WorkflowActionBBTasksTest extends BaseTaskTest { @@ -95,14 +97,16 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { ExecuteBuildingBlock ebb = new ExecuteBuildingBlock(); String vnfCustomizationUUID = "1234567"; - String serviceInstanceId = "1234567"; + String modelUuid = "1234567"; BuildingBlock buildingBlock = new BuildingBlock(); buildingBlock.setBpmnFlowName("ConfigAssignVnfBB"); buildingBlock.setKey(vnfCustomizationUUID); ebb.setBuildingBlock(buildingBlock); - WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); - workflowResourceIds.setServiceInstanceId(serviceInstanceId); - ebb.setWorkflowResourceIds(workflowResourceIds); + RequestDetails rd = new RequestDetails(); + ModelInfo mi = new ModelInfo(); + mi.setModelUuid(modelUuid); + rd.setModelInfo(mi); + ebb.setRequestDetails(rd); flowsToExecute.add(ebb); List vnfResourceCustomizations = new ArrayList(); @@ -112,8 +116,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { vnfResourceCustomizations.add(vrc); GenericVnf genericVnf = new GenericVnf(); genericVnf.setModelCustomizationId(vnfCustomizationUUID); - doReturn(vnfResourceCustomizations).when(catalogDbClient) - .getVnfResourceCustomizationByModelUuid(serviceInstanceId); + doReturn(vnfResourceCustomizations).when(catalogDbClient).getVnfResourceCustomizationByModelUuid(modelUuid); doReturn(vrc).when(catalogDbClient).findVnfResourceCustomizationInList(vnfCustomizationUUID, vnfResourceCustomizations); @@ -138,14 +141,16 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); String vnfCustomizationUUID = "1234567"; - String serviceInstanceId = "1234567"; + String modelUuid = "1234567"; BuildingBlock buildingBlock = new BuildingBlock(); buildingBlock.setBpmnFlowName("ConfigDeployVnfBB"); buildingBlock.setKey(vnfCustomizationUUID); ebb.setBuildingBlock(buildingBlock); - WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); - workflowResourceIds.setServiceInstanceId(serviceInstanceId); - ebb.setWorkflowResourceIds(workflowResourceIds); + RequestDetails rd = new RequestDetails(); + ModelInfo mi = new ModelInfo(); + mi.setModelUuid(modelUuid); + rd.setModelInfo(mi); + ebb.setRequestDetails(rd); flowsToExecute.add(ebb); List vnfResourceCustomizations = new ArrayList(); @@ -155,8 +160,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { vnfResourceCustomizations.add(vrc); GenericVnf genericVnf = new GenericVnf(); genericVnf.setModelCustomizationId(vnfCustomizationUUID); - doReturn(vnfResourceCustomizations).when(catalogDbClient) - .getVnfResourceCustomizationByModelUuid(serviceInstanceId); + doReturn(vnfResourceCustomizations).when(catalogDbClient).getVnfResourceCustomizationByModelUuid(modelUuid); doReturn(vrc).when(catalogDbClient).findVnfResourceCustomizationInList(vnfCustomizationUUID, vnfResourceCustomizations); -- cgit 1.2.3-korg From ce75c2660be79e0ec72669b4dd5e62172d89c028 Mon Sep 17 00:00:00 2001 From: "Bonkur, Venkat (vb8416)" Date: Tue, 4 Jun 2019 22:46:14 -0400 Subject: Add SO exclude ConfigurationScaleOutBB Updated the WorkflowAction.isConfiguration() to exclude ConfigurationScaleOutBB problem- VF module check failure during scale out Issue-ID: SO-1982 Signed-off-by: Bonkur, Venkat (vb8416) Change-Id: I5caa6f1c5ff21131ea1c42a63b441a39f77a6e62 --- .../org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 2fc301f9d7..70726f2014 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -415,7 +415,7 @@ public class WorkflowAction { protected boolean isConfiguration(List orchFlows) { for (OrchestrationFlow flow : orchFlows) { - if (flow.getFlowName().contains("Configuration")) { + if (flow.getFlowName().contains("Configuration") && !flow.getFlowName().equals("ConfigurationScaleOutBB")) { return true; } } -- cgit 1.2.3-korg