* ============LICENSE_END=========================================================
*/
-package com.att.bpm.scripts;
+package org.openecomp.mso.bpmn.common.scripts;
import org.apache.commons.lang3.*
import groovy.xml.XmlUtil
+
import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
import javax.xml.transform.Transformer
import org.w3c.dom.Node
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource
-import org.apache.commons.lang3.*
+
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.runtime.Execution
+import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor;
import org.w3c.dom.Document
import org.w3c.dom.Element
-
import org.w3c.dom.NamedNodeMap
import org.w3c.dom.Node
import org.w3c.dom.NodeList;
this.taskProcessor = taskProcessor
}
-
/**
* This method returns the string for Network request
* V2 for Contrail 3.x will populate cloud-region data in same cloudSiteId filed
* Network adapter will handle it properly
- * @param requestId either 'request-id' or 'att-mso-request-id'
+ * @param requestId either 'request-id' or 'openecomp-mso-request-id'
* @param requestInput the request in the process
* @param queryIdResponse the response of REST AAI query by Id
* @param routeCollection the collection
// requestInput
String cloudRegion = cloudRegionId
String tenantId = utils.getNodeText1(requestInput, "tenant-id")
-
+ String networkType = ""
+ if (utils.nodeExists(requestInput, "networkModelInfo")) {
+ String networkModelInfo = utils.getNodeXml(requestInput, "networkModelInfo", false).replace("tag0:","").replace(":tag0","")
+ networkType = utils.getNodeText1(networkModelInfo, "modelName")
+ } else {
+ networkType = utils.getNodeText1(queryIdResponse, "network-type")
+ }
+
// queryIdResponse
String networkName = utils.getNodeText1(queryIdResponse, "network-name")
String networkId = utils.getNodeText1(queryIdResponse, "network-id")
- String networkType = utils.getNodeText1(queryIdResponse, "network-type")
-
+ String networkTechnology = utils.getNodeText1(queryIdResponse, "network-technology")
+
+ // contrailNetwork - networkTechnology = 'Contrail' vs. 'AIC_SR_IOV')
+ String contrailNetwork = ""
+ if (networkTechnology.contains('Contrail') || networkTechnology.contains('contrail') || networkTechnology.contains('CONTRAIL')) {
+ contrailNetwork = """<contrailNetwork>
+ <shared>${sharedValue}</shared>
+ <external>${externalValue}</external>
+ ${routeCollection}
+ ${policyFqdns}
+ ${tableCollection}
+ </contrailNetwork>"""
+ networkTechnology = "CONTRAIL" // replace
+ }
+
// rebuild subnets
String subnets = ""
if (utils.nodeExists(queryIdResponse, "subnets")) {
<networkId>${networkId}</networkId>
<networkName>${networkName}</networkName>
<networkType>${networkType}</networkType>
- <networkTechnology>CONTRAIL</networkTechnology>
+ <networkTechnology>${networkTechnology}</networkTechnology>
<providerVlanNetwork>
<physicalNetworkName>${physicalNetworkName}</physicalNetworkName >
${vlansCollection}
</providerVlanNetwork>
- <contrailNetwork>
- <shared>${sharedValue}</shared>
- <external>${externalValue}</external>
- ${routeCollection}
- ${policyFqdns}
- ${tableCollection}
- </contrailNetwork>
+ ${contrailNetwork}
${subnets}
<skipAAI>true</skipAAI>
<backout>${backoutOnFailure}</backout>
* This method returns the string for Network request
* V2 for Contrail 3.x will populate cloud-region data in same cloudSiteId filed
* Network adapter will handle it properly
- * @param requestId either 'request-id' or 'att-mso-request-id'
+ * @param requestId either 'request-id' or 'openecomp-mso-request-id'
* @param requestInput the request in the process
* @param queryIdResponse the response of REST AAI query by Id
* @param routeCollection the collection
def String CreateNetworkVolumeRequest(groupId, volumeName, vnfType, tenantId) {
String requestPayload =
- """<volume-group xmlns="http://org.openecomp.aai.inventory/v6">
+ """<volume-group xmlns="http://org.openecomp.mso/v6">
<volume-group-id>${groupId}</volume-group-id>
<volume-group-name>${volumeName}</volume-group-name>
<heat-stack-id></heat-stack-id>
return requestPayload
}
- def String createCloudRegionVolumeRequest(groupId, volumeName, vnfType, tenantId, cloudRegion, namespace) {
+ def String createCloudRegionVolumeRequest(groupId, volumeName, vnfType, tenantId, cloudRegion, namespace, modelCustomizationId) {
String requestPayload =
"""<volume-group xmlns="${namespace}">
<heat-stack-id></heat-stack-id>
<vnf-type>${vnfType}</vnf-type>
<orchestration-status>Pending</orchestration-status>
+ <vf-module-persona-model-customization-id>${modelCustomizationId}</vf-module-persona-model-customization-id>
<relationship-list>
<relationship>
<related-to>tenant</related-to>
</relationship-data>
<relationship-data>
<relationship-key>cloud-region.cloud-owner</relationship-key>
- <relationship-value>att-aic</relationship-value>
+ <relationship-value>openecomp-aic</relationship-value>
</relationship-data>
<relationship-data>
<relationship-key>cloud-region.cloud-region-id</relationship-key>
return requestPayload
}
- def String createCloudRegionVolumeRequest(groupId, volumeName, vnfType, vnfId, tenantId, cloudRegion, namespace) {
+ def String createCloudRegionVolumeRequest(groupId, volumeName, vnfType, vnfId, tenantId, cloudRegion, namespace, modelCustomizationId) {
String requestPayload =
"""<volume-group xmlns="${namespace}">
<heat-stack-id></heat-stack-id>
<vnf-type>${vnfType}</vnf-type>
<orchestration-status>Pending</orchestration-status>
+ <vf-module-persona-model-customization-id>${modelCustomizationId}</vf-module-persona-model-customization-id>
<relationship-list>
<relationship>
<related-to>generic-vnf</related-to>
</relationship-data>
<relationship-data>
<relationship-key>cloud-region.cloud-owner</relationship-key>
- <relationship-value>att-aic</relationship-value>
+ <relationship-value>openecomp-aic</relationship-value>
</relationship-data>
<relationship-data>
<relationship-key>cloud-region.cloud-region-id</relationship-key>
* @param heatStackId the value of heat stack id
* @return String request payload
*/
- def String updateCloudRegionVolumeRequest(requeryAAIVolGrpNameResponse, heatStackId, namespace) {
+ def String updateCloudRegionVolumeRequest(requeryAAIVolGrpNameResponse, heatStackId, namespace, modelCustomizationId) {
String requestPayload = ""
if (requeryAAIVolGrpNameResponse != null) {
def groupId = utils.getNodeText(requeryAAIVolGrpNameResponse, "volume-group-id")
<vnf-type>${vnfType}</vnf-type>
<orchestration-status>Active</orchestration-status>
<resource-version>${resourceVersion}</resource-version>
+ <vf-module-persona-model-customization-id>${modelCustomizationId}</vf-module-persona-model-customization-id>
${relationshipList}
</volume-group>"""
}
}
requestPayload =
- """<volume-group xmlns="http://org.openecomp.aai.inventory/v6">
+ """<volume-group xmlns="http://org.openecomp.mso/v6">
<volume-group-id>${groupId}</volume-group-id>
<volume-group-name>${volumeName}</volume-group-name>
<heat-stack-id>${heatStackId}</heat-stack-id>
* <relationship-list>
* <relationship>
* <related-to>vpn-binding</related-to>
- * <related-link>https://aai-app-e2e.test.att.com:8443/aai/v6/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/</related-link>
+ * <related-link>https://aai-app-e2e.test.openecomp.com:8443/aai/v6/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/</related-link>
* <relationship-data>
* <relationship-key>vpn-binding.vpn-id</relationship-key>
* <relationship-value>85f015d0-2e32-4c30-96d2-87a1a27f8017</relationship-value>
* </relationship>
* <relationship>
* <related-to>vpn-binding</related-to>
- * <related-link>https://aai-ext1.test.att.com:8443/aai/v6/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/</related-link>
+ * <related-link>https://aai-ext1.test.openecomp.com:8443/aai/v6/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/</related-link>
* <relationship-data>
* <relationship-key>vpn-binding.vpn-id</relationship-key>
* <relationship-value>24a4b507-853a-4a38-99aa-05fcc54be24d</relationship-value>
return rtn
}
+ /**
+ * similar to network policymethod
+ * @param xmlInput the XML document
+ * @return a list of IDs for related VNF instances
+ *
+ **/
+ def getRelatedVnfIdList(xmlInput) {
+ //def rtn = null
+ List rtn = []
+ if (xmlInput!=null) {
+ def relationshipList = getListWithElements(xmlInput, 'relationship')
+ def relationshipListSize = relationshipList.size()
+ if (relationshipListSize > 0) {
+ for (i in 0..relationshipListSize-1) {
+ def relationshipXml = XmlUtil.serialize(relationshipList[i])
+ if (utils.getNodeText(relationshipXml, 'related-to') == "generic-vnf") {
+ def relatedLink = utils.getNodeText1(relationshipXml, 'related-link')
+ if (relatedLink != null || relatedLink != "") {
+ rtn.add(relatedLink.substring(relatedLink.indexOf("/generic-vnf/")+13, relatedLink.length()))
+ }
+ }
+ }
+ }
+ }
+ return rtn
+ }
+
+ /**
+ * similar to network policymethod
+ * @param xmlInput the XML document
+ * @return a list of IDs for related Network instances
+ *
+ **/
+ def getRelatedNetworkIdList(xmlInput) {
+ //def rtn = null
+ List rtn = []
+ if (xmlInput!=null) {
+ def relationshipList = getListWithElements(xmlInput, 'relationship')
+ def relationshipListSize = relationshipList.size()
+ if (relationshipListSize > 0) {
+ for (i in 0..relationshipListSize-1) {
+ def relationshipXml = XmlUtil.serialize(relationshipList[i])
+ if (utils.getNodeText(relationshipXml, 'related-to') == "l3-network") {
+ def relatedLink = utils.getNodeText1(relationshipXml, 'related-link')
+ if (relatedLink != null || relatedLink != "") {
+ rtn.add(relatedLink.substring(relatedLink.indexOf("/l3-network/")+12, relatedLink.length()))
+ }
+ }
+ }
+ }
+ }
+ return rtn
+ }
def isVfRelationshipExist(xmlInput) {
Boolean rtn = false
}
+ def getCloudRegion(xmlInput) {
+ String lcpCloudRegion = ""
+ if (xmlInput!=null) {
+ def relationshipList = getListWithElements(xmlInput, 'relationship')
+ def relationshipListSize = relationshipList.size()
+ if (relationshipListSize > 0) {
+ for (i in 0..relationshipListSize-1) {
+ def relationshipXml = XmlUtil.serialize(relationshipList[i])
+ if (utils.getNodeText(relationshipXml, 'related-to') == "cloud-region") {
+ def relatedLink = utils.getNodeText1(relationshipXml, 'related-link')
+ if (relatedLink != null || relatedLink != "") {
+ lcpCloudRegion = relatedLink.substring(relatedLink.indexOf("/openecomp-aic/")+9, relatedLink.length())
+ if (lcpCloudRegion.contains('/')) {
+ lcpCloudRegion = relatedLink.substring(relatedLink.indexOf("/openecomp-aic/")+9, relatedLink.length()-1)
+ }
+ }
+ }
+ }
+ }
+ }
+ return lcpCloudRegion
+ }
+
+ def getTenantId(xmlInput) {
+ String tenantId = ""
+ if (xmlInput!=null) {
+ def relationshipList = getListWithElements(xmlInput, 'relationship')
+ def relationshipListSize = relationshipList.size()
+ if (relationshipListSize > 0) {
+ for (i in 0..relationshipListSize-1) {
+ def relationshipXml = XmlUtil.serialize(relationshipList[i])
+ if (utils.getNodeText(relationshipXml, 'related-to') == "tenant") {
+ def relatedLink = utils.getNodeText1(relationshipXml, 'related-link')
+ if (relatedLink != null || relatedLink != "") {
+ tenantId = relatedLink.substring(relatedLink.indexOf("/tenant/")+8, relatedLink.length())
+ if (tenantId.contains('/')) {
+ tenantId = relatedLink.substring(relatedLink.indexOf("/tenant/")+8, relatedLink.length()-1)
+ }
+ }
+ }
+ }
+ }
+ }
+ return tenantId
+ }
+
def isInstanceValueMatch(linkResource, globalSubscriberId, serviceType) {
Boolean rtn = false
try {
* Ex 2: xmlInput // no parent tag
* <ws:sdnc-request-header>
* <ws:svc-request-id>fec8ec88-151a-45c9-ad60-8233e0fc8ff2</ws:svc-request-id>
- * <ws:svc-notification-url>https://msojra.mtsnj.aic.cip.att.com:8443/adapters/rest/SDNCNotify</ws:svc-notification-url>
+ * <ws:svc-notification-url>https://msojra.mtsnj.aic.cip.openecomp.com:8443/adapters/rest/SDNCNotify</ws:svc-notification-url>
* <ws:svc-action>assign</ws:svc-action>
* </ws:sdnc-request-header>
* Usage:
//TODO: This method still needs to be tested before using.
/**
+ *
* This method is similar to the gennetwork:ContrailNetworUpdateCompletedObject
* BPEL method. It extracts all of the required subnet information
* for each subnet listed with an orch status equal to the one provided
/**
+ *
* This method extracts the "value" node text for the the given subnet Id.
*
* @param String inputSource - xml that contains the subnet id key and value
public boolean isRollbackEnabled (Execution execution, String payloadXml) {
- boolean rollbackEnabled = false
- boolean rollbackValueSet = false
+ def rollbackEnabled = false
+ def rollbackValueSet = false
if (utils.nodeExists(payloadXml, "backout-on-failure")) {
String backoutValue = utils.getNodeText1(payloadXml, "backout-on-failure")
if (backoutValue != null && !backoutValue.isEmpty()) {
}
if (!rollbackValueSet) {
- rollbackEnabled = execution.getVariable("URN_mso_rollback")
+ if (execution.getVariable("URN_mso_rollback") != null) {
+ rollbackEnabled = execution.getVariable("URN_mso_rollback").toBoolean()
+ }
}
return rollbackEnabled
}