diff options
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/main/groovy')
9 files changed, 166 insertions, 46 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy index da9584771c..75006365f2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy @@ -268,34 +268,39 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe Map<String,Object> profile switch(domainType) { case "AN-NF": - profile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)//pending fields - maxBandwidth, sST, plmnIdList, cSReliabilityMeanTime, - //msgSizeByte, maxNumberofPDUSessions,overallUserDensity,transferIntervalTarget + profile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)//pending fields - cSReliabilityMeanTime, cSAvailabilityTarget, terminalDensity, msgSizeByte result.setJitter(profile.get("jitter")) result.setLatency(profile.get("latency")) + result.setMaxBandwidth(profile.get("maxbandwidth")) result.setResourceSharingLevel(profile.get("resourceSharingLevel")) result.setUeMobilityLevel(profile.get("uEMobilityLevel")) result.setMaxNumberOfUEs(profile.get("maxNumberofUEs")) result.setActivityFactor(profile.get("activityFactor")) - result.setCoverageAreaTAList(profile.get("coverageAreaTAList")) + result.setCoverageAreaTAList(profile.get("coverageAreaTAList").toString()) result.setExpDataRateDL(profile.get("expDataRateDL")) result.setExpDataRateUL(profile.get("expDataRateUL")) result.setSurvivalTime(profile.get("survivalTime")) + result.setMaxNumberOfPDUSession(profile.get("maxNumberOfPDUSession")) result.setAreaTrafficCapDL(profile.get("areaTrafficCapDL")) result.setAreaTrafficCapUL(profile.get("areaTrafficCapUL")) + result.setOverallUserDensity(profile.get("overallUserDensity")) + result.setTransferIntervalTarget(profile.get("transferIntervalTarget")) result.setExpDataRate(profile.get("expDataRate")) result.setProfileId(execution.getVariable("ANNF_sliceProfileId")) break case "TN-FH": - profile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class) //pending fields - maxBandwidth, sST, plmnIdList + profile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class) result.setJitter(profile.get("jitter")) result.setLatency(profile.get("latency")) + result.setMaxBandwidth(profile.get("maxbandwidth")) result.setResourceSharingLevel(profile.get("resourceSharingLevel")) result.setProfileId(execution.getVariable("TNFH_sliceProfileId")) break case "TN-MH": - profile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class)//pending fields - maxBandwidth, sST, plmnIdList + profile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class) result.setJitter(profile.get("jitter")) result.setLatency(profile.get("latency")) + result.setMaxBandwidth(profile.get("maxbandwidth")) result.setResourceSharingLevel(profile.get("resourceSharingLevel")) result.setProfileId(execution.getVariable("TNMH_sliceProfileId")) break @@ -356,6 +361,7 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe if(domainType.equals("TN_FH")) { serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNFH_modelInvariantUuid")) serviceInfo.addProperty("serviceUuid", execution.getVariable("TNFH_modelUuid")) + serviceInfo.addProperty("nssiName", execution.getVariable("TNFH_modelName")) allocateTnNssi.addProperty("nsstId", execution.getVariable("TNFH_modelUuid")) allocateTnNssi.addProperty("nssiName", execution.getVariable("TNFH_modelName")) Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class) @@ -367,6 +373,7 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe }else if(domainType.equals("TN_MH")) { serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNMH_modelInvariantUuid")) serviceInfo.addProperty("serviceUuid", execution.getVariable("TNMH_modelUuid")) + serviceInfo.addProperty("nssiName", execution.getVariable("TNMH_modelName")) allocateTnNssi.addProperty("nsstId", execution.getVariable("TNMH_modelUuid")) allocateTnNssi.addProperty("nssiName", execution.getVariable("TNMH_modelName")) Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy index ff7b0a3b6d..515990ac1a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy @@ -37,6 +37,9 @@ import org.onap.so.db.request.beans.ResourceOperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory +import static org.apache.commons.lang3.StringUtils.isBlank +import static org.apache.commons.lang3.StringUtils.isEmpty + public class DoActivateTnNssi extends AbstractServiceTaskProcessor { String Prefix = "TNACT_" @@ -63,7 +66,9 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor { String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("modelUuid") - //here modelVersion is not set, we use modelUuid to decompose the service. + if (isEmpty(modelUuid)) { + modelUuid = tnNssmfUtils.getModelUuidFromServiceInstance(execution.getVariable("serviceInstanceID")) + } def isDebugLogEnabled = true execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) String serviceModelInfo = """{ @@ -83,7 +88,13 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor { String actionType = operationType.equals("activateInstance") ? "activate" : "deactivate" execution.setVariable("actionType", actionType) - tnNssmfUtils.setEnableSdncConfig(execution) + String additionalPropJsonStr = execution.getVariable("sliceParams") + if (isBlank(additionalPropJsonStr) || + isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution, + additionalPropJsonStr, + "enableSdnc", "enableSdnc"))) { + tnNssmfUtils.setEnableSdncConfig(execution) + } logger.debug("Finish preProcessRequest") } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy index 33724bd011..567c703496 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy @@ -323,7 +323,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { execution.setVariable("isRspRanNssi", true) }else { JsonObject newNSISolution = sol.get("newNSISolution").getAsJsonObject() - JsonArray sliceProfiles = newNSISolution.get("slice_profiles").getAsJsonArray() + JsonArray sliceProfiles = newNSISolution.get("sliceProfiles").getAsJsonArray() logger.debug("RanConstituentSliceProfiles list from OOF "+sliceProfiles) execution.setVariable("RanConstituentSliceProfiles", sliceProfiles.toString()) } @@ -354,14 +354,14 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { execution.setVariable("modifySliceParams", modifySliceParams.toString()) //create operation status in request db - String serviceId = execution.getVariable("RANServiceInstanceId") String nsiId = execution.getVariable("nsiId") - logger.debug("Generated new job for Service Instance serviceId:" + serviceId + "jobId:" + jobId) + String modelUuid = execution.getVariable("modelUuid") + logger.debug("Generated new job for Service Instance serviceId:" + nsiId + "jobId:" + jobId) ResourceOperationStatus initStatus = new ResourceOperationStatus() - initStatus.setServiceId(serviceId) + initStatus.setServiceId(nsiId) initStatus.setOperationId(jobId) - initStatus.setResourceTemplateUUID(nsiId) + initStatus.setResourceTemplateUUID(modelUuid) initStatus.setOperType("Modify") requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) } @@ -613,13 +613,17 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { ANServiceInstance.setServiceType(serviceType) String serviceStatus = "deactivated" ANServiceInstance.setOrchestrationStatus(serviceStatus) - String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "pLMNIdList") + String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "plmnIdList") ANServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid) String serviceRole = "nssi" ANServiceInstance.setServiceRole(serviceRole) List<String> snssaiList = execution.getVariable("snssaiList") String snssai = snssaiList.get(0) ANServiceInstance.setEnvironmentContext(snssai) + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelUuid = execution.getVariable("modelUuid") + ANServiceInstance.setModelInvariantId(modelInvariantUuid) + ANServiceInstance.setModelVersionId(modelUuid) ANServiceInstance.setWorkloadContext("AN") String serviceFunctionAn = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "resourceSharingLevel") ANServiceInstance.setServiceFunction(serviceFunctionAn) @@ -630,12 +634,14 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { ANNFServiceInstance.setServiceInstanceName(sliceInstanceName) ANNFServiceInstance.setServiceType(serviceType) ANNFServiceInstance.setOrchestrationStatus(serviceStatus) - serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "pLMNIdList") + serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "plmnIdList") ANNFServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid) ANNFServiceInstance.setServiceRole(serviceRole) snssaiList = execution.getVariable("snssaiList") snssai = snssaiList.get(0) ANNFServiceInstance.setEnvironmentContext(snssai) + ANNFServiceInstance.setModelInvariantId(execution.getVariable("ANNF_modelInvariantUuid")) + ANNFServiceInstance.setModelVersionId(execution.getVariable("ANNF_modelUuid")) ANNFServiceInstance.setWorkloadContext("AN-NF") String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "resourceSharingLevel") ANNFServiceInstance.setServiceFunction(serviceFunctionAnnf) @@ -852,16 +858,16 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { def prepareOperationStatusUpdate = { DelegateExecution execution -> logger.debug(Prefix + "prepareOperationStatusUpdate Start") - String serviceId = execution.getVariable("dummyServiceId") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") + String modelUuid = execution.getVariable("modelUuid") String nssiId = execution.getVariable("RANServiceInstanceId") - logger.debug("Service Instance serviceId:" + serviceId + " jobId:" + jobId) + logger.debug("Service Instance serviceId:" + nsiId + " jobId:" + jobId) ResourceOperationStatus updateStatus = new ResourceOperationStatus() - updateStatus.setServiceId(serviceId) + updateStatus.setServiceId(nsiId) updateStatus.setOperationId(jobId) - updateStatus.setResourceTemplateUUID(nsiId) + updateStatus.setResourceTemplateUUID(modelUuid) updateStatus.setResourceInstanceID(nssiId) updateStatus.setOperType("Allocate") updateStatus.setProgress("100") @@ -874,16 +880,16 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { def prepareFailedOperationStatusUpdate = { DelegateExecution execution -> logger.debug(Prefix + "prepareFailedOperationStatusUpdate Start") - String serviceId = execution.getVariable("dummyServiceId") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") + String modelUuid = execution.getVariable("modelUuid") String nssiId = execution.getVariable("RANServiceInstanceId") - logger.debug("Service Instance serviceId:" + serviceId + " jobId:" + jobId) + logger.debug("Service Instance serviceId:" + nsiId + " jobId:" + jobId) ResourceOperationStatus updateStatus = new ResourceOperationStatus() - updateStatus.setServiceId(serviceId) + updateStatus.setServiceId(nsiId) updateStatus.setOperationId(jobId) - updateStatus.setResourceTemplateUUID(nsiId) + updateStatus.setResourceTemplateUUID(modelUuid) updateStatus.setResourceInstanceID(nssiId) updateStatus.setOperType("Allocate") updateStatus.setProgress("0") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy index 04f07b66d4..c06e313c4c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy @@ -35,6 +35,7 @@ import org.slf4j.Logger import org.slf4j.LoggerFactory import static org.apache.commons.lang3.StringUtils.isBlank +import static org.apache.commons.lang3.StringUtils.isNotBlank class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { @@ -63,7 +64,9 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { }""" execution.setVariable("serviceModelInfo", serviceModelInfo) - tnNssmfUtils.setEnableSdncConfig(execution) + if (isBlank(execution.getVariable("enableSdnc"))) { + tnNssmfUtils.setEnableSdncConfig(execution) + } logger.trace("Exit preProcessRequest") } @@ -110,6 +113,12 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { String ssInstanceId = execution.getVariable("sliceServiceInstanceId") String sliceProfileStr = execution.getVariable("sliceProfile") try { + if (sliceProfileStr == null || sliceProfileStr.isEmpty()) { + String msg = "ERROR: createServiceInstance: sliceProfile is null" + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + org.onap.aai.domain.yang.ServiceInstance ss = new org.onap.aai.domain.yang.ServiceInstance() ss.setServiceInstanceId(ssInstanceId) String sliceInstanceName = execution.getVariable("sliceServiceInstanceName") @@ -125,12 +134,18 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { String modelUuid = execution.getVariable("modelUuid") ss.setModelInvariantId(modelInvariantUuid) ss.setModelVersionId(modelUuid) - String serviceInstanceLocationid = tnNssmfUtils.getFirstPlmnIdFromSliceProfile(sliceProfileStr) - ss.setServiceInstanceLocationId(serviceInstanceLocationid) + String serviceInstanceLocationId = tnNssmfUtils.getFirstPlmnIdFromSliceProfile(sliceProfileStr) + ss.setServiceInstanceLocationId(serviceInstanceLocationId) String snssai = tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr) //ss.setEnvironmentContext(snssai) ss.setEnvironmentContext("tn") ss.setServiceRole(serviceRole) + + String domainTypeStr = jsonUtil.getJsonValue(sliceProfileStr, "domainType") + if (isNotBlank(domainTypeStr)) { + ss.setWorkloadContext(domainTypeStr) + } + AAIResourcesClient client = getAAIClient() AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() @@ -280,25 +295,30 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { List<String> linkStrList = jsonUtil.StringArrayToList(linkArrayStr) for (String linkStr : linkStrList) { - String logicalLinkId = UUID.randomUUID().toString() + String linkName = jsonUtil.getJsonValue(linkStr, "name") + if (isBlank(linkName)) { + linkName = "tn-nssmf-" + UUID.randomUUID().toString() + } + logger.debug("createLogicalLinksForAllocatedResource: linkName=" + linkName) + String epA = jsonUtil.getJsonValue(linkStr, "transportEndpointA") String epB = jsonUtil.getJsonValue(linkStr, "transportEndpointB") String modelInvariantId = execution.getVariable("modelInvariantUuid") String modelVersionId = execution.getVariable("modelUuid") org.onap.aai.domain.yang.LogicalLink resource = new org.onap.aai.domain.yang.LogicalLink() - resource.setLinkId(logicalLinkId) - resource.setLinkName(epA) + resource.setLinkName(linkName) + resource.setLinkId(epA) resource.setLinkName2(epB) resource.setLinkType("TsciConnectionLink") resource.setInMaint(false) //epA is link-name AAIResourceUri logicalLinkUri = - AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(epA)) + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(linkName)) getAAIClient().create(logicalLinkUri, resource) - tnNssmfUtils.attachLogicalLinkToAllottedResource(execution, AAI_VERSION, allottedResourceUri, epA); + tnNssmfUtils.attachLogicalLinkToAllottedResource(execution, AAI_VERSION, allottedResourceUri, linkName); } } catch (BpmnError e) { throw e diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy index a715e7799d..b09161d5cd 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy @@ -38,6 +38,9 @@ import org.onap.so.db.request.beans.ResourceOperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory +import static org.apache.commons.lang3.StringUtils.isBlank +import static org.apache.commons.lang3.StringUtils.isEmpty + class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { String Prefix = "TNDEALLOC_" @@ -68,10 +71,11 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { String sliceServiceInstanceName = execution.getVariable("servicename") execution.setVariable("sliceServiceInstanceName", sliceServiceInstanceName) - String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("modelUuid") - //here modelVersion is not set, we use modelUuid to decompose the service. + if (isEmpty(modelUuid)) { + modelUuid = tnNssmfUtils.getModelUuidFromServiceInstance(execution.getVariable("serviceInstanceID")) + } def isDebugLogEnabled = true execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) String serviceModelInfo = """{ @@ -81,7 +85,13 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { }""" execution.setVariable("serviceModelInfo", serviceModelInfo) - tnNssmfUtils.setEnableSdncConfig(execution) + String additionalPropJsonStr = execution.getVariable("sliceParams") + if (isBlank(additionalPropJsonStr) || + isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution, + additionalPropJsonStr, + "enableSdnc", "enableSdnc"))) { + tnNssmfUtils.setEnableSdncConfig(execution) + } logger.debug("Finish preProcessRequest") } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy index 4ff15a58c5..45af88d253 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy @@ -120,6 +120,11 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { } else { execution.setVariable("nsiInfo", nsiInfo) } + + if (isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution, additionalPropJsonStr, + "enableSdnc", "enableSdnc"))) { + tnNssmfUtils.setEnableSdncConfig(execution) + } } catch (BpmnError e) { throw e } catch (Exception ex) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/QueryJobStatus.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/QueryJobStatus.groovy index 74c9a49911..7bb451164c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/QueryJobStatus.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/QueryJobStatus.groovy @@ -20,11 +20,9 @@ package org.onap.so.bpmn.infrastructure.scripts -import com.fasterxml.jackson.databind.ObjectMapper import groovy.json.JsonSlurper import org.json.JSONObject import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.beans.nsmf.JobStatusRequest import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils @@ -45,7 +43,8 @@ public class QueryJobStatus extends AbstractServiceTaskProcessor{ try{ String requestId = execution.getVariable("msoRequestId") logger.debug("RequestId :" + requestId) - String jobId = execution.getVariable("jobId") + String responseId = execution.getVariable("responseId") + String jobId = execution.getVariable("jobId") def jsonSlurper = new JsonSlurper() HashMap<String,?> esrInfo = jsonSlurper.parseText(execution.getVariable("esrInfo")) @@ -53,7 +52,7 @@ public class QueryJobStatus extends AbstractServiceTaskProcessor{ HashMap<String,?> serviceInfo = jsonSlurper.parseText(execution.getVariable("serviceInfo")) logger.debug("serviceInfo" + serviceInfo.toString()) - + execution.setVariable("esrInfo", esrInfo) execution.setVariable("serviceInfo", serviceInfo) @@ -61,9 +60,10 @@ public class QueryJobStatus extends AbstractServiceTaskProcessor{ String endPoint = String.format("/api/rest/provMns/v1/NSS/jobs/%s", jobId) String url = nssmfEndpoint + endPoint execution.setVariable("NSSMF_AdapterEndpoint", url) - + String payload = """ { + "responseId": "${responseId}", "esrInfo": ${execution.getVariable("esrInfo") as JSONObject}, "serviceInfo": ${execution.getVariable("serviceInfo") as JSONObject} } @@ -72,7 +72,7 @@ public class QueryJobStatus extends AbstractServiceTaskProcessor{ execution.setVariable("NSSMF_AdapterRequest", payload.replaceAll("\\s+", "")) execution.setVariable("startTime", System.currentTimeMillis()) logger.debug("Outgoing NSSMF_AdapterRequest: \n" + payload) - }catch(Exception e){ + }catch(Exception ex){ String msg = "Exception in QueryJobStatus.preProcessRequest " + ex.getMessage() logger.error(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) @@ -107,7 +107,7 @@ public class QueryJobStatus extends AbstractServiceTaskProcessor{ responseDescriptorMap.put("statusDescription","Exception while querying job status") String responseDescriptor = """ { - "responseDescriptor": "${responseDescriptorMap}", + "responseDescriptor": "${responseDescriptorMap as JSONObject}" } """ execution.setVariable("JobStatusCompleted", "TRUE") @@ -123,7 +123,7 @@ public class QueryJobStatus extends AbstractServiceTaskProcessor{ responseDescriptorMap.put("statusDescription","timeout") String responseDescriptor = """ { - "responseDescriptor": "${responseDescriptorMap}", + "responseDescriptor": ${responseDescriptorMap as JSONObject} } """ execution.setVariable("JobStatusCompleted", "TRUE") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy index deeec94b74..019e836514 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy @@ -116,10 +116,10 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { execution.setVariable("nsiInfo", nsiInfoStr) } - //nsiId is passed in from caller bpmn - //String nsiIdStr = jsonUtil.getJsonValue(nsiInfo, "nsiId") - //execution.setVariable("nsiId", nsiIdStr) - + if (isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution, additionalPropJsonStr, + "enableSdnc", "enableSdnc"))) { + tnNssmfUtils.setEnableSdncConfig(execution) + } } catch (BpmnError e) { throw e } catch (Exception ex) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy index 009b0a1941..4877a236f3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy @@ -23,8 +23,11 @@ package org.onap.so.bpmn.infrastructure.scripts import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.ServiceInstance import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils @@ -368,4 +371,62 @@ class TnNssmfUtils { execution.setVariable("enableSdnc", enableSdnc) } -} + + String setExecVarFromJsonIfExists(DelegateExecution execution, + String jsonStr, String jsonKey, String varName) { + return setExecVarFromJsonStr(execution, jsonStr, jsonKey, varName, false) + } + + String setExecVarFromJsonStr(DelegateExecution execution, + String jsonStr, String jsonKey, String varName, + boolean exceptionOnErr) { + String msg = "" + String valueStr = jsonUtil.getJsonValue(jsonStr, jsonKey) + if (isBlank(valueStr)) { + if (exceptionOnErr) { + msg = "cannot find " + jsonKey + " in " + jsonStr + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + } else { + execution.setVariable(varName, valueStr) + } + + return valueStr + } + + ServiceInstance getServiceInstanceFromAai(String serviceInstanceId) { + if (isBlank(serviceInstanceId)) { + logger.error("ERROR: getServiceInstanceFromAai: serviceInstanceId is blank") + return null + } + + ServiceInstance nssi = null + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.Types.SERVICE_INSTANCE + .getFragment(serviceInstanceId)) + Optional<ServiceInstance> nssiOpt = client.get(ServiceInstance.class, uri) + + if (nssiOpt.isPresent()) { + nssi = nssiOpt.get() + return nssi + } else { + String msg = String.format("ERROR: getServiceInstanceFromAai: NSSI %s not found in AAI", serviceInstanceId) + logger.error(msg) + } + + return nssi; + } + + String getModelUuidFromServiceInstance(String serviceInstanceId) { + ServiceInstance si = getServiceInstanceFromAai(serviceInstanceId) + if (si == null) { + String msg = String.format("ERROR: getModelUuidFromServiceInstance: getServiceInstanceFromAai() failed. " + + "serviceInstanceId=%s", serviceInstanceId) + logger.error(msg) + return null + } + + return si.modelVersionId() + } +}
\ No newline at end of file |