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.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 com.fasterxml.jackson.databind.ObjectMapper
import com.google.gson.JsonObject
+import com.google.gson.Gson
/**
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)
execution.setVariable("anNfSliceProfileId", getInstanceIdByWorkloadContext(execution.getVariable("relatedSPs"), AN_NF))
Map<String,ServiceInstance> relatedNssis = new HashMap<>()
- execution.setVariable("relatedNssis", getRelatedInstancesByRole(execution, ROLE_NSSI, anNssiId))
+ relatedNssis = getRelatedInstancesByRole(execution, ROLE_NSSI, anNssiId)
+ if(relatedNssis.size() == 1) {
+ execution.setVariable("IsRANNfAlonePresent", true)
+ }
+ execution.setVariable("relatedNssis", relatedNssis)
}
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))
JsonObject input = new JsonObject()
input.addProperty("RANNFNSSIId", anNfNssiId)
input.addProperty("callbackURL", callbackURL.toString())
- input.addProperty("s-NSSAI", sNssai)
+ input.addProperty("sNSSAI", sNssai)
+ input.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId") as String)
+ input.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType") as String)
+ 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")
logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " operationId:" + modificationJobId)
ResourceOperationStatus initStatus = new ResourceOperationStatus()
- initStatus.setServiceId(serviceId)
+ initStatus.setServiceId(nsiId)
initStatus.setOperationId(modificationJobId)
- initStatus.setResourceTemplateUUID(nsiId)
+ initStatus.setResourceTemplateUUID(serviceId)
initStatus.setOperType("Modify-Deallocate")
requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus)
String responseId = "1"
String globalSubscriberId = execution.getVariable("globalSubscriberId")
String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ String anNssiId = execution.getVariable("anNssiId")
- EsrInfo esrInfo = new EsrInfo()
- esrInfo.setNetworkType(networkType)
- esrInfo.setVendor("ONAP")
-
- ServiceInfo serviceInfo = new ServiceInfo()
- serviceInfo.setNssiId(instanceId)
- serviceInfo.setNsiId(execution.getVariable("nsiId"))
- serviceInfo.setGlobalSubscriberId(globalSubscriberId)
- serviceInfo.setSubscriptionServiceType(subscriptionServiceType)
-
- execution.setVariable("${networkType}_esrInfo", esrInfo)
+ JsonObject esrInfo = new JsonObject()
+ esrInfo.addProperty("networkType", networkType)
+ esrInfo.addProperty("vendor", "ONAP_internal")
+
+ JsonObject serviceInfo = new JsonObject()
+ if (networkType.equals(SubnetType.AN.getSubnetType())) {
+ serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
+ } else {
+ serviceInfo.addProperty("nsiId", anNssiId)
+ }
+ serviceInfo.addProperty("nssiId", instanceId)
+ serviceInfo.addProperty("globalSubscriberId", globalSubscriberId)
+ serviceInfo.addProperty("subscriptionServiceType", subscriptionServiceType)
+
+ 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 {
}
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)
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)
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)
void deleteANNSSI(DelegateExecution execution) {
logger.debug("${Prefix} delete AN NSSI")
- String nssiId = execution.getVariable("serviceInstanceID")
+ String nssiId = execution.getVariable("anNssiId")
deleteServiceInstanceInAAI(execution, nssiId)
}
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")
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)