From 140cd9c29a4f1ab9aa9590f07ac6b653ca459ffa Mon Sep 17 00:00:00 2001 From: Isaac Manuel Raj Date: Fri, 17 May 2019 20:48:58 +0530 Subject: Fix SDNC Resource creation workflow Fix SDNC Resource Creation workflow Issue-ID: SO-1393 Change-Id: Ia75150adf3695e623a2f3ec7ea5f720667142c1b Signed-off-by: Isaac Manuel Raj --- .../onap/so/bpmn/common/recipe/ResourceInput.java | 24 ++ .../bpmn/common/resource/InstanceResourceList.java | 14 +- .../scripts/ActivateSDNCNetworkResource.groovy | 70 +--- .../scripts/CreateSDNCNetworkResource.groovy | 417 ++++++++++++++------- .../scripts/DoCreateResources.groovy | 64 +++- .../process/ActivateSDNCNetworkResource.bpmn | 30 +- 6 files changed, 400 insertions(+), 219 deletions(-) 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..33c48fbe44 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 @@ -84,6 +84,30 @@ public class ResourceInput { @JsonProperty("operationType") private String operationType; + @JsonProperty("vfModelInfo") + private ModelInfo vfModelInfo; + + + @JsonProperty("vnf-Id") + private String vnfId; + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public ModelInfo getVfModelInfo() { + return vfModelInfo; + } + + public void setVfModelInfo(ModelInfo vfModelInfo) { + this.vfModelInfo = vfModelInfo; + } + + /** * @return Returns the requestsInputs. */ diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java index 71ea3b565b..e32a03dfa2 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java @@ -98,8 +98,6 @@ public class InstanceResourceList { // ....} // it will return sdwansiteresource_list private static String getPrimaryKey(Resource resource) { - String pk = ""; - String resourceInput = ""; if (resource instanceof VnfResource) { resourceInput = ((VnfResource) resource).getResourceInput(); @@ -111,10 +109,16 @@ public class InstanceResourceList { Type type = new TypeToken>() {}.getType(); Map map = gson.fromJson(resourceInput, type); - Optional pkOpt = map.values().stream().filter(e -> e.contains("[")).map(e -> e.replace("[", "")) - .map(e -> e.split(",")[0]).findFirst(); + if (map != null) { + Optional pkOpt = map.values().stream().filter(e -> e.contains("[")).map(e -> e.replace("[", "")) + .map(e -> e.split(",")[0]).findFirst(); - return pkOpt.isPresent() ? pkOpt.get() : ""; + return pkOpt.isPresent() ? pkOpt.get() : ""; + } else { + // TODO: handle the case if VNF resource is not list + // e.g. { resourceInput + return ""; + } } private static List convertToInstanceResourceList(Map>> normalizedReq, diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy index f4bdde5e80..2d0b9e5a99 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy @@ -33,6 +33,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.core.domain.ResourceType import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.slf4j.Logger @@ -52,7 +53,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { JsonUtils jsonUtil = new JsonUtils() SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - + MsoUtils msoUtils = new MsoUtils() public void preProcessRequest(DelegateExecution execution) { @@ -83,49 +84,17 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { } String sdnc_svcAction = "activate" - switch (resourceInputObj.getResourceModelInfo().getModelName()) { - case ~/[\w\s\W]*SOTNConnectivity[\w\s\W]*/ : - operationType = "SOTNConnectivity" - break - - case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/ : - operationType = "SOTNAttachment" - break - - case ~/[\w\s\W]*SiteVF[\w\s\W]*/ : - operationType = "Site" - break - - case ~/[\w\s\W]*deviceVF[\w\s\W]*/ : - operationType = "SDWANDevice" - execution.setVariable("isActivateRequired", "true") - break - - case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ : - operationType = "SDWANPort" - execution.setVariable("isActivateRequired", "true") - break + String sdnc_requestAction = UrnPropertiesReader.getVariable("resource-config." + resourceInputObj.resourceModelInfo.getModelName() +".operation-type") + String isActivateRequired = UrnPropertiesReader.getVariable("resource-config." + resourceInputObj.resourceModelInfo.getModelName() +".activation-required") + execution.setVariable("isActivateRequired", isActivateRequired) - case ~/[\w\s\W]*SDWANConnectivity[\w\s\W]*/ : - operationType = "SDWANConnectivity" - break - - case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ : - operationType = "SDWANAttachment" - break - - default: - break - } - - String sdnc_requestAction = StringUtils.capitalize(sdnc_svcAction) + operationType +"Instance" execution.setVariable(Prefix + "svcAction", sdnc_svcAction) execution.setVariable(Prefix + "requestAction", sdnc_requestAction) execution.setVariable(Prefix + "serviceInstanceId", resourceInputObj.getServiceInstanceId()) execution.setVariable("mso-request-id", requestId) execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId()) } catch (BpmnError e) { - throw e; + throw e } catch (Exception ex){ String msg = "Exception in preProcessRequest " + ex.getMessage() logger.debug(msg) @@ -174,20 +143,20 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { } String customizeResourceParam(String networkInputParametersJson) { - List> paramList = new ArrayList(); + List> paramList = new ArrayList() JSONObject jsonObject = new JSONObject(networkInputParametersJson); - Iterator iterator = jsonObject.keys(); + Iterator iterator = jsonObject.keys() while (iterator.hasNext()) { - String key = iterator.next(); - HashMap hashMap = new HashMap(); + String key = iterator.next() + HashMap hashMap = new HashMap() hashMap.put("name", key); hashMap.put("value", jsonObject.get(key)) paramList.add(hashMap) } - Map>> paramMap = new HashMap(); - paramMap.put("param", paramList); + Map>> paramMap = new HashMap() + paramMap.put("param", paramList) - return new JSONObject(paramMap).toString(); + return new JSONObject(paramMap).toString() } public void prepareSDNCRequest (DelegateExecution execution) { @@ -224,11 +193,9 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { String netowrkInputParameters = XML.toString(new JSONObject(customizeResourceParam(networkInputParametersJson))) // 1. prepare assign topology via SDNC Adapter SUBFLOW call String sdncTopologyActivateRequest = "" - - switch (modelName) { - case ~/[\w\s\W]*deviceVF[\w\s\W]*/ : - case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ : - case ~/[\w\s\W]*SiteVF[\w\s\W]*/: + String modelType = resourceInputObj.getResourceModelInfo().getModelType() + switch (modelType) { + case "VNF" : sdncTopologyActivateRequest = """ @@ -286,8 +253,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { """.trim() break - case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ : - case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/: + case "GROUP" : sdncTopologyActivateRequest = """ metadatum = getMetaDatum(resourceInputObj.getGlobalSubscriberId(), - resourceInputObj.getServiceType(), - resourceInputObj.getServiceInstanceId()) + resourceInputObj.getServiceType(), + resourceInputObj.getServiceInstanceId()) for(Metadatum datum: metadatum) { if (datum.getMetaname().equalsIgnoreCase("cvlan")) { cvlan = datum.getMetaval() @@ -346,13 +285,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: @@ -399,12 +338,31 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { //here convert json string to xml string String netowrkInputParameters = XML.toString(new JSONObject(customizeResourceParam(networkInputParametersJson))) // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sdncTopologyCreateRequest = "" + String sdncTopologyCreateRequest = ""; + + + + //When a new resource creation request reaches SO, the parent resources information needs to be provided + //while creating the child resource. + String vnfid = "" + String vnfmodelInvariantUuid = "" + String vnfmodelCustomizationUuid = "" + String vnfmodelUuid = "" + String vnfmodelVersion = "" + String vnfmodelName = "" + String modelType = resourceInputObj.getResourceModelInfo().getModelType() + if(modelType.equalsIgnoreCase(ResourceType.GROUP.toString())) { + vnfid = resourceInputObj.getVnfId(); + ModelInfo vfModelInfo = resourceInputObj.getVfModelInfo() + vnfmodelInvariantUuid = vfModelInfo.getModelInvariantUuid() + vnfmodelCustomizationUuid = vfModelInfo.getModelCustomizationUuid() + vnfmodelUuid = vfModelInfo.getModelUuid() + vnfmodelVersion = vfModelInfo.getModelVersion() + vnfmodelName = vfModelInfo.getModelName() + } - switch (modelName) { - case ~/[\w\s\W]*deviceVF[\w\s\W]*/ : - case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ : - case ~/[\w\s\W]*SiteVF[\w\s\W]*/: + switch (modelType) { + case "VNF" : sdncTopologyCreateRequest = """ @@ -439,7 +397,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { ${msoUtils.xmlEscape(globalCustomerId)} - + ${msoUtils.xmlEscape(vnfid)} ${msoUtils.xmlEscape(modelInvariantUuid)} @@ -461,9 +419,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { """.trim() break - - case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ : - case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/ : + case "GROUP" : sdncTopologyCreateRequest = """ @@ -471,7 +427,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { ${msoUtils.xmlEscape(hdrRequestId)} ${msoUtils.xmlEscape(serviceInstanceId)} ${msoUtils.xmlEscape(sdnc_svcAction)} - connection-attachment-topology-operation + network-topology-operation sdncCallback generic-resource @@ -497,19 +453,22 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { ${msoUtils.xmlEscape(globalCustomerId)} ${msoUtils.xmlEscape(globalCustomerId)} - - - - - $parentServiceInstanceId - - ${msoUtils.xmlEscape(modelInvariantUuid)} - ${msoUtils.xmlEscape(modelCustomizationUuid)} - ${msoUtils.xmlEscape(modelUuid)} - ${msoUtils.xmlEscape(modelVersion)} - ${msoUtils.xmlEscape(modelName)} - - + + ${msoUtils.xmlEscape(vnfmodelInvariantUuid)} + ${msoUtils.xmlEscape(vnfmodelCustomizationUuid)} + ${msoUtils.xmlEscape(vnfmodelUuid)} + ${msoUtils.xmlEscape(vnfmodelVersion)} + ${msoUtils.xmlEscape(vnfmodelName)} + + + + $netowrkInputParameters + + + + + + $netowrkInputParameters @@ -520,13 +479,70 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { // for SDWANConnectivity and SOTNConnectivity: default: sdncTopologyCreateRequest = """ + + ${hdrRequestId} + ${msoUtils.xmlEscape(serviceInstanceId)} + ${msoUtils.xmlEscape(sdnc_svcAction)} + network-topology-operation + sdncCallback + generic-resource + + + + ${msoUtils.xmlEscape(hdrRequestId)} + ${msoUtils.xmlEscape(sdnc_requestAction)} + ${msoUtils.xmlEscape(source)} + + + + + + ${msoUtils.xmlEscape(serviceInstanceId)} + ${msoUtils.xmlEscape(serviceType)} + + ${msoUtils.xmlEscape(serviceModelInvariantUuid)} + ${msoUtils.xmlEscape(serviceModelUuid)} + ${msoUtils.xmlEscape(serviceModelVersion)} + ${msoUtils.xmlEscape(serviceModelName)} + + ${msoUtils.xmlEscape(serviceInstanceId)} + ${msoUtils.xmlEscape(globalCustomerId)} + + + + ${msoUtils.xmlEscape(modelInvariantUuid)} + ${msoUtils.xmlEscape(modelCustomizationUuid)} + ${msoUtils.xmlEscape(modelUuid)} + ${msoUtils.xmlEscape(modelVersion)} + ${msoUtils.xmlEscape(modelName)} + + + + $netowrkInputParameters + + + """.trim() + + + } + + + + + //switch (modelName) { + // case ~/[\w\s\W]*deviceVF[\w\s\W]*/ + // case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ : + // case ~/[\w\s\W]*SiteVF[\w\s\W]*/: + /* sdncTopologyCreateRequest = """ - ${hdrRequestId} + ${msoUtils.xmlEscape(hdrRequestId)} ${msoUtils.xmlEscape(serviceInstanceId)} ${msoUtils.xmlEscape(sdnc_svcAction)} - network-topology-operation + vnf-topology-operation sdncCallback generic-resource @@ -550,8 +566,11 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { ${msoUtils.xmlEscape(serviceInstanceId)} ${msoUtils.xmlEscape(globalCustomerId)} + ${msoUtils.xmlEscape(globalCustomerId)} - + + + ${msoUtils.xmlEscape(modelInvariantUuid)} ${msoUtils.xmlEscape(modelCustomizationUuid)} @@ -559,13 +578,147 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { ${msoUtils.xmlEscape(modelVersion)} ${msoUtils.xmlEscape(modelName)} - - - $netowrkInputParameters - + + + + $netowrkInputParameters + + + + + + """.trim() - } + + + break + + //case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ + //case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/ : + /* sdncTopologyCreateRequest = """ + + ${msoUtils.xmlEscape(hdrRequestId)} + ${msoUtils.xmlEscape(serviceInstanceId)} + ${msoUtils.xmlEscape(sdnc_svcAction)} + connection-attachment-topology-operation + sdncCallback + generic-resource + + + + ${msoUtils.xmlEscape(hdrRequestId)} + ${msoUtils.xmlEscape(sdnc_requestAction)} + ${msoUtils.xmlEscape(source)} + + + + + + ${msoUtils.xmlEscape(serviceInstanceId)} + ${msoUtils.xmlEscape(serviceType)} + + ${msoUtils.xmlEscape(serviceModelInvariantUuid)} + ${msoUtils.xmlEscape(serviceModelUuid)} + ${msoUtils.xmlEscape(serviceModelVersion)} + ${msoUtils.xmlEscape(serviceModelName)} + + ${msoUtils.xmlEscape(serviceInstanceId)} + ${msoUtils.xmlEscape(globalCustomerId)} + ${msoUtils.xmlEscape(globalCustomerId)} + + + + + ${msoUtils.xmlEscape(modelInvariantUuid)} + ${msoUtils.xmlEscape(modelCustomizationUuid)} + ${msoUtils.xmlEscape(modelUuid)} + ${msoUtils.xmlEscape(modelVersion)} + ${msoUtils.xmlEscape(modelName)} + + + + + $netowrkInputParameters + + + + + + + + + + + $parentServiceInstanceId + + ${msoUtils.xmlEscape(modelInvariantUuid)} + ${msoUtils.xmlEscape(modelCustomizationUuid)} + ${msoUtils.xmlEscape(modelUuid)} + ${msoUtils.xmlEscape(modelVersion)} + ${msoUtils.xmlEscape(modelName)} + + + + $netowrkInputParameters + + + """.trim() + break + + // for SDWANConnectivity and SOTNConnectivity: + default: + sdncTopologyCreateRequest = """ + + ${hdrRequestId} + ${msoUtils.xmlEscape(serviceInstanceId)} + ${msoUtils.xmlEscape(sdnc_svcAction)} + network-topology-operation + sdncCallback + generic-resource + + + + ${msoUtils.xmlEscape(hdrRequestId)} + ${msoUtils.xmlEscape(sdnc_requestAction)} + ${msoUtils.xmlEscape(source)} + + + + + + ${msoUtils.xmlEscape(serviceInstanceId)} + ${msoUtils.xmlEscape(serviceType)} + + ${msoUtils.xmlEscape(serviceModelInvariantUuid)} + ${msoUtils.xmlEscape(serviceModelUuid)} + ${msoUtils.xmlEscape(serviceModelVersion)} + ${msoUtils.xmlEscape(serviceModelName)} + + ${msoUtils.xmlEscape(serviceInstanceId)} + ${msoUtils.xmlEscape(globalCustomerId)} + + + + ${msoUtils.xmlEscape(modelInvariantUuid)} + ${msoUtils.xmlEscape(modelCustomizationUuid)} + ${msoUtils.xmlEscape(modelUuid)} + ${msoUtils.xmlEscape(modelVersion)} + ${msoUtils.xmlEscape(modelName)} + + + + $netowrkInputParameters + + + """.trim() + } + + **/ String sndcTopologyCreateRequesAsString = utils.formatXml(sdncTopologyCreateRequest) execution.setVariable("sdncAdapterWorkflowRequest", sndcTopologyCreateRequesAsString) @@ -656,11 +809,8 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { String responseCode = execution.getVariable(Prefix + "sdncCreateReturnCode") String responseObj = execution.getVariable(Prefix + "SuccessIndicator") - def isActivateRequried = execution.getVariable("isActivateRequired") - if (StringUtils.equalsIgnoreCase(isActivateRequried, "true")) { - def instnaceId = getInstnaceId(execution) - execution.setVariable("networkInstanceId", instnaceId) - } + def instnaceId = getInstnaceId(execution) + execution.setVariable("resourceInstanceId", instnaceId) logger.info("response from sdnc, response code :" + responseCode + " response object :" + responseObj) logger.info(" ***** Exit prepareSDNCRequest *****") @@ -673,24 +823,38 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { String modelName = resourceInputObj.getResourceModelInfo().getModelName() def val = "" - switch (modelName) { - case ~/[\w\s\W]*deviceVF[\w\s\W]*/ : - case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ : - case ~/[\w\s\W]*Site[\w\s\W]*/: + + //switch (modelName) { + // case ~/[\w\s\W]*deviceVF[\w\s\W]*/ : + // case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ : + // case ~/[\w\s\W]*Site[\w\s\W]*/: + // val = response."response-data"."RequestData"."output"."vnf-response-information"."instance-id" + // break + + // case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ : + // case ~/[\w\s\W]*sotnvpprepareUpdateAfterCreateSDNCResourcenattachment[\w\s\W]*/: + // val = response."response-data"."RequestData"."output"."connection-attachment-response-information"."instance-id" + // break + + // for SDWANConnectivity and SOTNConnectivity and default: + // default: + // val = response."response-data"."RequestData"."output"."network-response-information"."instance-id" + // break + //} + + + String modelType = resourceInputObj.getResourceModelInfo().getModelType() + switch (modelType) { + case "VNF" : val = response."response-data"."RequestData"."output"."vnf-response-information"."instance-id" break - - case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ : - case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/: - val = response."response-data"."RequestData"."output"."connection-attachment-response-information"."instance-id" + case "GROUP": + val = response."response-data"."RequestData"."output"."vf-module-response-information"."instance-id" break - - // for SDWANConnectivity and SOTNConnectivity and default: default: val = response."response-data"."RequestData"."output"."network-response-information"."instance-id" break } - return val.toString() } @@ -700,7 +864,8 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { try { String operationStatus = "finished" // RESTResponse for main flow - String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim() + String vnfid=execution.getVariable("resourceInstanceId"); + String resourceOperationResp = """{"operationStatus":"${operationStatus}","vnf-id":"${vnfid}"}""".trim() logger.debug(" sendSyncResponse to APIH:" + "\n" + resourceOperationResp) sendWorkflowResponse(execution, 202, resourceOperationResp) execution.setVariable("sentSyncResponse", true) @@ -712,4 +877,4 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { } logger.debug(" ***** Exit sendSyncResponse *****") } -} +} \ No newline at end of file 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 ea25904cf3..a303da9a8f 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 @@ -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. @@ -22,9 +22,15 @@ package org.onap.so.bpmn.infrastructure.scripts + +import com.google.common.reflect.TypeToken +import com.google.gson.Gson +import org.apache.http.util.EntityUtils import org.onap.so.bpmn.common.resource.InstanceResourceList import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory import org.onap.so.bpmn.core.domain.GroupResource +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ResourceType import org.onap.so.bpmn.infrastructure.properties.BPMNProperties import org.apache.commons.lang3.StringUtils import org.apache.http.HttpResponse @@ -46,11 +52,12 @@ import org.onap.so.bpmn.common.resource.ResourceRequestBuilder import org.slf4j.Logger import org.slf4j.LoggerFactory +import java.lang.reflect.Type /** * This groovy class supports the DoCreateResources.bpmn process. - * + * * Inputs: * @param - msoRequestId * @param - globalSubscriberId - O @@ -58,7 +65,7 @@ import org.slf4j.LoggerFactory * @param - serviceInstanceId * @param - serviceInstanceName - O * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM) - * @param - sdncVersion + * @param - sdncVersion * * @param - addResourceList * @@ -101,7 +108,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ public void sequenceResoure(DelegateExecution execution) { logger.trace("Start sequenceResoure Process ") - + String incomingRequest = execution.getVariable("uuiRequest") String serviceModelUuid = jsonUtil.getJsonValue(incomingRequest,"service.serviceUuid") @@ -114,10 +121,10 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ String serviceDecompose = execution.getVariable("serviceDecomposition") String serviceModelName = jsonUtil.getJsonValue(serviceDecompose, "serviceResources.modelInfo.modelName") - // get Sequence from properties + // get Sequence from properties def resourceSequence = BPMNProperties.getResourceSequenceProp(serviceModelName) - // get Sequence from csar(model) + // get Sequence from csar(model) if(resourceSequence == null) { resourceSequence = ResourceRequestBuilder.getResourceSequence(serviceModelUuid) logger.info("Get Sequence from csar : " + resourceSequence) @@ -254,21 +261,38 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ resourceInput.setResourceModelInfo(currentResource.getModelInfo()) resourceInput.getResourceModelInfo().setModelType(currentResource.getResourceType().toString()) ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + + if (currentResource.getResourceType() == ResourceType.VNF) { + execution.setVariable("vfModelInfo", currentResource.getModelInfo()) + } + + resourceInput.setVfModelInfo(execution.getVariable("vfModelInfo") as ModelInfo) + String vnfId = execution.getVariable("vnf-id") + if (vnfId != null) { + resourceInput.setVnfId(vnfId) + } + + resourceInput.setServiceModelInfo(serviceDecomposition.getModelInfo()) String incomingRequest = execution.getVariable("uuiRequest") - //set the requestInputs from tempalte To Be Done + //set the requestInputs from template To Be Done String uuiServiceParameters = jsonUtil.getJsonValue(incomingRequest, "service.parameters") - Map currentVFData = (Map) execution.getVariable("currentVFData"); + + // current vfdata holds information for preparing input for resource + // e.g. it will hold + // { top_level_list_name, second_level_list_name, top_index, second_index, last processed node} + Map currentVFData = (Map) execution.getVariable("currentVFData") + if (null == currentVFData) { - currentVFData = new HashMap<>(); + currentVFData = new HashMap<>() } String resourceParameters = ResourceRequestBuilder.buildResourceRequestParameters(execution, currentResource, uuiServiceParameters, currentVFData) resourceInput.setResourceParameters(resourceParameters) resourceInput.setRequestsInputs(incomingRequest) execution.setVariable("resourceInput", resourceInput.toString()) execution.setVariable("resourceModelUUID", resourceInput.getResourceModelInfo().getModelUuid()) - execution.setVariable("currentVFData",currentVFData); + execution.setVariable("currentVFData",currentVFData) logger.trace("COMPLETED prepareResourceRecipeRequest Process ") } @@ -294,6 +318,22 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ BpmnRestClient bpmnRestClient = new BpmnRestClient() HttpResponse resp = bpmnRestClient.post(recipeURL, requestId, recipeTimeOut, requestAction, serviceInstanceId, serviceType, resourceInput, recipeParamXsd) + + def currentIndex = execution.getVariable("currentResourceIndex") + List instanceResourceList = execution.getVariable("instanceResourceList") as List + Resource currentResource = instanceResourceList.get(currentIndex) + if(ResourceType.VNF == currentResource.getResourceType()) { + if (resp.getStatusLine().getStatusCode() > 199 && resp.getStatusLine().getStatusCode() < 300) { + String responseString = EntityUtils.toString(resp.getEntity(), "UTF-8") + if (responseString != null) { + Gson gson = new Gson() + Type type = new TypeToken>() {}.getType() + Map map = gson.fromJson(responseString, type) + Map map1 = gson.fromJson(map.get("response"), type) + execution.setVariable("vnf-id",map1.get("vnf-id")) + } + } + } } else { String exceptionMessage = "Resource receipe is not found for resource modeluuid: " + resourceModelUUID logger.trace(exceptionMessage) @@ -313,4 +353,4 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ public void postConfigRequest(DelegateExecution execution){ //now do noting } -} +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSDNCNetworkResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSDNCNetworkResource.bpmn index 8cde4f6c56..e5b361643f 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSDNCNetworkResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSDNCNetworkResource.bpmn @@ -1,13 +1,13 @@ - + SequenceFlow_1c92ks3_activate - SequenceFlow_17md60u_activate + SequenceFlow_0ow44q0_activate - + SequenceFlow_1vnx1pp_activate SequenceFlow_0ow44q0_activate @@ -54,14 +54,6 @@ dcsi.prepareUpdateAfterActivateSDNCResource(execution) - - SequenceFlow_0ow44q0_activate - SequenceFlow_17md60u_activate - import org.onap.so.bpmn.infrastructure.scripts.* -def csi = new ActivateSDNCNetworkResource() -csi.sendSyncResponse(execution) - - SequenceFlow_18l3crb_activate @@ -96,14 +88,14 @@ dcsi.prepareSDNCRequest(execution) - + - + - + @@ -141,16 +133,6 @@ dcsi.prepareSDNCRequest(execution) - - - - - - - - - - -- cgit 1.2.3-korg