X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=bpmn%2FMSOInfrastructureBPMN%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fopenecomp%2Fmso%2Fbpmn%2Finfrastructure%2Fscripts%2FDoCreateE2EServiceInstance.groovy;h=f8706cc2f07b14b9ed60b25c0d64733a20c525a3;hb=refs%2Fchanges%2F25%2F35725%2F1;hp=cfdc0e9bfa2e09e70d1a484382dbe02cb7854d75;hpb=233b1d9e9164b1005ef2d476fe0e156535e2379d;p=so.git 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 cfdc0e9bfa..f8706cc2f0 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 @@ -27,6 +27,13 @@ import groovy.json.* import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition import org.openecomp.mso.bpmn.core.domain.ServiceInstance import org.openecomp.mso.bpmn.core.domain.ModelInfo +import org.openecomp.mso.bpmn.core.domain.Resource +import org.openecomp.mso.bpmn.core.domain.AllottedResource +import org.openecomp.mso.bpmn.core.domain.NetworkResource +import org.openecomp.mso.bpmn.core.domain.VnfResource +import org.openecomp.mso.bpmn.common.recipe.ResourceInput +import org.openecomp.mso.bpmn.common.resource.ResourceRequestBuilder; +import org.openecomp.mso.bpmn.common.recipe.BpmnRestClient import org.openecomp.mso.bpmn.core.json.JsonUtils import org.openecomp.mso.bpmn.common.scripts.AaiUtil import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor @@ -42,6 +49,8 @@ import org.openecomp.mso.rest.RESTConfig import java.util.List; import java.util.UUID; +import javax.mail.Quota.Resource; + import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.runtime.Execution import org.json.JSONObject; @@ -225,7 +234,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { try { String serviceInstanceName = execution.getVariable("serviceInstanceName") boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") - if(succInAAI != true){ + if(!succInAAI){ utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceName, isDebugEnabled) WorkflowException workflowException = execution.getVariable("WorkflowException") utils.logAudit("workflowException: " + workflowException) @@ -242,7 +251,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { else { boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") - if(foundInAAI == true){ + if(foundInAAI){ utils.log("INFO","Found Service-instance in AAI", isDebugEnabled) msg = "ServiceInstance already exists in AAI:" + serviceInstanceName utils.log("INFO", msg, isDebugEnabled) @@ -266,7 +275,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { try { String serviceInstanceId = execution.getVariable("serviceInstanceId") boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator") - if(succInAAI != true){ + if(!succInAAI){ utils.log("INFO","Error putting Service-instance in AAI", + serviceInstanceId, isDebugEnabled) WorkflowException workflowException = execution.getVariable("WorkflowException") utils.logAudit("workflowException: " + workflowException) @@ -305,7 +314,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { try { String serviceInstanceName = execution.getVariable("serviceInstanceName") boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") - if(succInAAI != true){ + if(!succInAAI){ utils.log("INFO","Error getting Service-instance from AAI in postProcessAAIGET2", + serviceInstanceName, isDebugEnabled) WorkflowException workflowException = execution.getVariable("WorkflowException") utils.logAudit("workflowException: " + workflowException) @@ -322,7 +331,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { else { boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") - if(foundInAAI == true){ + if(foundInAAI){ String aaiService = execution.getVariable("GENGS_service") if (!isBlank(aaiService) && (utils.nodeExists(aaiService, "service-instance-name"))) { execution.setVariable("serviceInstanceName", utils.getNodeText1(aaiService, "service-instance-name")) @@ -400,11 +409,11 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { execution.setVariable("serviceInstanceId", serviceId) execution.setVariable("operationId", operationId) execution.setVariable("operationType", operationType) - String incomingRequest = execution.getVariable("uuiRequest") - String resourcesStr = jsonUtil.getJsonValue(incomingRequest, "service.parameters.resources") - List resourceList = jsonUtil.StringArrayToList(execution, resourcesStr) + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + List resourceList = serviceDecomposition.getServiceResources() + for(String resource : resourceList){ - resourceTemplateUUIDs = resourceTemplateUUIDs + jsonUtil.getJsonValue(resource, "resourceId") + ":" + resourceTemplateUUIDs = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":" } def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter" @@ -491,41 +500,34 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { 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) - } + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + + //we use VF to define a network service + List vnfResourceList= serviceDecomposition.getServiceVnfs() + + //here wan is defined as a network resource + List networkResourceList = serviceDecomposition.getServiceNetworks() + + //allotted resource + List arResourceList= serviceDecomposition.getServiceAllottedResources() + //define sequenced resource list, we deploy vf first and then network and then ar + //this is defaule sequence + List sequencedResourceList = new ArrayList(); + if(null != vnfResourceList){ + sequencedResourceList.addAll(vnfResourceList) + } + if(null != networkResourceList){ + sequencedResourceList.addAll(networkResourceList) } - resourceSequence.addAll(nsResources) - resourceSequence.addAll(wanResources) - String isContainsWanResource = wanResources.isEmpty() ? "false" : "true" + if(null != arResourceList){ + sequencedResourceList.addAll(arResourceList) + } + + String isContainsWanResource = networkResourceList.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) + execution.setVariable("sequencedResourceList", sequencedResourceList) + utils.log("INFO", "sequencedResourceList: " + sequencedResourceList, isDebugEnabled) utils.log("INFO", "======== COMPLETED sequenceResoure Process ======== ", isDebugEnabled) } @@ -533,15 +535,9 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { 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") - } + List sequencedResourceList = execution.getVariable("sequencedResourceList") + Resource currentResource = sequencedResourceList.get(currentIndex) + utils.log("INFO", "Now we deal with resouce:" + currentResource.getModelInfo().getModelName(), isDebugEnabled) utils.log("INFO", "======== COMPLETED getCurrentResoure Process ======== ", isDebugEnabled) } @@ -554,8 +550,8 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { def currentIndex = execution.getVariable("currentResourceIndex") def nextIndex = currentIndex + 1 execution.setVariable("currentResourceIndex", nextIndex) - List resourceSequence = execution.getVariable("resourceSequence") - if(nextIndex >= resourceSequence.size()){ + List sequencedResourceList = execution.getVariable("sequencedResourceList") + if(nextIndex >= sequencedResourceList.size()){ execution.setVariable("allResourceFinished", "true") }else{ execution.setVariable("allResourceFinished", "false") @@ -569,4 +565,42 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { public void postConfigRequest(execution){ //now do noting } + + public void prepareResourceRecipeRequest(execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", "======== Start prepareResourceRecipeRequest Process ======== ", isDebugEnabled) + ResourceInput resourceInput = new ResourceInput() + String serviceInstanceName = execution.getVariable("serviceInstanceName") + String resourceInstanceName = resourceType + "_" + serviceInstanceName + resourceInput.setResourceInstanceName(resourceInstanceName) + utils.log("INFO", "Prepare Resource Request resourceInstanceName:" + resourceInstanceName, isDebugEnabled) + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String operationType = execution.getVariable("operationType") + resourceInput.setGlobalSubscriberId(globalSubscriberId) + resourceInput.setServiceType(serviceType) + resourceInput.setServiceInstanceId(serviceInstanceId) + resourceInput.setOperationId(operationId) + resourceInput.setOperationType(operationType); + def currentIndex = execution.getVariable("currentResourceIndex") + List sequencedResourceList = execution.getVariable("sequencedResourceList") + Resource currentResource = sequencedResourceList.get(currentIndex) + String resourceCustomizationUuid = currentResource.getModelInfo().getModelCustomizationUuid() + resourceInput.setResourceCustomizationUuid(resourceCustomizationUuid); + String resourceInvariantUuid = currentResource.getModelInfo().getModelInvariantUuid() + resourceInput.setResourceInvariantUuid(resourceInvariantUuid) + String resourceUuid = currentResource.getModelInfo().getModelUuid() + resourceInput.setResourceUuid(resourceUuid) + + String incomingRequest = execution.getVariable("uuiRequest") + //set the requestInputs from tempalte To Be Done + String serviceModelUuid = execution.getVariable("modelUuid") + String serviceParameters = jsonUtil.getJsonValue(incomingRequest, "service.parameters") + String resourceParameters = ResourceRequestBuilder.buildResourceRequestParameters(execution, serviceModelUuid, resourceCustomizationUuid, serviceParameters) + resourceInput.setResourceParameters(resourceParameters) + execution.setVariable("resourceInput", resourceInput) + utils.log("INFO", "======== COMPLETED prepareResourceRecipeRequest Process ======== ", isDebugEnabled) + } }