diff options
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/main')
13 files changed, 266 insertions, 140 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 1d8de352fb..da9584771c 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 @@ -55,7 +55,7 @@ import org.onap.aai.domain.yang.ServiceInstance import org.onap.aai.domain.yang.SliceProfile import org.onap.aai.domain.yang.SliceProfiles import org.onap.aai.domain.yang.Relationship - +import com.google.gson.Gson class AnNssmfUtils { @@ -193,7 +193,7 @@ public void createSliceProfilesInAai(DelegateExecution execution) { ANNF_sliceProfileInstance.setServiceType(serviceType) String serviceStatus = "deactivated" ANNF_sliceProfileInstance.setOrchestrationStatus(serviceStatus) - String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "pLMNIdList") + String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "plmnIdList") ANNF_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid) String serviceRole = "slice-profile-instance" ANNF_sliceProfileInstance.setServiceRole(serviceRole) @@ -213,7 +213,7 @@ public void createSliceProfilesInAai(DelegateExecution execution) { serviceType = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "sST") TNFH_sliceProfileInstance.setServiceType(serviceType) TNFH_sliceProfileInstance.setOrchestrationStatus(serviceStatus) - serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "pLMNIdList") + serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "plmnIdList") TNFH_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid) TNFH_sliceProfileInstance.setServiceRole(serviceRole) TNFH_sliceProfileInstance.setEnvironmentContext(snssai) @@ -230,7 +230,7 @@ public void createSliceProfilesInAai(DelegateExecution execution) { serviceType = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "sST") TNMH_sliceProfileInstance.setServiceType(serviceType) TNMH_sliceProfileInstance.setOrchestrationStatus(serviceStatus) - serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "pLMNIdList") + serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "plmnIdList") TNMH_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid) TNMH_sliceProfileInstance.setServiceRole(serviceRole) TNMH_sliceProfileInstance.setEnvironmentContext(snssai) @@ -268,7 +268,7 @@ 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, + profile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)//pending fields - maxBandwidth, sST, plmnIdList, cSReliabilityMeanTime, //msgSizeByte, maxNumberofPDUSessions,overallUserDensity,transferIntervalTarget result.setJitter(profile.get("jitter")) result.setLatency(profile.get("latency")) @@ -286,14 +286,14 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe 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) //pending fields - maxBandwidth, sST, plmnIdList result.setJitter(profile.get("jitter")) result.setLatency(profile.get("latency")) 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)//pending fields - maxBandwidth, sST, plmnIdList result.setJitter(profile.get("jitter")) result.setLatency(profile.get("latency")) result.setResourceSharingLevel(profile.get("resourceSharingLevel")) @@ -342,16 +342,17 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe public String buildCreateNSSMFRequest(DelegateExecution execution, String domainType, String action) { JsonObject esrInfo = new JsonObject() - esrInfo.addProperty("networkType", "tn") - esrInfo.addProperty("vendor", "ONAP_internal") + esrInfo.addProperty("networkType", "tn") + esrInfo.addProperty("vendor", "ONAP_internal") JsonObject response = new JsonObject() JsonObject allocateTnNssi = new JsonObject() JsonObject serviceInfo = new JsonObject() JsonArray transportSliceNetworksList = new JsonArray() JsonArray connectionLinksList = new JsonArray() JsonObject connectionLinks = new JsonObject() + Gson jsonConverter = new Gson() if(action.equals("allocate")){ - Map<String, String> endpoints + JsonObject endpoints = new JsonObject() if(domainType.equals("TN_FH")) { serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNFH_modelInvariantUuid")) serviceInfo.addProperty("serviceUuid", execution.getVariable("TNFH_modelUuid")) @@ -359,12 +360,10 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe allocateTnNssi.addProperty("nssiName", execution.getVariable("TNFH_modelName")) Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class) sliceProfile.put("sliceProfileId", execution.getVariable("TNFH_sliceProfileInstanceId")) - String sliceProfileString = objectMapper.writeValueAsString(sliceProfile) - allocateTnNssi.addProperty("sliceProfile", sliceProfileString) - endpoints.put("transportEndpointA", execution.getVariable("tranportEp_ID_RU")) - endpoints.put("transportEndpointB", execution.getVariable("tranportEp_ID_DUIN")) - String endpointsString = objectMapper.writeValueAsString(endpoints) - connectionLinksList.add(endpointsString) + allocateTnNssi.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile)) + endpoints.addProperty("transportEndpointA", execution.getVariable("tranportEp_ID_RU")) + endpoints.addProperty("transportEndpointB", execution.getVariable("tranportEp_ID_DUIN")) + connectionLinksList.add(endpoints) }else if(domainType.equals("TN_MH")) { serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNMH_modelInvariantUuid")) serviceInfo.addProperty("serviceUuid", execution.getVariable("TNMH_modelUuid")) @@ -372,41 +371,32 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe allocateTnNssi.addProperty("nssiName", execution.getVariable("TNMH_modelName")) Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class) sliceProfile.put("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId")) - String sliceProfileString = objectMapper.writeValueAsString(sliceProfile) - allocateTnNssi.addProperty("sliceProfile", sliceProfileString) - endpoints.put("transportEndpointA", execution.getVariable("tranportEp_ID_DUEG")) - endpoints.put("transportEndpointB", execution.getVariable("tranportEp_ID_CUIN")) - String endpointsString = objectMapper.writeValueAsString(endpoints) - connectionLinksList.add(endpointsString) + allocateTnNssi.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile)) + endpoints.addProperty("transportEndpointA", execution.getVariable("tranportEp_ID_DUEG")) + endpoints.addProperty("transportEndpointB", execution.getVariable("tranportEp_ID_CUIN")) + connectionLinksList.add(endpoints) } //Connection links connectionLinks.add("connectionLinks", connectionLinksList) transportSliceNetworksList.add(connectionLinks) allocateTnNssi.add("transportSliceNetworks", transportSliceNetworksList) - allocateTnNssi.addProperty("nssiId", null) - serviceInfo.addProperty("nssiId", null) }else if(action.equals("modify-allocate")) { if(domainType.equals("TN_FH")) { - serviceInfo.addProperty("serviceInvariantUuid", null) - serviceInfo.addProperty("serviceUuid", null) - allocateTnNssi.addProperty("nsstId", null) allocateTnNssi.addProperty("nssiName", execution.getVariable("TNFH_nssiName")) allocateTnNssi.addProperty("sliceProfileId", execution.getVariable("TNFH_sliceProfileInstanceId")) allocateTnNssi.addProperty("nssiId", execution.getVariable("TNFH_NSSI")) serviceInfo.addProperty("nssiId", execution.getVariable("TNFH_NSSI")) }else if(domainType.equals("TN_MH")) { - serviceInfo.addProperty("serviceInvariantUuid", null) - serviceInfo.addProperty("serviceUuid", null) - allocateTnNssi.addProperty("nsstId", null) allocateTnNssi.addProperty("nssiName", execution.getVariable("TNMH_nssiName")) allocateTnNssi.addProperty("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId")) allocateTnNssi.addProperty("nssiId", execution.getVariable("TNMH_NSSI")) serviceInfo.addProperty("nssiId", execution.getVariable("TNMH_NSSI")) } } + JsonParser parser = new JsonParser() String nsiInfo = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "nsiInfo") - allocateTnNssi.addProperty("nsiInfo", nsiInfo) + allocateTnNssi.add("nsiInfo",(JsonObject) parser.parse(nsiInfo)) allocateTnNssi.addProperty("scriptName", "TN1") serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId")) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy index 8cab146006..b94c81b41f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy @@ -215,11 +215,12 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution) - String basicAuthValue = utils.encrypt(basicAuth, msoKey) - String encodeString = utils.getBasicAuth(basicAuthValue, msoKey) +// String basicAuthValue = utils.encrypt(basicAuth, msoKey) +// String encodeString = utils.getBasicAuth(basicAuthValue, msoKey) HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) - httpClient.addAdditionalHeader("Authorization", encodeString) +// httpClient.addAdditionalHeader("Authorization", encodeString) + httpClient.addAdditionalHeader("Authorization", basicAuth) httpClient.addAdditionalHeader("Accept", "application/json") Response httpResponse = httpClient.delete(requestBody) handleNSSMFWFResponse(httpResponse, execution) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy index 4c008a2eb9..8c04675193 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy @@ -20,6 +20,8 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.aaiclient.client.aai.entities.uri.AAISimpleUri + import static org.apache.commons.lang3.StringUtils.isBlank import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.BpmnError @@ -176,11 +178,11 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { ServiceProfile serviceProfile = serviceProfiles.getServiceProfile().get(0) profileId = serviceProfile ? serviceProfile.getProfileId() : "" } - resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId).serviceProfile(profileId)) - if (!getAAIClient().exists(resourceUri)) { + AAISimpleUri profileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId).serviceProfile(profileId)) + if (!getAAIClient().exists(profileUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } - getAAIClient().delete(resourceUri) + getAAIClient().delete(profileUri) } catch (any) { 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 05996d3671..f3f8c8bacf 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 @@ -83,6 +83,7 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor { String actionType = operationType.equals("activateInstance") ? "activate" : "deactivate" execution.setVariable("actionType", actionType) + tnNssmfUtils.setEnableSdncConfig(execution) logger.debug("Finish preProcessRequest") } @@ -142,20 +143,17 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor { String status, String progress, String statusDescription) { - String serviceId = execution.getVariable("sliceServiceInstanceId") + String ssInstanceId = execution.getVariable("sliceServiceInstanceId") + String modelUuid = execution.getVariable("modelUuid") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") String operType = execution.getVariable("actionType") + operType = operType.toUpperCase() + + ResourceOperationStatus roStatus = tnNssmfUtils.buildRoStatus(modelUuid, ssInstanceId, + jobId, nsiId, operType, status, progress, statusDescription) - ResourceOperationStatus roStatus = new ResourceOperationStatus() - roStatus.setServiceId(serviceId) - roStatus.setOperationId(jobId) - roStatus.setResourceTemplateUUID(nsiId) - roStatus.setOperType(operType) - roStatus.setProgress(progress) - roStatus.setStatus(status) - roStatus.setStatusDescription(statusDescription) requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } 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 e1719aa5d6..33724bd011 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 @@ -34,6 +34,7 @@ import org.slf4j.LoggerFactory import java.util.List import static org.apache.commons.lang3.StringUtils.isBlank import com.google.gson.JsonObject +import com.google.gson.Gson import com.fasterxml.jackson.databind.ObjectMapper import com.google.gson.JsonArray import com.google.gson.JsonParser @@ -98,8 +99,8 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { execution.setVariable("sliceProfile", sliceProfile) } String sliceProfileId = jsonUtil.getJsonValue(sliceProfile, "sliceProfileId") - def snssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "sNSSAI")) - def plmnIdList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "pLMNIdList")) + def snssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "snssaiList")) + def plmnIdList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "plmnIdList")) def coverageAreaTAList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "coverageAreaTAList")) if (isBlank(sliceProfileId) || (snssaiList.empty) || (plmnIdList.empty) @@ -577,7 +578,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { def createSdnrRequest = { DelegateExecution execution -> logger.debug(Prefix+"createSdnrRequest method start") String callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.message.endpoint") + "/AsyncSdnrResponse/"+execution.getVariable("msoRequestId") - String sdnrRequest = buildSdnrAllocateRequest(execution, "allocate", "InstantiateRANSlice", callbackUrl) + String sdnrRequest = buildSdnrAllocateRequest(execution, "allocate", "instantiateRANSlice", callbackUrl) execution.setVariable("createNSSI_sdnrRequest", sdnrRequest) execution.setVariable("createNSSI_timeout", "PT10M") execution.setVariable("createNSSI_correlator", execution.getVariable("msoRequestId")) @@ -697,12 +698,12 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { } def createFhAllocateNssiJobQuery = { DelegateExecution execution -> - logger.debug(Prefix+"createModifyNssiQueryJobStatus method start") + logger.debug(Prefix+"createFhAllocateNssiJobQuery method start") createTnAllocateNssiJobQuery(execution, "TN_FH") } def createMhAllocateNssiJobQuery = { DelegateExecution execution -> - logger.debug(Prefix+"createModifyNssiQueryJobStatus method start") + logger.debug(Prefix+"createMhAllocateNssiJobQuery method start") createTnAllocateNssiJobQuery(execution, "TN_MH") } @@ -712,7 +713,6 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { esrInfo.addProperty("vendor", "ONAP_internal") execution.setVariable("esrInfo", esrInfo.toString()) JsonObject serviceInfo = new JsonObject() - serviceInfo.addProperty("nssiId", null) serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) String sST = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST") serviceInfo.addProperty("sST", sST) @@ -736,14 +736,14 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug(Prefix+"processJobStatusRsp method start") String jobResponse = execution.getVariable("TNFH_jobResponse") logger.debug("Job status response "+jobResponse) - String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status") - String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi") + String status = jsonUtil.getJsonValue(jobResponse, "status") + String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId") if(status.equalsIgnoreCase("finished")) { execution.setVariable("TNFH_NSSI", nssi) logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi) } else { - String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription") + String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription") logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) } @@ -753,14 +753,14 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug(Prefix+"processJobStatusRsp method start") String jobResponse = execution.getVariable("TNMH_jobResponse") logger.debug("Job status response "+jobResponse) - String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status") - String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi") + String status = jsonUtil.getJsonValue(jobResponse, "status") + String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId") if(status.equalsIgnoreCase("finished")) { execution.setVariable("TNMH_NSSI", nssi) logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi) } else { - String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription") + String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription") logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) } @@ -770,13 +770,13 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug(Prefix+"processJobStatusRsp method start") String jobResponse = execution.getVariable("jobResponse") logger.debug("Job status response "+jobResponse) - String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status") - String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi") + String status = jsonUtil.getJsonValue(jobResponse, "status") + String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId") if(status.equalsIgnoreCase("finished")) { logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi) } else { - String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription") + String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription") logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) } @@ -899,29 +899,30 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSessions")) sliceProfile.put("uLThptPerSlice", sliceProfile.get("expDataRateUL")) sliceProfile.put("dLThptPerSlice", sliceProfile.get("expDataRateDL")) - String sliceProfileString = objectMapper.writeValueAsString(sliceProfile) + JsonObject response = new JsonObject() JsonObject body = new JsonObject() JsonObject input = new JsonObject() JsonObject commonHeader = new JsonObject() JsonObject payload = new JsonObject() JsonObject payloadInput = new JsonObject() - commonHeader.addProperty("TimeStamp",new Date(System.currentTimeMillis()).format("yyyy-MM-dd'T'HH:mm:ss.sss", TimeZone.getDefault())) - commonHeader.addProperty("APIver", "1.0") - commonHeader.addProperty("RequestID", requestId) - commonHeader.addProperty("SubRequestID", "1") - commonHeader.add("RequestTrack", new JsonObject()) - commonHeader.add("Flags", new JsonObject()) - payloadInput.addProperty("sliceProfile", sliceProfileString) + commonHeader.addProperty("TimeStamp",new Date(System.currentTimeMillis()).format("yyyy-MM-dd'T'HH:mm:ss.sss'Z'", TimeZone.getDefault())) + commonHeader.addProperty("api-ver", "1.0") + commonHeader.addProperty("request-id", requestId) + commonHeader.addProperty("sub-request-id", "1") + commonHeader.add("request-track", new JsonObject()) + commonHeader.add("flags", new JsonObject()) + Gson jsonConverter = new Gson() + payloadInput.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile)) payloadInput.addProperty("RANNSSIId", execution.getVariable("RANServiceInstanceId")) payloadInput.addProperty("NSIID", execution.getVariable("nsiId")) payloadInput.addProperty("RANNFNSSIId", execution.getVariable("RANNFServiceInstanceId")) payloadInput.addProperty("callbackURL", callbackUrl) payloadInput.add("additionalproperties", new JsonObject()) payload.add("input", payloadInput) - input.add("CommonHeader", commonHeader) - input.addProperty("Action", action) - input.addProperty("Payload", payload.toString()) + input.add("common-header", commonHeader) + input.addProperty("action", action) + input.addProperty("payload", payload.toString()) body.add("input", input) response.add("body", body) response.addProperty("version", "1.0") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy index 0311c3d856..059a209336 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy @@ -394,6 +394,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ AllocateAnNssi allocateAnNssi = new AllocateAnNssi() allocateAnNssi.sliceProfile = sliceTaskInfo.sliceProfile.trans2AnProfile() + allocateAnNssi.sliceProfile.sliceProfileId = sliceTaskInfo.sliceInstanceId allocateAnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID allocateAnNssi.nssiId = sliceTaskInfo.suggestNssiId allocateAnNssi.nssiName = "nssi_an" + execution.getVariable("sliceServiceInstanceName") @@ -537,6 +538,8 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ allocateCnNssi.nssiId = sliceTaskInfo.suggestNssiId allocateCnNssi.nssiName = "nssi_cn" + execution.getVariable("sliceServiceInstanceName") allocateCnNssi.sliceProfile = sliceTaskInfo.sliceProfile.trans2CnProfile() + allocateCnNssi.sliceProfile.sliceProfileId = sliceTaskInfo.sliceInstanceId + NsiInfo nsiInfo = new NsiInfo() nsiInfo.nsiId = sliceParams.suggestNsiId nsiInfo.nsiName = sliceParams.suggestNsiName 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 4eb70a5302..04f07b66d4 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 @@ -34,6 +34,8 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.slf4j.Logger import org.slf4j.LoggerFactory +import static org.apache.commons.lang3.StringUtils.isBlank + class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger(DoCreateTnNssiInstance.class); @@ -61,6 +63,8 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { }""" execution.setVariable("serviceModelInfo", serviceModelInfo) + tnNssmfUtils.setEnableSdncConfig(execution) + logger.trace("Exit preProcessRequest") } @@ -109,15 +113,18 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { org.onap.aai.domain.yang.ServiceInstance ss = new org.onap.aai.domain.yang.ServiceInstance() ss.setServiceInstanceId(ssInstanceId) String sliceInstanceName = execution.getVariable("sliceServiceInstanceName") + if (isBlank(sliceInstanceName)) { + logger.error("ERROR: createServiceInstance: sliceInstanceName is null") + sliceInstanceName = ssInstanceId + } ss.setServiceInstanceName(sliceInstanceName) ss.setServiceType(serviceType) - String serviceStatus = "activated" + String serviceStatus = "deactivated" ss.setOrchestrationStatus(serviceStatus) String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("modelUuid") - //TODO: need valid model ID from the caller, as AAI does not accept invalid IDs - //ss.setModelInvariantId(modelInvariantUuid) - //ss.setModelVersionId(modelUuid) + ss.setModelInvariantId(modelInvariantUuid) + ss.setModelVersionId(modelUuid) String serviceInstanceLocationid = tnNssmfUtils.getFirstPlmnIdFromSliceProfile(sliceProfileStr) ss.setServiceInstanceLocationId(serviceInstanceLocationid) String snssai = tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy index f3bc47e7cf..147e623ece 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy @@ -21,25 +21,26 @@ package org.onap.so.bpmn.infrastructure.scripts import com.fasterxml.jackson.databind.ObjectMapper import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.SliceProfiles +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAISimpleUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder -import org.onap.so.beans.nsmf.DeAllocateNssi -import org.onap.so.beans.nsmf.EsrInfo -import org.onap.so.beans.nsmf.NetworkType -import org.onap.so.beans.nsmf.NssiResponse -import org.onap.so.beans.nsmf.ServiceInfo +import org.onap.so.beans.nsmf.* +import org.onap.so.beans.nsmf.oof.SubnetType import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils import org.onap.so.bpmn.common.scripts.RequestDBUtil -import org.onap.so.bpmn.core.domain.ServiceArtifact import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.db.request.beans.OperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory +import javax.ws.rs.NotFoundException class DoDeallocateNSSI extends AbstractServiceTaskProcessor { @@ -103,15 +104,13 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor try { ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") as ServiceDecomposition - ServiceArtifact serviceArtifact = serviceDecomposition ?.getServiceInfo()?.getServiceArtifact()?.get(0) - String content = serviceArtifact.getContent() - String vendor = jsonUtil.getJsonValue(content, "metadata.vendor") - String domainType = jsonUtil.getJsonValue(content, "metadata.domainType") + String vendor = serviceDecomposition ?.getServiceRole() + NetworkType domainType = convertServiceCategory(serviceDecomposition.getServiceCategory()) def currentNSSI = execution.getVariable("currentNSSI") currentNSSI['vendor'] = vendor currentNSSI['domainType'] = domainType - LOGGER.info("processDecomposition, current vendor-domainType:" +String.join("-", vendor, domainType)) + LOGGER.info("processDecomposition, current vendor-domainType:" +String.join("-", vendor, domainType.toString())) } catch (any) { String exceptionMessage = "Bpmn error encountered in deallocate nssi. processDecomposition() - " + any.getMessage() @@ -120,6 +119,27 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor } LOGGER.debug("*****${PREFIX} Exit processDecomposition *****") } + + + /** + * get subnetType from serviceCategory + * @return + */ + private NetworkType convertServiceCategory(String serviceCategory){ + if(serviceCategory ==~ /CN.*/){ + return SubnetType.CN.getNetworkType() + } + if (serviceCategory ==~ /AN.*NF.*/){ + return SubnetType.AN.getNetworkType() + } + if (serviceCategory ==~ /TN.*BH.*/){ + return SubnetType.TN_BH.getNetworkType() + } + if(serviceCategory ==~ /TN.*MH.*/){ + return SubnetType.TN_MH.getNetworkType() + } + return null + } /** * send deallocate request to nssmf @@ -136,9 +156,9 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor String scriptName = execution.getVariable("scriptName") String serviceInvariantUuid = currentNSSI['modelInvariantId'] - String serviceUuid = currentNSSI['modelId'] + String serviceUuid = currentNSSI['modelVersionId'] String globalSubscriberId = currentNSSI['globalSubscriberId'] - String subscriptionServiceType = execution.getVariable("serviceType") + String subscriptionServiceType = currentNSSI['serviceType'] DeAllocateNssi deAllocateNssi = new DeAllocateNssi() deAllocateNssi.setNsiId(nsiId) @@ -191,8 +211,6 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor { def currentNSSI = execution.getVariable("currentNSSI") String jobId = currentNSSI['jobId'] - - execution.setVariable("responseId", "3") execution.setVariable("jobId", jobId) } @@ -245,11 +263,11 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor private EsrInfo getEsrInfo(def currentNSSI) { - String domaintype = currentNSSI['domainType'] + NetworkType domainType = currentNSSI['domainType'] String vendor = currentNSSI['vendor'] EsrInfo info = new EsrInfo() - info.setNetworkType(NetworkType.fromString(domaintype)) + info.setNetworkType(domainType) info.setVendor(vendor) return info } @@ -264,17 +282,17 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor def currentNSSI = execution.getVariable("currentNSSI") int currentProgress = currentNSSI["jobProgress"] def proportion = currentNSSI['proportion'] - def statusDes = currentNSSI["statusDescription"] int progress = (currentProgress as int) == 0 ? 0 : (currentProgress as int) / 100 * (proportion as int) def status = currentNSSI['status'] - + + OperationStatus operationStatus = new OperationStatus() operationStatus.setServiceId(currentNSSI['e2eServiceInstanceId'] as String) operationStatus.setOperationId(currentNSSI['operationId'] as String) operationStatus.setOperation("DELETE") - operationStatus.setResult(status as String) + operationStatus.setResult("processing") operationStatus.setProgress(progress as String) - operationStatus.setOperationContent(statusDes as String) + operationStatus.setOperationContent(currentNSSI['domainType'].toString() + " " + status.toString()) requestDBUtil.prepareUpdateOperationStatus(execution, operationStatus) LOGGER.debug("update operation, currentProgress=${currentProgress}, proportion=${proportion}, progress = ${progress}" ) } @@ -283,20 +301,20 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * delete slice profile from aai * @param execution */ - void delSliceProfileFromAAI(DelegateExecution execution) + void delSliceProfileServiceFromAAI(DelegateExecution execution) { LOGGER.debug("*****${PREFIX} start delSliceProfileFromAAI *****") def currentNSSI = execution.getVariable("currentNSSI") String nssiServiceInstanceId = currentNSSI['nssiServiceInstanceId'] String profileId = currentNSSI['profileId'] String globalSubscriberId = currentNSSI["globalSubscriberId"] - String serviceType = execution.getVariable("serviceType") + String serviceType = currentNSSI['serviceType'] try { LOGGER.debug("delete nssiServiceInstanceId:${nssiServiceInstanceId}, profileId:${profileId}") AAIResourceUri resourceUri = AAIUriFactory.createResourceUri( - AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiServiceInstanceId).sliceProfile(profileId)) + AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(profileId)) if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } @@ -310,4 +328,41 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor } LOGGER.debug("*****${PREFIX} Exist delSliceProfileFromAAI *****") } + + void delSliceProfileFromAAI(DelegateExecution execution){ + + LOGGER.debug("*****${PREFIX} start delSliceProfileFromAAI *****") + def currentNSSI = execution.getVariable("currentNSSI") + String globalSubscriberId = currentNSSI["globalSubscriberId"] + String serviceType = currentNSSI['serviceType'] + String sliceProfileInstId = currentNSSI['profileId'] + + try + { + AAIPluralResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(sliceProfileInstId).sliceProfiles()) + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) + Optional<SliceProfiles> sliceProfilesOpt =wrapper.asBean(SliceProfiles.class) + SliceProfiles sliceProfiles + String profileId + if(sliceProfilesOpt.isPresent()){ + sliceProfiles = sliceProfilesOpt.get() + org.onap.aai.domain.yang.SliceProfile sliceProfile = sliceProfiles.getSliceProfile().get(0) + profileId = sliceProfile ? sliceProfile.getProfileId() : "" + } + if (profileId){ + AAISimpleUri profileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(sliceProfileInstId).sliceProfile(profileId)) + if (!getAAIClient().exists(profileUri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") + } + getAAIClient().delete(profileUri) + } + + } + catch (any) + { + String msg = "delete service profile from aai failed! cause-"+any.getCause() + LOGGER.error(any.printStackTrace()) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); + } + } } 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 c817eaad61..a715e7799d 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 @@ -25,7 +25,6 @@ import groovy.json.JsonSlurper import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.ServiceInstance -import org.onap.aaiclient.client.aai.AAIObjectType 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 @@ -81,6 +80,9 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { "modelVersion":"" }""" execution.setVariable("serviceModelInfo", serviceModelInfo) + + tnNssmfUtils.setEnableSdncConfig(execution) + logger.debug("Finish preProcessRequest") } @@ -150,18 +152,15 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { String status, String progress, String statusDescription) { - String serviceId = execution.getVariable("sliceServiceInstanceId") + String ssInstanceId = execution.getVariable("sliceServiceInstanceId") + String modelUuid = execution.getVariable("modelUuid") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") - ResourceOperationStatus roStatus = new ResourceOperationStatus() - roStatus.setServiceId(serviceId) - roStatus.setOperationId(jobId) - roStatus.setResourceTemplateUUID(nsiId) - roStatus.setOperType("Deallocate") - roStatus.setProgress(progress) - roStatus.setStatus(status) - roStatus.setStatusDescription(statusDescription) + ResourceOperationStatus roStatus = tnNssmfUtils.buildRoStatus(modelUuid, ssInstanceId, + jobId, nsiId, "DEALLOCATE", status, progress, statusDescription) + + logger.debug("DoDeallocateTnNssi: roStatus={}", roStatus) requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy index c4321220fd..2889f79c30 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy @@ -19,6 +19,9 @@ */ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.aai.domain.yang.SliceProfiles +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri + import static org.apache.commons.lang3.StringUtils.isBlank import javax.ws.rs.NotFoundException import javax.ws.rs.core.Response @@ -99,7 +102,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { * save snssai * @param execution */ - void queryE2ESliceSeriveFromAAI(DelegateExecution execution) + void queryServiceProfileFromAAI(DelegateExecution execution) { LOGGER.trace(" *****${PREFIX} Start queryE2ESliceSeriveFromAAI *****") String serviceInstanceId = execution.getVariable("serviceInstanceId") @@ -111,11 +114,11 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { if(si.isPresent()) { String snssai = si.get()?.getEnvironmentContext() - ServiceProfiles serviceProfiles = si.get()?.getServiceProfiles() - ServiceProfile serviceProfile = serviceProfiles.getServiceProfile().get(0) - String serviceProfileId = serviceProfile ? serviceProfile.getProfileId() : "" execution.setVariable("snssai", snssai ?: "") - execution.setVariable("serviceProfileId",serviceProfileId) +// ServiceProfiles serviceProfiles = si.get()?.getServiceProfiles() +// ServiceProfile serviceProfile = serviceProfiles.getServiceProfile().get(0) +// String serviceProfileId = serviceProfile ? serviceProfile.getProfileId() : "" +// execution.setVariable("serviceProfileId", serviceProfileId) List<ServiceInstance> sliceProfileList = [] List<Relationship> relationshipList = si.get().getRelationshipList().getRelationship() for (Relationship relationship : relationshipList) { @@ -127,7 +130,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { Optional<ServiceInstance> serviceInstance = wrapper1.asBean(ServiceInstance.class) if (serviceInstance.isPresent()) { ServiceInstance instance = serviceInstance.get() - if ("slice-profile-instance".equalsIgnoreCase(instance.getServiceRole())) { + if ("slice-profile".equalsIgnoreCase(instance.getServiceRole())) { sliceProfileList.add(instance) } } @@ -158,7 +161,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { try { String errorMsg = "query allotted resource from aai failed." - AAIResultWrapper wrapper = queryAAI(execution, Types.ALLOTTED_RESOURCES, serviceInstanceId, errorMsg) + AAIResultWrapper wrapper = queryAAI(execution, Types.ALLOTTED_RESOURCE, serviceInstanceId, errorMsg) Optional<AllottedResources> ars = wrapper?.asBean(AllottedResources.class) if(ars.isPresent() && ars.get().getAllottedResource()) { @@ -209,6 +212,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { String instanceId = relatedLink ? relatedLink.substring(relatedLink.lastIndexOf("/") + 1,relatedLink.length()) : "" AAIResultWrapper wrapper1 = queryAAI(execution, Types.SERVICE_INSTANCE, instanceId, errorMsg) Optional<ServiceInstance> serviceInstance = wrapper1.asBean(ServiceInstance.class) + def nssiId if (serviceInstance.isPresent()) { ServiceInstance instance = serviceInstance.get() if ("nssi".equalsIgnoreCase(instance.getServiceRole())) { @@ -274,14 +278,39 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { List<ServiceInstance> nssiInstanceList = execution.getVariable("nssiInstanceList") List<ServiceInstance> sliceProfileList = execution.getVariable("sliceProfileList") int currentIndex = execution.getVariable("currentNSSIIndex") as int - String profileId = "" + String profileInstId = "" ServiceInstance nssi = nssiInstanceList?.get(currentIndex) + List<Relationship> relationshipList = nssi.getRelationshipList()?.getRelationship() for(ServiceInstance sliceProfileInstance : sliceProfileList) { - if(sliceProfileInstance.getWorkloadContext().equalsIgnoreCase(nssi.getWorkloadContext())) - { - profileId = sliceProfileInstance.getServiceInstanceId() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo == "service-instance"){ + String relatedLink = relationship.getRelatedLink()?:"" + String instanceId = relatedLink ? relatedLink.substring(relatedLink.lastIndexOf("/") + 1,relatedLink.length()) : "" + if(instanceId.equals(sliceProfileInstance.getServiceInstanceId())){ + profileInstId = sliceProfileInstance.getServiceInstanceId() + break + } + } + } + if(profileInstId){ + break } } + + //@TODO Temp begin******************* +// AAIPluralResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("serviceType")).serviceInstance(profileInstId).sliceProfiles()) +// AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) +// Optional<SliceProfiles> sliceProfilesOpt =wrapper.asBean(SliceProfiles.class) +// SliceProfiles sliceProfiles +// String sliceProfileId +// if(sliceProfilesOpt.isPresent()){ +// sliceProfiles = sliceProfilesOpt.get() +// org.onap.aai.domain.yang.SliceProfile sliceProfile = sliceProfiles.getSliceProfile().get(0) +// sliceProfileId = sliceProfile ? sliceProfile.getProfileId() : "" +// } + //@TODO Temp end******************* + def currentNSSI = [:] currentNSSI['nssiServiceInstanceId'] = nssi?.getServiceInstanceId() currentNSSI['modelInvariantId'] = nssi?.getModelInvariantId() @@ -289,7 +318,10 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { currentNSSI['nssiName'] = nssi?.getServiceInstanceName() currentNSSI['sST'] = nssi?.getServiceType() currentNSSI['PLMNIdList'] = nssi?.getServiceInstanceLocationId() - currentNSSI['profileId'] = profileId + //@TODO Temp + + currentNSSI['profileId'] = profileInstId +// currentNSSI['profileId'] = sliceProfileId currentNSSI['snssai'] = execution.getVariable("snssai") ?: "" currentNSSI['nsiServiceInstanceId'] = execution.getVariable("nsiId") ?: "" currentNSSI['operationId'] = execution.getVariable("operationId") ?: "" @@ -343,7 +375,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { org.onap.aaiclient.client.generated.fluentbuilders.ServiceInstance serviceInstanceType = AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(instanceId) def type - if (aaiObjectName == Types.ALLOTTED_RESOURCES) { + if (aaiObjectName == Types.ALLOTTED_RESOURCE) { type = serviceInstanceType.allottedResources() } else if (aaiObjectName == Types.SLICE_PROFILES) { type = serviceInstanceType.sliceProfiles() @@ -361,8 +393,10 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { void terminateNSIQuery(DelegateExecution execution) { - logger.debug("Start terminateNSIQuery") - + LOGGER.debug("Start terminateNSIQuery") + + return + //To test String requestId = execution.getVariable("msoRequestId") String nxlId = currentNSSI['nsiServiceInstanceId'] String nxlType = "NSI" @@ -375,17 +409,17 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { String basicAuthValue = utils.encrypt(basicAuth, msokey) if (basicAuthValue != null) { - logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue) + LOGGER.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue) try { authHeader = utils.getBasicAuth(basicAuthValue, msokey) execution.setVariable("BasicAuthHeaderValue", authHeader) } catch (Exception ex) { - logger.debug( "Unable to encode username and password string: " + ex) + LOGGER.debug( "Unable to encode username and password string: " + ex) exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " + "encode username and password string") } } else { - logger.debug( "Unable to obtain BasicAuth - BasicAuth value null") + LOGGER.debug( "Unable to obtain BasicAuth - BasicAuth value null") exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " + "value null") } @@ -397,7 +431,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { Response httpResponse = httpClient.post(oofRequest) int responseCode = httpResponse.getStatus() - logger.debug("OOF sync response code is: " + responseCode) + LOGGER.debug("OOF sync response code is: " + responseCode) if(responseCode != 200){ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") @@ -407,9 +441,9 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { boolean terminateResponse = resMap.get("terminateResponse") execution.setVariable("terminateNSI", terminateResponse) } catch (Exception ex) { - logger.debug( "Failed to get terminate Response suggested by OOF.") + LOGGER.debug( "Failed to get terminate Response suggested by OOF.") exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Failed to get terminate Response suggested by OOF.") } - logger.debug("Finish terminateNSIQuery") + LOGGER.debug("Finish terminateNSIQuery") } } 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 5cdf540173..74c9a49911 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,9 +20,11 @@ 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 @@ -43,16 +45,15 @@ public class QueryJobStatus extends AbstractServiceTaskProcessor{ try{ String requestId = execution.getVariable("msoRequestId") logger.debug("RequestId :" + requestId) - String responseId = execution.getVariable("responseId") - String jobId = execution.getVariable("jobId") + String jobId = execution.getVariable("jobId") def jsonSlurper = new JsonSlurper() - HashMap<String,?> esrInfo=jsonSlurper.parseText(execution.getVariable("esrInfo")) + HashMap<String,?> esrInfo = jsonSlurper.parseText(execution.getVariable("esrInfo")) logger.debug("esrInfo" + esrInfo.toString()) - HashMap<String,?> serviceInfo=jsonSlurper.parseText(execution.getVariable("serviceInfo")) + HashMap<String,?> serviceInfo = jsonSlurper.parseText(execution.getVariable("serviceInfo")) logger.debug("serviceInfo" + serviceInfo.toString()) - + execution.setVariable("esrInfo", esrInfo) execution.setVariable("serviceInfo", serviceInfo) @@ -60,10 +61,9 @@ 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} } 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 88db2161f7..deeec94b74 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 @@ -72,7 +72,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { String additionalPropJsonStr = execution.getVariable("sliceParams") - String tnNssiId = execution.getVariable("serviceInstanceID") + String tnNssiId = jsonUtil.getJsonValue(additionalPropJsonStr, "serviceInstanceID") //for debug if (isBlank(tnNssiId)) { tnNssiId = UUID.randomUUID().toString() } 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 d97f416db9..009b0a1941 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 @@ -32,6 +32,7 @@ import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -122,7 +123,7 @@ class TnNssmfUtils { } String sdncRequest = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1" + """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1"> <sdncadapter:RequestHeader> @@ -332,4 +333,39 @@ class TnNssmfUtils { createRelationShipInAAI(execution, aaiResourceUri, relationship) } + + ResourceOperationStatus buildRoStatus(String nsstId, + String nssiId, + String jobId, + String nsiId, + String action, + String status, + String progress, + String statusDescription) { + ResourceOperationStatus roStatus = new ResourceOperationStatus() + roStatus.setResourceTemplateUUID(nsstId) + roStatus.setResourceInstanceID(nssiId) + roStatus.setServiceId(nsiId) + roStatus.setOperationId(jobId) + roStatus.setOperType(action) + roStatus.setProgress(progress) + roStatus.setStatus(status) + roStatus.setStatusDescription(statusDescription) + + return roStatus + } + + + void setEnableSdncConfig(DelegateExecution execution) { + String enableSdnc = UrnPropertiesReader.getVariable( + "mso.workflow.TnNssmf.enableSDNCNetworkConfig") + if (isBlank(enableSdnc)) { + logger.debug("mso.workflow.TnNssmf.enableSDNCNetworkConfig is undefined, so use default value (true)") + enableSdnc = "true" + } + + logger.debug("setEnableSdncConfig: enableSdnc=" + enableSdnc) + + execution.setVariable("enableSdnc", enableSdnc) + } } |