From 9278ff592ce215dd49c8a2b090f28678c695b841 Mon Sep 17 00:00:00 2001 From: c00149107 Date: Thu, 22 Feb 2018 09:46:14 +0800 Subject: Support more Generic workflow for voLTE Support more Generic workflow for voLTE Change-Id: I0005fffdb420709b597739173fa894981ac9c74e Issue-ID: SO-438 Signed-off-by: c00149107 --- .../scripts/DoCreateE2EServiceInstance.groovy | 108 +++++++++++++++++++-- .../DoCustomDeleteE2EServiceInstance.groovy | 68 +++++++++++++ .../process/CreateCustomE2EServiceInstance.bpmn | 2 +- .../process/DeleteCustomE2EServiceInstance.bpmn | 2 +- 4 files changed, 168 insertions(+), 12 deletions(-) (limited to 'bpmn') diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy index d15be38042..ef2388fe44 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy @@ -32,17 +32,20 @@ import org.openecomp.mso.bpmn.common.scripts.AaiUtil import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils +import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils; import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.rest.APIResponse; import org.openecomp.mso.rest.RESTClient import org.openecomp.mso.rest.RESTConfig +import java.util.List; import java.util.UUID; import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.runtime.Execution import org.json.JSONObject; +import org.json.JSONArray; import org.apache.commons.lang3.* import org.apache.commons.codec.binary.Base64; import org.springframework.web.util.UriUtils; @@ -77,6 +80,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { String Prefix="DCRESI_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() + CatalogDbUtils cutils = new CatalogDbUtils() public void preProcessRequest (Execution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") @@ -402,7 +406,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { String serviceInstanceName = execution.getVariable("serviceInstanceName") String nsServiceName = resourceType + "_" + serviceInstanceName execution.setVariable("nsServiceName", nsServiceName) - utils.log("INFO", "Prepare VFC Request nsServiceName:" + nsServiceName, isDebugEnabled) + utils.log("INFO", "Prepare Resource Request nsServiceName:" + nsServiceName, isDebugEnabled) String globalSubscriberId = execution.getVariable("globalSubscriberId") String serviceType = execution.getVariable("serviceType") String serviceId = execution.getVariable("serviceInstanceId") @@ -412,7 +416,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { String resourcesStr = jsonUtil.getJsonValue(incomingRequest, "service.parameters.resources") String nsServiceDescription = jsonUtil.getJsonValue(incomingRequest, "service.description") execution.setVariable("nsServiceDescription", nsServiceDescription) - utils.log("INFO", "Prepare VFC Request nsServiceDescription:" + nsServiceDescription, isDebugEnabled) + utils.log("INFO", "Prepare Resource Request nsServiceDescription:" + nsServiceDescription, isDebugEnabled) List resourceList = jsonUtil.StringArrayToList(execution, resourcesStr) //reset the variables execution.setVariable("resourceUUID", "") @@ -427,18 +431,102 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { execution.setVariable("resourceUUID", resourceUUID) execution.setVariable("resourceInvariantUUID", resourceInvariantUUID) execution.setVariable("resourceParameters", resourceParameters) - utils.log("INFO", "Prepare VFC Request resourceType:" + resourceType, isDebugEnabled) - utils.log("INFO", "Prepare VFC Request resourceUUID:" + resourceUUID, isDebugEnabled) - utils.log("INFO", "Prepare VFC Request resourceParameters:" + resourceParameters, isDebugEnabled) + utils.log("INFO", "Prepare Resource Request resourceType:" + resourceType, isDebugEnabled) + utils.log("INFO", "Prepare Resource Request resourceUUID:" + resourceUUID, isDebugEnabled) + utils.log("INFO", "Prepare Resource Request resourceParameters:" + resourceParameters, isDebugEnabled) } } - utils.log("INFO", "Prepare VFC Request finished", isDebugEnabled) + utils.log("INFO", "Prepare Controller Request finished", isDebugEnabled) + } + /** + * sequence resource. we should analyze resource sequence from service template + * Here we make VF first, and then network for E2E service. + */ + public void sequenceResoure(execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", "======== Start sequenceResoure Process ======== ", isDebugEnabled) + String serviceModelUUID = execution.getVariable("modelUuid") + JSONArray networks = cutils.getAllNetworksByServiceModelUuid(execution, serviceModelUUID) + utils.log("DEBUG", "obtained Network list: " + networks, isDebugEnabled) + if (networks == null) { + utils.log("INFO", "No matching networks in Catalog DB for serviceModelUUID=" + serviceModelUUID, isDebugEnabled) + } + String incomingRequest = execution.getVariable("uuiRequest") + String resourcesStr = jsonUtil.getJsonValue(incomingRequest, "service.parameters.resources") + List resourceList = jsonUtil.StringArrayToList(execution, resourcesStr) + // Only one match herenetwork + List nsResources = new ArrayList() + List wanResources = new ArrayList() + List resourceSequence = new ArrayList() + for(String resource : resourceList){ + String resourceName = jsonUtil.getJsonValue(resource, "resourceName") + String resourceUUID = jsonUtil.getJsonValue(resource, "resourceId") + //check is network. + boolean isNetwork = false; + if(networks != null){ + for(int i = 0; i < networks.size(); i++){ + String networkUUID = jsonUtil.getJsonValueForKey(networks.get(i), "modelVersionId") + if(StringUtils.equals(resourceUUID, networkUUID)){ + isNetwork = true + break + } + } + } + if(isNetwork){ + wanResources.add(resourceName) + }else{ + nsResources.add(resourceName) + } + } + resourceSequence.addAll(nsResources) + resourceSequence.addAll(wanResources) + String isContainsWanResource = wanResources.isEmpty() ? "false" : "true" + execution.setVariable("isContainsWanResource", isContainsWanResource) + execution.setVariable("currentResourceIndex", 0) + execution.setVariable("resourceSequence", resourceSequence) + utils.log("INFO", "resourceSequence: " + resourceSequence, isDebugEnabled) + execution.setVariable("wanResources", wanResources) + utils.log("INFO", "======== COMPLETED sequenceResoure Process ======== ", isDebugEnabled) } + public void getCurrentResoure(execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", "======== Start getCurrentResoure Process ======== ", isDebugEnabled) + def currentIndex = execution.getVariable("currentResourceIndex") + List resourceSequence = execution.getVariable("resourceSequence") + List wanResources = execution.getVariable("wanResources") + String resourceName = resourceSequence.get(currentIndex) + execution.setVariable("resourceType",resourceName) + if(wanResources.contains(resourceName)){ + execution.setVariable("controllerInfo", "SDN-C") + }else{ + execution.setVariable("controllerInfo", "VF-C") + } + utils.log("INFO", "======== COMPLETED getCurrentResoure Process ======== ", isDebugEnabled) + } + /** - * post config request. + * sequence resource */ - public void postConfigRequest(execution){ - //now do noting - } + public void parseNextResource(execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", "======== Start parseNextResource Process ======== ", isDebugEnabled) + def currentIndex = execution.getVariable("currentResourceIndex") + def nextIndex = currentIndex + 1 + execution.setVariable("currentResourceIndex", nextIndex) + List resourceSequence = execution.getVariable("resourceSequence") + if(nextIndex >= resourceSequence.size()){ + execution.setVariable("allResourceFinished", "true") + }else{ + execution.setVariable("allResourceFinished", "false") + } + utils.log("INFO", "======== COMPLETED parseNextResource Process ======== ", isDebugEnabled) + } + + /** + * post config request. + */ + public void postConfigRequest(execution){ + //now do noting + } } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy index ecc1488cbc..bf61013c76 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy @@ -35,6 +35,7 @@ import org.openecomp.mso.rest.APIResponse; import org.openecomp.mso.rest.RESTClient import org.openecomp.mso.rest.RESTConfig +import java.util.List; import java.util.UUID; import javax.xml.parsers.DocumentBuilder import javax.xml.parsers.DocumentBuilderFactory @@ -589,5 +590,72 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess } utils.log("INFO", " ======== END preResourceDelete Process ======== ", isDebugEnabled) } + + public void sequenceResource(execution){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + + utils.log("INFO", " ======== STARTED sequenceResource Process ======== ", isDebugEnabled) + List nsResources = new ArrayList() + List wanResources = new ArrayList() + List resourceSequence = new ArrayList() + + String serviceRelationShip = execution.getVariable("serviceRelationShip") + + + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + List relationShipList = jsonSlurper.parseText(serviceRelationShip) + + if (relationShipList != null) { + relationShipList.each { + if(StringUtils.containsIgnoreCase(it.resourceType, "overlay") || StringUtils.containsIgnoreCase(it.resourceType, "underlay")){ + wanResources.add(it.resourceType) + }else{ + nsResources.add(it.resourceType) + } + } + } + resourceSequence.addAll(wanResources) + resourceSequence.addAll(nsResources) + String isContainsWanResource = wanResources.isEmpty() ? "false" : "true" + execution.setVariable("isContainsWanResource", isContainsWanResource) + execution.setVariable("currentResourceIndex", 0) + execution.setVariable("resourceSequence", resourceSequence) + utils.log("INFO", "resourceSequence: " + resourceSequence, isDebugEnabled) + execution.setVariable("wanResources", wanResources) + utils.log("INFO", " ======== END sequenceResource Process ======== ", isDebugEnabled) + } + + public void getCurrentResource(execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", "======== Start getCurrentResoure Process ======== ", isDebugEnabled) + def currentIndex = execution.getVariable("currentResourceIndex") + List resourceSequence = execution.getVariable("resourceSequence") + List wanResources = execution.getVariable("wanResources") + String resourceName = resourceSequence.get(currentIndex) + execution.setVariable("resourceType",resourceName) + if(wanResources.contains(resourceName)){ + execution.setVariable("controllerInfo", "SDN-C") + }else{ + execution.setVariable("controllerInfo", "VF-C") + } + utils.log("INFO", "======== COMPLETED getCurrentResoure Process ======== ", isDebugEnabled) + } + + public void parseNextResource(execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", "======== Start parseNextResource Process ======== ", isDebugEnabled) + def currentIndex = execution.getVariable("currentResourceIndex") + def nextIndex = currentIndex + 1 + execution.setVariable("currentResourceIndex", nextIndex) + List resourceSequence = execution.getVariable("resourceSequence") + if(nextIndex >= resourceSequence.size()){ + execution.setVariable("allResourceFinished", "true") + }else{ + execution.setVariable("allResourceFinished", "false") + } + utils.log("INFO", "======== COMPLETED parseNextResource Process ======== ", isDebugEnabled) + } + } \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn index 8fc761c0d3..24d5a7b3ad 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn @@ -22,7 +22,7 @@ ex.processJavaException(execution)]]> - + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn index 2983589699..84c370e7fa 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn @@ -22,7 +22,7 @@ ex.processJavaException(execution)]]> - + -- cgit 1.2.3-korg