diff options
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common')
8 files changed, 155 insertions, 100 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 a812b37879..07a23481d7 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 @@ -356,12 +356,15 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe JsonArray connectionLinksList = new JsonArray() JsonObject connectionLinks = new JsonObject() Gson jsonConverter = new Gson() + String TNFH_nssiInstanceId = UUID.randomUUID().toString() + String TNMH_nssiInstanceId = UUID.randomUUID().toString() + if(action.equals("allocate")){ JsonObject endpoints = new JsonObject() if(domainType.equals("TN_FH")) { serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNFH_modelInvariantUuid")) serviceInfo.addProperty("serviceUuid", execution.getVariable("TNFH_modelUuid")) - serviceInfo.addProperty("nssiName", "nssi_"+execution.getVariable("TNFH_modelName")) + serviceInfo.addProperty("nssiName", "nssi_tn_fh_"+TNFH_nssiInstanceId) serviceInfo.addProperty("sst", execution.getVariable("sst")) allocateTnNssi.addProperty("nsstId", execution.getVariable("TNFH_modelUuid")) allocateTnNssi.addProperty("nssiName", execution.getVariable("TNFH_modelName")) @@ -374,7 +377,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", "nssi_"+execution.getVariable("TNMH_modelName")) + serviceInfo.addProperty("nssiName", "nssi_tn_mh_"+TNMH_nssiInstanceId) serviceInfo.addProperty("sst", execution.getVariable("sst")) allocateTnNssi.addProperty("nsstId", execution.getVariable("TNMH_modelUuid")) allocateTnNssi.addProperty("nssiName", execution.getVariable("TNMH_modelName")) @@ -435,15 +438,15 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe public String buildDeallocateNssiRequest(DelegateExecution execution,String domainType) { String globalSubscriberId = execution.getVariable("globalSubscriberId") String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + List<String> sNssaiList = execution.getVariable("snssaiList") + + DeAllocateNssi deallocateNssi = new DeAllocateNssi() + deallocateNssi.setNsiId(execution.getVariable("nsiId")) + deallocateNssi.setScriptName("TN1") + deallocateNssi.setSnssaiList(sNssaiList) + deallocateNssi.setTerminateNssiOption(0) - JsonObject deAllocateNssi = new JsonObject() - deAllocateNssi.addProperty("snssaiList", execution.getVariable("snssaiList")) - deAllocateNssi.addProperty("nsiId", execution.getVariable("nsiId")) - deAllocateNssi.addProperty("modifyAction", true) - deAllocateNssi.addProperty("terminateNssiOption", 0) - deAllocateNssi.addProperty("scriptName", "TN1") - - JsonObject esrInfo = new JsonObject() esrInfo.addProperty("networkType", "tn") esrInfo.addProperty("vendor", "ONAP_internal") @@ -451,19 +454,21 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe JsonObject serviceInfo = new JsonObject() serviceInfo.addProperty("globalSubscriberId", globalSubscriberId) serviceInfo.addProperty("subscriptionServiceType", subscriptionServiceType) - + serviceInfo.addProperty("modifyAction", true) + if(domainType.equals("TN_FH")) { - deAllocateNssi.addProperty("nssiId", execution.getVariable("TNFH_NSSI")) + deallocateNssi.setNssiId(execution.getVariable("TNFH_NSSI")) + deallocateNssi.setSliceProfileId(execution.getVariable("TNFH_sliceProfileInstanceId")) serviceInfo.addProperty("nssiId", execution.getVariable("TNFH_NSSI")) - deAllocateNssi.addProperty("sliceProfileId", execution.getVariable("TNFH_sliceProfileInstanceId")) }else if(domainType.equals("TN_MH")) { - deAllocateNssi.addProperty("nssiId", execution.getVariable("TNMH_NSSI")) + deallocateNssi.setNssiId(execution.getVariable("TNMH_NSSI")) + deallocateNssi.setSliceProfileId(execution.getVariable("TNMH_sliceProfileInstanceId")) serviceInfo.addProperty("nssiId", execution.getVariable("TNMH_NSSI")) - deAllocateNssi.addProperty("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId")) } JsonObject json = new JsonObject() - json.add("deAllocateNssi", deAllocateNssi) + Gson jsonConverter = new Gson() + json.add("deAllocateNssi", jsonConverter.toJsonTree(deallocateNssi)) json.add("esrInfo", esrInfo) json.add("serviceInfo", serviceInfo) return json.toString() 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 2564b11295..d5c132087c 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 @@ -643,7 +643,8 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug("completed AN service instance build "+ ANServiceInstance.toString()) //create RAN NF NSSI ANNFServiceInstance.setServiceInstanceId(execution.getVariable("RANNFServiceInstanceId")) - sliceInstanceName = "nssi_"+execution.getVariable("ANNF_modelName") + String ANNF_nssiInstanceId = UUID.randomUUID().toString() + sliceInstanceName = "nssi_an_nf_"+ANNF_nssiInstanceId ANNFServiceInstance.setServiceInstanceName(sliceInstanceName) ANNFServiceInstance.setServiceType(execution.getVariable("sst")) ANNFServiceInstance.setOrchestrationStatus(serviceStatus) 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 0d64d7811b..0088ed4e54 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 @@ -691,6 +691,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ allocateTnNssi.setNetworkSliceInfos() allocateTnNssi.setSliceProfile(sliceTaskInfo.sliceProfile.trans2TnProfile()) + allocateTnNssi.getSliceProfile().setDomainType(sliceTaskInfo.subnetType.subnetType) NsiInfo nsiInfo = new NsiInfo() nsiInfo.setNsiId(sliceParams.suggestNsiId) nsiInfo.setNsiName(sliceParams.suggestNsiName) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy index 67e4b9227d..b07f5c965d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy @@ -121,6 +121,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor { currentNSSI['S-NSSAI'] = sNssai } + LOGGER.debug("S-NSSAI=" + currentNSSI['S-NSSAI']) // Slice Profile id String sliceProfileId = jsonUtil.getJsonValue(sliceProfile, "sliceProfileId") @@ -381,9 +382,10 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor { } + LOGGER.debug("${getPrefix()} Exit callPUTServiceInstance") + return response - LOGGER.debug("${getPrefix()} Exit callPUTServiceInstance") } @@ -742,6 +744,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor { // Supported S-NSSAI List<String> snssais = (List<String>) currentNSSI['S-NSSAIs'] + LOGGER.debug("prepareInstanceParams: snssais size = " + snssais.size()) + ServiceInstance nssi = (ServiceInstance) currentNSSI['nssi'] String orchStatus = nssi.getOrchestrationStatus() @@ -750,6 +754,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor { List<Map<String, String>> snssaiList = new ArrayList<>() for(String snssai:snssais) { + LOGGER.debug("prepareInstanceParams: snssai = " + snssai) Map<String, String> snssaisMap = new HashMap<>() snssaisMap.put("snssai", snssai) snssaisMap.put("status", orchStatus) @@ -761,12 +766,15 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor { ObjectMapper mapper = new ObjectMapper() - String supportedNssaiDetailsStr = mapper.writeValueAsString(snssaiList) + Map<String, Object> nSsai= new LinkedHashMap<>() + nSsai.put("sNssai", snssaiList) + // String supportedsNssaiJson = mapper.writeValueAsString(snssaiList) + String supportedsNssaiJson = mapper.writeValueAsString(nSsai) instanceParamsMap.put("k8s-rb-profile-name", "default") // ??? instanceParamsMap.put("config-type", "day2") // ??? - instanceParamsMap.put("supportedNssai", supportedNssaiDetailsStr) + instanceParamsMap.put("supportedsNssai", supportedsNssaiJson) instanceParams.add(instanceParamsMap) LOGGER.debug("${getPrefix()} Exit prepareInstanceParams") @@ -1177,9 +1185,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor { sliceProfileInstanceUri = (AAIResourceUri)spURI } else { - String msg = "Slice Profile URI not found" - LOGGER.error(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + String msg = "Slice Profile association with NSSI was already removed" + LOGGER.info(msg) } } @@ -1220,13 +1227,12 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor { sliceProfileInstanceUri = (AAIResourceUri)spURI } else { - String msg = "Slice Profile URI not found" - LOGGER.error(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + String msg = "Slice Profile instance was already deleted" + LOGGER.info(msg) } } - if(sliceProfileInstanceUri != null) { // NSSI should not be terminated + if(sliceProfileInstanceUri != null) { try { client.delete(sliceProfileInstanceUri) } catch (Exception e) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy index 0d2e6c1d5e..5a3859fff4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy @@ -38,6 +38,7 @@ import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.T import org.onap.logging.filter.base.ONAPComponents 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.ServiceInfo import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -55,6 +56,7 @@ import org.slf4j.LoggerFactory import com.fasterxml.jackson.databind.ObjectMapper import com.google.gson.JsonObject +import com.google.gson.Gson /** @@ -74,23 +76,23 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { private static final String ROLE_SLICE_PROFILE = "slice-profile-instance" private static final String ROLE_NSSI = "nssi" - private static final String AN_NF = "AN-NF" - private static final String TN_FH = "TN-FH" - private static final String TN_MH = "TN-MH" + private static final String AN_NF = "AN_NF" + private static final String TN_FH = "TN_FH" + private static final String TN_MH = "TN_MH" @Override public void preProcessRequest(DelegateExecution execution) { logger.debug("${Prefix} - Start preProcessRequest") String sliceParams = execution.getVariable("sliceParams") - String sNssaiList = jsonUtil.getJsonValue(sliceParams, "snssaiList") + def sNssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceParams, "snssaiList")) String anSliceProfileId = jsonUtil.getJsonValue(sliceParams, "sliceProfileId") String nsiId = jsonUtil.getJsonValue(sliceParams, "nsiId") String globalSubscriberId = execution.getVariable("globalSubscriberId") String subscriptionServiceType = execution.getVariable("subscriptionServiceType") String anNssiId = execution.getVariable("serviceInstanceID") - if(isBlank(sNssaiList) || isBlank(anSliceProfileId) || isBlank(nsiId)) { + if((sNssaiList.empty) || isBlank(anSliceProfileId) || isBlank(nsiId)) { String msg = "Input fields cannot be null : Mandatory attributes : [snssaiList, sliceProfileId, nsiId]" logger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) @@ -172,14 +174,15 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { boolean terminateAnNfNSSI = callOofAdapter(execution,execution.getVariable("oofAnNfNssiPayload")) execution.setVariable("terminateAnNfNSSI", terminateAnNfNSSI) if(!terminateAnNfNSSI) { - execution.setVariable("modifyAction",true) + execution.setVariable("modifyAction","deallocate") } } void prepareSdnrRequest(DelegateExecution execution) { String anNfNssiId = execution.getVariable("anNfNssiId") - String sNssai = execution.getVariable("sNssaiList") + String sNssai = execution.getVariable("sNssaiList").get(0) + String sliceProfileId = execution.getVariable("anNfSliceProfileId") String reqId = execution.getVariable("msoRequestId") String messageType = "SDNRTerminateResponse" StringBuilder callbackURL = new StringBuilder(UrnPropertiesReader.getVariable("mso.workflow.message.endpoint", execution)) @@ -188,35 +191,38 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { JsonObject input = new JsonObject() input.addProperty("RANNFNSSIId", anNfNssiId) input.addProperty("callbackURL", callbackURL.toString()) - input.addProperty("s-NSSAI", sNssai) + input.addProperty("sNSSAI", sNssai) + input.addProperty("sliceProfileId",sliceProfileId) + input.add("additionalproperties", new JsonObject()) JsonObject Payload = new JsonObject() - Payload.addProperty("version", "1.0") - Payload.addProperty("rpc-name", "terminateRANSliceInstance") - Payload.addProperty("correlation-id", reqId) - Payload.addProperty("type", "request") JsonObject wrapinput = new JsonObject() wrapinput.addProperty("action", "deallocate") JsonObject CommonHeader = new JsonObject() - CommonHeader.addProperty("time-stamp", new Date(System.currentTimeMillis()).format("yyyy-MM-dd'T'HH:mm:ss.sss'Z'", TimeZone.getDefault())) + 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("originator-id", "testing") CommonHeader.addProperty("request-id", reqId) CommonHeader.addProperty("sub-request-id", "1") + CommonHeader.add("flags", new JsonObject()) JsonObject body = new JsonObject() - body.add("input", wrapinput) JsonObject sdnrRequest = new JsonObject() Payload.add("input", input) - wrapinput.add("payload", Payload) + wrapinput.addProperty("payload", Payload.toString()) wrapinput.add("common-header", CommonHeader) body.add("input", wrapinput) sdnrRequest.add("body", body) + sdnrRequest.addProperty("version", "1.0") + sdnrRequest.addProperty("rpc-name", "terminateRANSliceInstance") + sdnrRequest.addProperty("correlation-id", reqId) + sdnrRequest.addProperty("type", "request") String json = sdnrRequest.toString() - execution.setVariable("sdnrRequest", sdnrRequest) + execution.setVariable("sdnrRequest", json) execution.setVariable("SDNR_messageType", messageType) execution.setVariable("SDNR_timeout", "PT10M") @@ -336,26 +342,26 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { String globalSubscriberId = execution.getVariable("globalSubscriberId") String subscriptionServiceType = execution.getVariable("subscriptionServiceType") - EsrInfo esrInfo = new EsrInfo() - esrInfo.setNetworkType(networkType) - esrInfo.setVendor("ONAP") + JsonObject esrInfo = new JsonObject() + esrInfo.addProperty("networkType", networkType) + esrInfo.addProperty("vendor", "ONAP_internal") - ServiceInfo serviceInfo = new ServiceInfo() - serviceInfo.setNssiId(instanceId) - serviceInfo.setNsiId(execution.getVariable("nsiId")) - serviceInfo.setGlobalSubscriberId(globalSubscriberId) - serviceInfo.setSubscriptionServiceType(subscriptionServiceType) + JsonObject serviceInfo = new JsonObject() + serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) + serviceInfo.addProperty("nssiId", instanceId) + serviceInfo.addProperty("globalSubscriberId", globalSubscriberId) + serviceInfo.addProperty("subscriptionServiceType", subscriptionServiceType) - execution.setVariable("${networkType}_esrInfo", esrInfo) + execution.setVariable("${networkType}_esrInfo", esrInfo.toString()) execution.setVariable("${networkType}_responseId", responseId) - execution.setVariable("${networkType}_serviceInfo", serviceInfo) + execution.setVariable("${networkType}_serviceInfo", serviceInfo.toString()) } void validateJobStatus(DelegateExecution execution,String responseDescriptor) { logger.debug("validateJobStatus ${responseDescriptor}") - String status = jsonUtil.getJsonValue(responseDescriptor, "responseDescriptor.status") - String statusDescription = jsonUtil.getJsonValue(responseDescriptor, "responseDescriptor.statusDescription") + String status = jsonUtil.getJsonValue(responseDescriptor, "status") + String statusDescription = jsonUtil.getJsonValue(responseDescriptor, "statusDescription") if("finished".equalsIgnoreCase(status)) { execution.setVariable("isSuccess", true) }else { @@ -364,14 +370,15 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { } void prepareUpdateJobStatus(DelegateExecution execution,String status,String progress,String statusDescription) { - String serviceId = execution.getVariable("anNssiId") + String nssiId = execution.getVariable("anNssiId") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") ResourceOperationStatus roStatus = new ResourceOperationStatus() - roStatus.setServiceId(serviceId) + roStatus.setServiceId(nsiId) roStatus.setOperationId(jobId) - roStatus.setResourceTemplateUUID(nsiId) + //roStatus.setResourceTemplateUUID(nsiId) + roStatus.setResourceInstanceID(nssiId) roStatus.setOperType("DeAllocate") roStatus.setProgress(progress) roStatus.setStatus(status) @@ -382,7 +389,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { void terminateTNFHNssi(DelegateExecution execution) { logger.debug("Start terminateTNFHNssi in ${Prefix}") String nssmfRequest = buildDeallocateNssiRequest(execution, TN_FH) - String nssiId = getInstanceIdByWorkloadContext(execution.getVariable("relatedSPs"), TN_FH) + String nssiId = getInstanceIdByWorkloadContext(execution.getVariable("relatedNssis"), TN_FH) execution.setVariable("tnFHNSSIId", nssiId) String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles/" + nssiId String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest) @@ -399,7 +406,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { void terminateTNMHNssi(DelegateExecution execution) { logger.debug("Start terminateTNMHNssi in ${Prefix}") String nssmfRequest = buildDeallocateNssiRequest(execution, TN_MH) - String nssiId = getInstanceIdByWorkloadContext(execution.getVariable("relatedSPs"), TN_MH) + String nssiId = getInstanceIdByWorkloadContext(execution.getVariable("relatedNssis"), TN_MH) execution.setVariable("tnMHNSSIId", nssiId) String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles/" + nssiId String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest) @@ -430,7 +437,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { void deleteANNSSI(DelegateExecution execution) { logger.debug("${Prefix} delete AN NSSI") - String nssiId = execution.getVariable("serviceInstanceID") + String nssiId = execution.getVariable("anNssiId") deleteServiceInstanceInAAI(execution, nssiId) } @@ -508,42 +515,46 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { Map<String, ServiceInstance> relatedNssis = execution.getVariable("relatedNssis") String anNssiId = execution.getVariable("anNssiId") - List<String> sNssaiList = execution.getVariable("sNssaiList") + List<String> sNssaiList = execution.getVariable("sNssaiList") Map<String, ServiceInstance> relatedSPs = execution.getVariable("relatedSPs") DeAllocateNssi deallocateNssi = new DeAllocateNssi() - deallocateNssi.setNsiId(anNssiId) + deallocateNssi.setNsiId(execution.getVariable("nsiId")) ServiceInstance tnNssi = relatedNssis.get(serviceFunction) String nssiId = tnNssi.getServiceInstanceId() deallocateNssi.setNssiId(nssiId) - deallocateNssi.setScriptName(tnNssi.getServiceInstanceName()) + deallocateNssi.setScriptName("TN1") deallocateNssi.setSnssaiList(sNssaiList) deallocateNssi.setSliceProfileId(relatedSPs.get(serviceFunction).getServiceInstanceId()) - EsrInfo esrInfo = new EsrInfo() - esrInfo.setVendor("ONAP") - esrInfo.setNetworkType("TN") + JsonObject esrInfo = new JsonObject() + esrInfo.addProperty("networkType", "tn") + esrInfo.addProperty("vendor", "ONAP_internal") ServiceInfo serviceInfo = new ServiceInfo() serviceInfo.setServiceInvariantUuid(tnNssi.getModelInvariantId()) serviceInfo.setServiceUuid(tnNssi.getModelVersionId()) serviceInfo.setGlobalSubscriberId(globalSubscriberId) serviceInfo.setSubscriptionServiceType(subscriptionServiceType) + serviceInfo.setNssiId(nssiId) + serviceInfo.setNssiName(tnNssi.getServiceInstanceName()) JsonObject json = new JsonObject() - json.addProperty("deAllocateNssi", objectMapper.writeValueAsString(deallocateNssi)) - json.addProperty("esrInfo", objectMapper.writeValueAsString(esrInfo)) - json.addProperty("serviceInfo", objectMapper.writeValueAsString(serviceInfo)) + Gson jsonConverter = new Gson() + json.add("deAllocateNssi", jsonConverter.toJsonTree(deallocateNssi)) + json.add("esrInfo", esrInfo) + json.add("serviceInfo", jsonConverter.toJsonTree(serviceInfo)) return json.toString() } private void deleteServiceInstanceInAAI(DelegateExecution execution,String instanceId) { try { - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("serviceType")).serviceInstance(instanceId)) - getAAIClient().delete(serviceInstanceUri) + AAIResourcesClient client = getAAIClient() + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(instanceId)) + client.delete(serviceInstanceUri) logger.debug("${Prefix} Exited deleteServiceInstance") }catch(Exception e){ logger.debug("Error occured within deleteServiceInstance method: " + e) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy index c559845e12..11058748fd 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy @@ -238,6 +238,22 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) } + + // NSI + String nsiId = currentNSSI['nsiId'] + ServiceInstance nsi = null + AAIResourceUri nsiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nsiId)) + Optional<ServiceInstance> nsiOpt = client.get(ServiceInstance.class, nsiUri) + if (nsiOpt.isPresent()) { + nsi = nsiOpt.get() + } + else { + String msg = "NSI service instance not found in AAI for nsi id " + nsiId + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + //Setting correlator as requestId String requestId = execution.getVariable("msoRequestId") execution.setVariable("NSSI_correlator", requestId) @@ -257,7 +273,7 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { String nxlId = nssi.getServiceInstanceId() String nxlType = "NSSI" - String oofRequest = getOofUtils().buildTerminateNxiRequest(requestId, nxlId, nxlType, messageType, nssi.getServiceInstanceId()) + String oofRequest = getOofUtils().buildTerminateNxiRequest(requestId, nxlId, nxlType, messageType, nsi.getServiceInstanceId()) LOGGER.debug("**** Terminate Nxi Request: "+oofRequest) LOGGER.debug("${PREFIX} Exit buildOOFRequest") @@ -289,32 +305,31 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { // http://so.onap:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances/de6a0aa2-19f2-41fe-b313-a5a9f159acd7/vnfs/3abbb373-8d33-4977-aa4b-2bfee496b6d5 String url = String.format("${nsmfЕndPoint}/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s", networkServiceInstance.getServiceInstanceId(), constituteVnf.getVnfId()) + LOGGER.debug("url = " + url) + currentNSSI['deleteServiceOrderURL'] = url String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) String basicAuth = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) - /*String basicAuthValue = encryptBasicAuth(basicAuth, msoKey) - def authHeader = "" - if (basicAuthValue != null) { - String responseAuthHeader = getAuthHeader(execution, basicAuthValue, msoKey) - String errorCode = jsonUtil.getJsonValue(responseAuthHeader, "errorCode") - if(errorCode == null || errorCode.isEmpty()) { // No error - authHeader = responseAuthHeader - } - else { - exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(errorCode), jsonUtil.getJsonValue(responseAuthHeader, "errorMessage")) - } - } else { - LOGGER.error( "Unable to obtain BasicAuth - BasicAuth value null") - exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " + - "value null") - } */ - def authHeader = utils.getBasicAuth(basicAuth, msoKey) - String callDeleteServiceOrderResponse = callDeleteServiceOrder(execution, url, authHeader) - String errorCode = jsonUtil.getJsonValue(callDeleteServiceOrderResponse, "errorCode") + def requestDetails = "" + + String prepareRequestDetailsResponse = prepareRequestDetails(execution) + LOGGER.debug("deleteServiceOrder: prepareRequestDetailsResponse=" + prepareRequestDetailsResponse) + + String errorCode = jsonUtil.getJsonValue(prepareRequestDetailsResponse, "errorCode") + LOGGER.debug("deleteServiceOrder: errorCode=" + errorCode) + if(errorCode == null || errorCode.isEmpty()) { // No error + requestDetails = prepareRequestDetailsResponse + } + else { + exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(errorCode), jsonUtil.getJsonValue(prepareRequestDetailsResponse, "errorMessage")) + } + + String callDeleteServiceOrderResponse = callDeleteServiceOrder(url, authHeader, requestDetails) + errorCode = jsonUtil.getJsonValue(callDeleteServiceOrderResponse, "errorCode") if(errorCode == null || errorCode.isEmpty()) { // No error String macroOperationId = jsonUtil.getJsonValue(callDeleteServiceOrderResponse, "requestReferences.requestId") @@ -339,21 +354,24 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { } - String callDeleteServiceOrder(DelegateExecution execution, String url, String authHeader) { + String callDeleteServiceOrder(String url, String authHeader, String requestDetailsStr) { LOGGER.debug("${PREFIX} Start callDeleteServiceOrder") String errorCode = "" String errorMessage = "" String response = "" + LOGGER.debug("callDeleteServiceOrder: url = " + url) + LOGGER.debug("callDeleteServiceOrder: authHeader = " + authHeader) + try { HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) httpClient.addAdditionalHeader("Authorization", authHeader) httpClient.addAdditionalHeader("Accept", "application/json") - Response httpResponse = httpClient.delete() + Response httpResponse = httpClient.delete(requestDetailsStr) int soResponseCode = httpResponse.getStatus() - LOGGER.debug("callDeleteServiceInstance: soResponseCode = " + soResponseCode) + LOGGER.debug("callDeleteServiceOrder: soResponseCode = " + soResponseCode) if (soResponseCode >= 200 && soResponseCode < 204 && httpResponse.hasEntity()) { response = httpResponse.readEntity(String.class) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy index 3bb1c0bef5..a08eb570c9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy @@ -609,7 +609,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { def prepareTnMhDeallocateRequest = { DelegateExecution execution -> logger.debug(Prefix+"prepareTnFhDeallocateRequest method start") - String nssmfRequest = anNssmfUtils.buildDeallocateNssiRequest(execution, "TN_FH") + String nssmfRequest = anNssmfUtils.buildDeallocateNssiRequest(execution, "TN_MH") String nssiId = execution.getVariable("TNFH_NSSI") execution.setVariable("tnFHNSSIId", nssiId) String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles/" + nssiId @@ -758,8 +758,9 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { } private void deleteServiceInstanceInAAI(DelegateExecution execution,String instanceId) { try { - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("serviceType")).serviceInstance(instanceId)) - getAAIClient().delete(serviceInstanceUri) + AAIResourcesClient client = getAAIClient() + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(instanceId)) + client.delete(serviceInstanceUri) logger.debug("${Prefix} Exited deleteServiceInstance") }catch(Exception e){ logger.debug("Error occured within deleteServiceInstance method: " + e) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy index 5bf4f40e50..acace8c1c7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy @@ -95,6 +95,9 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest { String nssiId = "5G-999" currentNSSI.put("nssiId", nssiId) + String nsiId = "ns-777" + currentNSSI.put("nsiId", nsiId) + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) when(mockExecution.getVariable("mso.oof.endpoint")).thenReturn("http://oof.onap:8088") @@ -127,6 +130,14 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest { when(client.get(ServiceInstance.class, nssiUri)).thenReturn(nssiOpt) + AAIResourceUri nsiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nsiId)) + + ServiceInstance nsi = new ServiceInstance() + nsi.setServiceInstanceId("5G-777") + Optional<ServiceInstance> nsiOpt = Optional.of(nsi) + + when(client.get(ServiceInstance.class, nsiUri)).thenReturn(nsiOpt) + String urlString = "http://oof.onap:8088" String httpRequest = "{\n" + @@ -143,7 +154,7 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest { String nxlId = nssi.getServiceInstanceId() String nxlType = "NSSI" String messageType = "cn" - String serviceInstanceId = nssi.getServiceInstanceId() + String serviceInstanceId = nsi.getServiceInstanceId() when(mockExecution.getVariable("msoRequestId")).thenReturn(requestId) when(oofUtilsMock.buildTerminateNxiRequest(requestId, nxlId, nxlType, messageType, serviceInstanceId)).thenReturn(httpRequest) @@ -213,6 +224,7 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest { genericVnf.setVnfName("vnf-name") genericVnf.setVnfId("vnf-id") + currentNSSI.put("constituteVnf", genericVnf) String urlString = String.format("http://mso.onap:8088/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s", networkServiceInstance.getServiceInstanceId(), genericVnf.getVnfId()) @@ -235,7 +247,7 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest { when(httpClientFactoryMock.newJsonClient(any(), any())).thenReturn(httpClientMock) - when(httpClientMock.delete()).thenReturn(responseMock) + when(httpClientMock.delete(requestDetailsStr)).thenReturn(responseMock) when(responseMock.getStatus()).thenReturn(200) when(responseMock.hasEntity()).thenReturn(true) |