diff options
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common')
2 files changed, 143 insertions, 139 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy index 4b848024d6..de998a5f9c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy @@ -165,6 +165,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { ${statusLine} <model-invariant-id>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-id> <model-version-id>${MsoUtils.xmlEscape(modelUuid)}</model-version-id> + <input-parameters>${MsoUtils.xmlEscape(uuiRequest)}</input-parameters> </service-instance>""".trim() execution.setVariable("serviceInstanceData", serviceInstanceData) msoLogger.debug(serviceInstanceData) 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 482da23b33..2167025e18 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 @@ -17,7 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - + package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.bpmn.infrastructure.properties.BPMNProperties @@ -69,41 +69,37 @@ import org.onap.so.logger.MsoLogger * * Outputs: * @param - WorkflowException - */ public class DoCreateResources extends AbstractServiceTaskProcessor{ - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateResources.class); + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateResources.class); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + CatalogDbUtils cutils = new CatalogDbUtils() - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - CatalogDbUtils cutils = new CatalogDbUtils() + public void preProcessRequest(DelegateExecution execution) { + msoLogger.trace("preProcessRequest ") + String msg = "" - public void preProcessRequest(DelegateExecution execution) - { - msoLogger.trace("preProcessRequest ") - String msg = "" - List addResourceList = execution.getVariable("addResourceList") - if (addResourceList == null) - { + if (addResourceList == null) { msg = "Input addResourceList is null" msoLogger.info(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) } - else if (addResourceList.size() == 0) - { + else if (addResourceList.size() == 0) { msg = "No resource in addResourceList" msoLogger.info(msg) } msoLogger.trace("Exit preProcessRequest ") } - - public void sequenceResoure(DelegateExecution execution) - { + + public void sequenceResoure(DelegateExecution execution) { msoLogger.trace("Start sequenceResoure Process ") - String serviceModelUUID = execution.getVariable("modelUuid") - + String incomingRequest = execution.getVariable("uuiRequest") + String serviceModelUuid = jsonUtil.getJsonValue(incomingRequest,"service.serviceUuid") + List<Resource> addResourceList = execution.getVariable("addResourceList") List<NetworkResource> networkResourceList = new ArrayList<NetworkResource>() @@ -112,40 +108,47 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ String serviceDecompose = execution.getVariable("serviceDecomposition") String serviceModelName = jsonUtil.getJsonValue(serviceDecompose, "serviceResources.modelInfo.modelName") + + // get Sequence from properties def resourceSequence = BPMNProperties.getResourceSequenceProp(serviceModelName) + // get Sequence from csar(model) + if(resourceSequence == null) { + resourceSequence = ResourceRequestBuilder.getResourceSequence(execution, serviceModelUuid) + msoLogger.info("Get Sequence from csar : " + resourceSequence) + } + if(resourceSequence != null) { - // sequence is defined in config file - for (resourceType in resourceSequence) { - for (resource in addResourceList) { - if (StringUtils.containsIgnoreCase(resource.getModelInfo().getModelName(), resourceType)) { - sequencedResourceList.add(resource) - - if (resource instanceof NetworkResource) { - networkResourceList.add(resource) + for (resourceType in resourceSequence) { + for (resource in addResourceList) { + if (StringUtils.containsIgnoreCase(resource.getModelInfo().getModelName(), resourceType)) { + sequencedResourceList.add(resource) + + if (resource instanceof NetworkResource) { + networkResourceList.add(resource) + } } } } - } } else { - - //define sequenced resource list, we deploy vf first and then network and then ar - //this is defaule sequence - List<VnfResource> vnfResourceList = new ArrayList<VnfResource>() - List<AllottedResource> arResourceList = new ArrayList<AllottedResource>() - - for (Resource rc : addResourceList){ - if (rc instanceof VnfResource) { - vnfResourceList.add(rc) - } else if (rc instanceof NetworkResource) { - networkResourceList.add(rc) - } else if (rc instanceof AllottedResource) { - arResourceList.add(rc) + + //define sequenced resource list, we deploy vf first and then network and then ar + //this is defaule sequence + List<VnfResource> vnfResourceList = new ArrayList<VnfResource>() + List<AllottedResource> arResourceList = new ArrayList<AllottedResource>() + + for (Resource rc : addResourceList){ + if (rc instanceof VnfResource) { + vnfResourceList.add(rc) + } else if (rc instanceof NetworkResource) { + networkResourceList.add(rc) + } else if (rc instanceof AllottedResource) { + arResourceList.add(rc) + } } - } - sequencedResourceList.addAll(vnfResourceList) - sequencedResourceList.addAll(networkResourceList) - sequencedResourceList.addAll(arResourceList) + sequencedResourceList.addAll(vnfResourceList) + sequencedResourceList.addAll(networkResourceList) + sequencedResourceList.addAll(arResourceList) } String isContainsWanResource = networkResourceList.isEmpty() ? "false" : "true" @@ -154,11 +157,11 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ String serviceNeedSDNC = "mso.workflow.custom." + serviceModelName + ".sdnc.need"; isContainsWanResource = BPMNProperties.getProperty(serviceNeedSDNC, isContainsWanResource) } - + execution.setVariable("isContainsWanResource", isContainsWanResource) execution.setVariable("currentResourceIndex", 0) execution.setVariable("sequencedResourceList", sequencedResourceList) - msoLogger.info("sequencedResourceList: " + sequencedResourceList) + msoLogger.info("sequencedResourceList: " + sequencedResourceList) msoLogger.trace("COMPLETED sequenceResoure Process ") } @@ -181,105 +184,105 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ msoLogger.trace("======== End prepareServiceTopologyRequest Process ======== ") } - + public void getCurrentResoure(DelegateExecution execution){ - msoLogger.trace("Start getCurrentResoure Process ") - def currentIndex = execution.getVariable("currentResourceIndex") - List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList") - Resource currentResource = sequencedResourceList.get(currentIndex) - execution.setVariable("resourceType", currentResource.getModelInfo().getModelName()) - msoLogger.info("Now we deal with resouce:" + currentResource.getModelInfo().getModelName()) - msoLogger.trace("COMPLETED getCurrentResoure Process ") + msoLogger.trace("Start getCurrentResoure Process ") + def currentIndex = execution.getVariable("currentResourceIndex") + List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList") + Resource currentResource = sequencedResourceList.get(currentIndex) + execution.setVariable("resourceType", currentResource.getModelInfo().getModelName()) + msoLogger.info("Now we deal with resouce:" + currentResource.getModelInfo().getModelName()) + msoLogger.trace("COMPLETED getCurrentResoure Process ") } - + public void parseNextResource(DelegateExecution execution){ - msoLogger.trace("Start parseNextResource Process ") + msoLogger.trace("Start parseNextResource Process ") def currentIndex = execution.getVariable("currentResourceIndex") def nextIndex = currentIndex + 1 execution.setVariable("currentResourceIndex", nextIndex) - List<String> sequencedResourceList = execution.getVariable("sequencedResourceList") + List<String> sequencedResourceList = execution.getVariable("sequencedResourceList") if(nextIndex >= sequencedResourceList.size()){ execution.setVariable("allResourceFinished", "true") }else{ execution.setVariable("allResourceFinished", "false") } - msoLogger.trace("COMPLETED parseNextResource Process ") - } - - public void prepareResourceRecipeRequest(DelegateExecution execution){ - msoLogger.trace("Start prepareResourceRecipeRequest Process ") - ResourceInput resourceInput = new ResourceInput() - String serviceInstanceName = execution.getVariable("serviceInstanceName") - String resourceType = execution.getVariable("resourceType") - String resourceInstanceName = resourceType + "_" + serviceInstanceName - resourceInput.setResourceInstanceName(resourceInstanceName) - msoLogger.info("Prepare Resource Request resourceInstanceName:" + resourceInstanceName) - String globalSubscriberId = execution.getVariable("globalSubscriberId") - String serviceType = execution.getVariable("serviceType") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String operationId = execution.getVariable("operationId") - String operationType = "createInstance" - resourceInput.setGlobalSubscriberId(globalSubscriberId) - resourceInput.setServiceType(serviceType) - resourceInput.setServiceInstanceId(serviceInstanceId) - resourceInput.setOperationId(operationId) - resourceInput.setOperationType(operationType); - def currentIndex = execution.getVariable("currentResourceIndex") - List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList") - Resource currentResource = sequencedResourceList.get(currentIndex) - resourceInput.setResourceModelInfo(currentResource.getModelInfo()); - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - resourceInput.setServiceModelInfo(serviceDecomposition.getModelInfo()); - def String resourceCustomizationUuid = currentResource.getModelInfo().getModelCustomizationUuid(); - - String incomingRequest = execution.getVariable("uuiRequest") - //set the requestInputs from tempalte To Be Done - String serviceModelUuid = jsonUtil.getJsonValue(incomingRequest,"service.serviceUuid") - String serviceParameters = jsonUtil.getJsonValue(incomingRequest, "service.parameters") - String resourceParameters = ResourceRequestBuilder.buildResourceRequestParameters(execution, serviceModelUuid, resourceCustomizationUuid, serviceParameters) - resourceInput.setResourceParameters(resourceParameters) - resourceInput.setRequestsInputs(incomingRequest) - execution.setVariable("resourceInput", resourceInput) - msoLogger.trace("COMPLETED prepareResourceRecipeRequest Process ") - } - - public void executeResourceRecipe(DelegateExecution execution){ - msoLogger.trace("Start executeResourceRecipe Process ") - - try { - String requestId = execution.getVariable("msoRequestId") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String serviceType = execution.getVariable("serviceType") - ResourceInput resourceInput = execution.getVariable("resourceInput") - - // requestAction is action, not opertiontype - //String requestAction = resourceInput.getOperationType() - String requestAction = "createInstance" - JSONObject resourceRecipe = cutils.getResourceRecipe(execution, resourceInput.getResourceModelInfo().getModelUuid(), requestAction) - - if (resourceRecipe != null) { - String recipeURL = BPMNProperties.getProperty("bpelURL", "http://mso:8080") + resourceRecipe.getString("orchestrationUri") - int recipeTimeOut = resourceRecipe.getInt("recipeTimeout") - String recipeParamXsd = resourceRecipe.get("paramXSD") - HttpResponse resp = BpmnRestClient.post(recipeURL, requestId, recipeTimeOut, requestAction, serviceInstanceId, serviceType, resourceInput.toString(), recipeParamXsd) - } else { - String exceptionMessage = "Resource receipe is not found for resource modeluuid: " + - resourceInput.getResourceModelInfo().getModelUuid() - msoLogger.trace(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, exceptionMessage) - } - - msoLogger.trace("======== end executeResourceRecipe Process ======== ") - }catch(BpmnError b){ - msoLogger.debug("Rethrowing MSOWorkflowException") - throw b - }catch(Exception e){ - msoLogger.debug("Error occured within DoCreateResources executeResourceRecipe method: " + e) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured during DoCreateResources executeResourceRecipe Catalog") - } - } - - public void postConfigRequest(DelegateExecution execution){ - //now do noting - } + msoLogger.trace("COMPLETED parseNextResource Process ") + } + + public void prepareResourceRecipeRequest(DelegateExecution execution){ + msoLogger.trace("Start prepareResourceRecipeRequest Process ") + ResourceInput resourceInput = new ResourceInput() + String serviceInstanceName = execution.getVariable("serviceInstanceName") + String resourceType = execution.getVariable("resourceType") + String resourceInstanceName = resourceType + "_" + serviceInstanceName + resourceInput.setResourceInstanceName(resourceInstanceName) + msoLogger.info("Prepare Resource Request resourceInstanceName:" + resourceInstanceName) + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String operationType = "createInstance" + resourceInput.setGlobalSubscriberId(globalSubscriberId) + resourceInput.setServiceType(serviceType) + resourceInput.setServiceInstanceId(serviceInstanceId) + resourceInput.setOperationId(operationId) + resourceInput.setOperationType(operationType); + def currentIndex = execution.getVariable("currentResourceIndex") + List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList") + Resource currentResource = sequencedResourceList.get(currentIndex) + resourceInput.setResourceModelInfo(currentResource.getModelInfo()); + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + resourceInput.setServiceModelInfo(serviceDecomposition.getModelInfo()); + def String resourceCustomizationUuid = currentResource.getModelInfo().getModelCustomizationUuid(); + + String incomingRequest = execution.getVariable("uuiRequest") + //set the requestInputs from tempalte To Be Done + String serviceModelUuid = jsonUtil.getJsonValue(incomingRequest,"service.serviceUuid") + String serviceParameters = jsonUtil.getJsonValue(incomingRequest, "service.parameters") + String resourceParameters = ResourceRequestBuilder.buildResourceRequestParameters(execution, serviceModelUuid, resourceCustomizationUuid, serviceParameters) + resourceInput.setResourceParameters(resourceParameters) + resourceInput.setRequestsInputs(incomingRequest) + execution.setVariable("resourceInput", resourceInput) + msoLogger.trace("COMPLETED prepareResourceRecipeRequest Process ") + } + + public void executeResourceRecipe(DelegateExecution execution){ + msoLogger.trace("Start executeResourceRecipe Process ") + + try { + String requestId = execution.getVariable("msoRequestId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String serviceType = execution.getVariable("serviceType") + ResourceInput resourceInput = execution.getVariable("resourceInput") + + // requestAction is action, not opertiontype + //String requestAction = resourceInput.getOperationType() + String requestAction = "createInstance" + JSONObject resourceRecipe = cutils.getResourceRecipe(execution, resourceInput.getResourceModelInfo().getModelUuid(), requestAction) + + if (resourceRecipe != null) { + String recipeURL = BPMNProperties.getProperty("bpelURL", "http://mso:8080") + resourceRecipe.getString("orchestrationUri") + int recipeTimeOut = resourceRecipe.getInt("recipeTimeout") + String recipeParamXsd = resourceRecipe.get("paramXSD") + HttpResponse resp = BpmnRestClient.post(recipeURL, requestId, recipeTimeOut, requestAction, serviceInstanceId, serviceType, resourceInput.toString(), recipeParamXsd) + } else { + String exceptionMessage = "Resource receipe is not found for resource modeluuid: " + + resourceInput.getResourceModelInfo().getModelUuid() + msoLogger.trace(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, exceptionMessage) + } + + msoLogger.trace("======== end executeResourceRecipe Process ======== ") + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + }catch(Exception e){ + msoLogger.debug("Error occured within DoCreateResources executeResourceRecipe method: " + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured during DoCreateResources executeResourceRecipe Catalog") + } + } + + public void postConfigRequest(DelegateExecution execution){ + //now do noting + } } |