diff options
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/main')
9 files changed, 444 insertions, 246 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 2c1fa64609..540358fde7 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 @@ -176,9 +176,9 @@ public void createSliceProfilesInAai(DelegateExecution execution) { org.onap.aai.domain.yang.SliceProfile ANNF_SliceProfile = new SliceProfile() org.onap.aai.domain.yang.SliceProfile TNFH_SliceProfile = new SliceProfile() org.onap.aai.domain.yang.SliceProfile TNMH_SliceProfile = new SliceProfile() - ANNF_SliceProfile = createSliceProfile("AN-NF", execution) - TNFH_SliceProfile = createSliceProfile("TN-FH",execution) - TNMH_SliceProfile = createSliceProfile("TN-MH",execution) + ANNF_SliceProfile = createSliceProfile("AN_NF", execution) + TNFH_SliceProfile = createSliceProfile("TN_FH",execution) + TNMH_SliceProfile = createSliceProfile("TN_MH",execution) ANNF_SliceProfiles.getSliceProfile().add(ANNF_SliceProfile) TNFH_SliceProfiles.getSliceProfile().add(TNFH_SliceProfile) @@ -194,13 +194,13 @@ public void createSliceProfilesInAai(DelegateExecution execution) { String serviceStatus = "deactivated" ANNF_sliceProfileInstance.setOrchestrationStatus(serviceStatus) String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "plmnIdList") - ANNF_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid) + ANNF_sliceProfileInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0)) String serviceRole = "slice-profile-instance" ANNF_sliceProfileInstance.setServiceRole(serviceRole) ArrayList<String> snssaiList = execution.getVariable("snssaiList") String snssai = snssaiList.get(0) ANNF_sliceProfileInstance.setEnvironmentContext(snssai) - ANNF_sliceProfileInstance.setWorkloadContext("AN-NF") + ANNF_sliceProfileInstance.setWorkloadContext("AN_NF") ANNF_sliceProfileInstance.setSliceProfiles(ANNF_SliceProfiles) String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "resourceSharingLevel") ANNF_sliceProfileInstance.setServiceFunction(serviceFunctionAnnf) @@ -214,10 +214,10 @@ public void createSliceProfilesInAai(DelegateExecution execution) { TNFH_sliceProfileInstance.setServiceType(serviceType) TNFH_sliceProfileInstance.setOrchestrationStatus(serviceStatus) serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "plmnIdList") - TNFH_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid) + TNFH_sliceProfileInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0)) TNFH_sliceProfileInstance.setServiceRole(serviceRole) TNFH_sliceProfileInstance.setEnvironmentContext(snssai) - TNFH_sliceProfileInstance.setWorkloadContext("TN-FH") + TNFH_sliceProfileInstance.setWorkloadContext("TN_FH") TNFH_sliceProfileInstance.setSliceProfiles(TNFH_SliceProfiles) String serviceFunctionTnFH = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "resourceSharingLevel") TNFH_sliceProfileInstance.setServiceFunction(serviceFunctionTnFH) @@ -231,10 +231,10 @@ public void createSliceProfilesInAai(DelegateExecution execution) { TNMH_sliceProfileInstance.setServiceType(serviceType) TNMH_sliceProfileInstance.setOrchestrationStatus(serviceStatus) serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "plmnIdList") - TNMH_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid) + TNMH_sliceProfileInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0)) TNMH_sliceProfileInstance.setServiceRole(serviceRole) TNMH_sliceProfileInstance.setEnvironmentContext(snssai) - TNMH_sliceProfileInstance.setWorkloadContext("TN-MH") + TNMH_sliceProfileInstance.setWorkloadContext("TN_MH") TNMH_sliceProfileInstance.setSliceProfiles(TNMH_SliceProfiles) String serviceFunctionTnMH = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "resourceSharingLevel") TNMH_sliceProfileInstance.setServiceFunction(serviceFunctionTnMH) @@ -267,7 +267,7 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe SliceProfile result = new SliceProfile() Map<String,Object> profile switch(domainType) { - case "AN-NF": + case "AN_NF": profile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)//pending fields - cSReliabilityMeanTime, cSAvailabilityTarget, terminalDensity, msgSizeByte result.setJitter(profile.get("jitter")) result.setLatency(profile.get("latency")) @@ -288,7 +288,7 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe result.setExpDataRate(profile.get("expDataRate")) result.setProfileId(execution.getVariable("ANNF_sliceProfileId")) break - case "TN-FH": + case "TN_FH": profile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class) result.setJitter(profile.get("jitter")) result.setLatency(profile.get("latency")) @@ -296,7 +296,7 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe result.setResourceSharingLevel(profile.get("resourceSharingLevel")) result.setProfileId(execution.getVariable("TNFH_sliceProfileId")) break - case "TN-MH": + case "TN_MH": profile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class) result.setJitter(profile.get("jitter")) result.setLatency(profile.get("latency")) @@ -361,7 +361,8 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe if(domainType.equals("TN_FH")) { serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNFH_modelInvariantUuid")) serviceInfo.addProperty("serviceUuid", execution.getVariable("TNFH_modelUuid")) - serviceInfo.addProperty("nssiName", execution.getVariable("TNFH_modelName")) + serviceInfo.addProperty("nssiName", "nssi_"+execution.getVariable("TNFH_modelName")) + serviceInfo.addProperty("sst", execution.getVariable("sst")) allocateTnNssi.addProperty("nsstId", execution.getVariable("TNFH_modelUuid")) allocateTnNssi.addProperty("nssiName", execution.getVariable("TNFH_modelName")) Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class) @@ -373,7 +374,8 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe }else if(domainType.equals("TN_MH")) { serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNMH_modelInvariantUuid")) serviceInfo.addProperty("serviceUuid", execution.getVariable("TNMH_modelUuid")) - serviceInfo.addProperty("nssiName", execution.getVariable("TNMH_modelName")) + serviceInfo.addProperty("nssiName", "nssi_"+execution.getVariable("TNMH_modelName")) + serviceInfo.addProperty("sst", execution.getVariable("sst")) allocateTnNssi.addProperty("nsstId", execution.getVariable("TNMH_modelUuid")) allocateTnNssi.addProperty("nssiName", execution.getVariable("TNMH_modelName")) Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class) @@ -383,26 +385,40 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe endpoints.addProperty("transportEndpointB", execution.getVariable("tranportEp_ID_CUIN")) connectionLinksList.add(endpoints) } - - //Connection links - connectionLinks.add("connectionLinks", connectionLinksList) - transportSliceNetworksList.add(connectionLinks) - allocateTnNssi.add("transportSliceNetworks", transportSliceNetworksList) }else if(action.equals("modify-allocate")) { + JsonObject endpoints = new JsonObject() if(domainType.equals("TN_FH")) { 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")) serviceInfo.addProperty("nssiName", execution.getVariable("TNFH_nssiName")) + Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class) + sliceProfile.put("sliceProfileId", execution.getVariable("TNFH_sliceProfileInstanceId")) + 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")) { 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")) serviceInfo.addProperty("nssiName", execution.getVariable("TNMH_nssiName")) + Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class) + sliceProfile.put("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId")) + 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) + JsonParser parser = new JsonParser() String nsiInfo = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "nsiInfo") allocateTnNssi.add("nsiInfo",(JsonObject) parser.parse(nsiInfo)) 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 567c703496..f3fca050a2 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 @@ -53,6 +53,7 @@ import org.onap.aaiclient.client.aai.AAINamespaceConstants import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aai.domain.yang.NetworkPolicy import org.onap.aai.domain.yang.NetworkRoute +import org.json.JSONArray class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { @@ -85,7 +86,8 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { " subscriptionServiceType - "+execution.getVariable("subscriptionServiceType")+ " jobId - "+execution.getVariable("jobId")+ " sliceParams - "+execution.getVariable("sliceParams")+ - " servicename - "+ execution.getVariable("servicename")) + " servicename - "+ execution.getVariable("servicename")+ + " sst - "+ execution.getVariable("sst")) //validate slice subnet inputs @@ -101,7 +103,14 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String sliceProfileId = jsonUtil.getJsonValue(sliceProfile, "sliceProfileId") def snssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "snssaiList")) def plmnIdList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "plmnIdList")) - def coverageAreaTAList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "coverageAreaTAList")) + String jsonArray = jsonUtil.getJsonValue(sliceProfile, "coverageAreaTAList") + List<Integer> list = new ArrayList<>(); + JSONArray arr = new JSONArray(jsonArray); + for (int i = 0; i < arr.length(); i++) { + int s = (int) arr.get(i); + list.add(s); + } + def coverageAreaTAList = list; if (isBlank(sliceProfileId) || (snssaiList.empty) || (plmnIdList.empty) || (coverageAreaTAList.empty)) { @@ -131,16 +140,16 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { execution.setVariable("job_timeout", 10) //set BH end point - List<String> BH_endPoints = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceParams, "endPoints")) - logger.debug("BH end points list : "+BH_endPoints) - if(BH_endPoints.empty) { - msg = "End point info is empty" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - }else { - execution.setVariable("bh_endpoint", BH_endPoints.get(0)) - } - + def BH_endPoints = jsonUtil.getJsonValue(sliceParams, "endPoint") + logger.debug("BH end points list : "+BH_endPoints) + if(isBlank(BH_endPoints)) { + msg = "End point info is empty" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + }else { + execution.setVariable("bh_endpoint", BH_endPoints) + } + } catch(BpmnError e) { throw e } catch(Exception ex) { @@ -261,6 +270,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String requestId = execution.getVariable("msoRequestId") String messageType = "NSISelectionResponse" Map<String, Object> profileInfo = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class) + profileInfo.put("sST",execution.getVariable("sst")) String modelUuid = execution.getVariable("modelUuid") String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelName = execution.getVariable("ranModelName") @@ -377,8 +387,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { serviceInfo.addProperty("nssiId", execution.getVariable("RANServiceInstanceId")) serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) serviceInfo.addProperty("nssiName", execution.getVariable("servicename")) - String sST = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST") - serviceInfo.addProperty("sST", sST) + serviceInfo.addProperty("sST", execution.getVariable("sst")) serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("plmnIdList"))) serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId")) serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType")) @@ -475,6 +484,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { List<String> ranConstituentSliceProfiles = jsonUtil.StringArrayToList(execution.getVariable("RanConstituentSliceProfiles")) anNssmfUtils.createDomainWiseSliceProfiles(ranConstituentSliceProfiles, execution) Map<String, Object> profileInfo = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class) + profileInfo.put("sST",execution.getVariable("sst")) String modelUuid = execution.getVariable("ANNF_modelUuid") String modelInvariantUuid = execution.getVariable("ANNF_modelInvariantUuid") String modelName = execution.getVariable("ANNF_modelName") @@ -518,6 +528,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { ServiceDecomposition serviceDecomposition = execution.getVariable("ANNF_ServiceDecomposition") serviceDecomposition.setServiceInstance(serviceInstance); execution.setVariable("ANNF_ServiceDecomposition", serviceDecomposition) + execution.setVariable("modifyAction","allocate") execution.setVariable("isRspRanNfNssi", true) }else { logger.debug("No solutions returned from OOF .. Create new RAN NF NSSI") @@ -544,17 +555,18 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String sliceInstanceName = execution.getVariable("servicename") ANServiceInstance.setServiceInstanceName(sliceInstanceName) String serviceType = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST") - ANServiceInstance.setServiceType(serviceType) + ANServiceInstance.setServiceType(execution.getVariable("sst")) String serviceStatus = "deactivated" ANServiceInstance.setOrchestrationStatus(serviceStatus) String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "plmnIdList") - ANServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid) + ANServiceInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0)) String serviceRole = "nssi" ANServiceInstance.setServiceRole(serviceRole) - List<String> snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class) + List<String> snssaiList = execution.getVariable("snssaiList") String snssai = snssaiList.get(0) - ANServiceInstance.setEnvironmentContext(snssai) - ANServiceInstance.setWorkloadContext("AN") + //ANServiceInstance.setEnvironmentContext(snssai) + ANServiceInstance.setEnvironmentContext("an") //Network Type + ANServiceInstance.setWorkloadContext("AN") //domain Type logger.debug("completed AN service instance build "+ ANServiceInstance.toString()) String msg = "" @@ -610,7 +622,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String sliceInstanceName = execution.getVariable("servicename") ANServiceInstance.setServiceInstanceName(sliceInstanceName) String serviceType = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST") - ANServiceInstance.setServiceType(serviceType) + ANServiceInstance.setServiceType(execution.getVariable("sst")) String serviceStatus = "deactivated" ANServiceInstance.setOrchestrationStatus(serviceStatus) String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "plmnIdList") @@ -630,19 +642,19 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug("completed AN service instance build "+ ANServiceInstance.toString()) //create RAN NF NSSI ANNFServiceInstance.setServiceInstanceId(execution.getVariable("RANNFServiceInstanceId")) - sliceInstanceName = execution.getVariable("ANNF_modelName") + sliceInstanceName = "nssi_"+execution.getVariable("ANNF_modelName") ANNFServiceInstance.setServiceInstanceName(sliceInstanceName) - ANNFServiceInstance.setServiceType(serviceType) + ANNFServiceInstance.setServiceType(execution.getVariable("sst")) ANNFServiceInstance.setOrchestrationStatus(serviceStatus) serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "plmnIdList") - ANNFServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid) + ANNFServiceInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0)) ANNFServiceInstance.setServiceRole(serviceRole) snssaiList = execution.getVariable("snssaiList") snssai = snssaiList.get(0) ANNFServiceInstance.setEnvironmentContext(snssai) ANNFServiceInstance.setModelInvariantId(execution.getVariable("ANNF_modelInvariantUuid")) ANNFServiceInstance.setModelVersionId(execution.getVariable("ANNF_modelUuid")) - ANNFServiceInstance.setWorkloadContext("AN-NF") + ANNFServiceInstance.setWorkloadContext("AN_NF") String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "resourceSharingLevel") ANNFServiceInstance.setServiceFunction(serviceFunctionAnnf) logger.debug("completed AN service instance build "+ ANNFServiceInstance.toString()) @@ -720,8 +732,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { execution.setVariable("esrInfo", esrInfo.toString()) JsonObject serviceInfo = new JsonObject() serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) - String sST = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST") - serviceInfo.addProperty("sST", sST) + serviceInfo.addProperty("sST", execution.getVariable("sst")) serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("plmnIdList"))) serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId")) serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType")) @@ -902,7 +913,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String requestId = execution.getVariable("msoRequestId") Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class) sliceProfile.put("sliceProfileId", execution.getVariable("ANNF_sliceProfileInstanceId")) - sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSessions")) + sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSession")) sliceProfile.put("uLThptPerSlice", sliceProfile.get("expDataRateUL")) sliceProfile.put("dLThptPerSlice", sliceProfile.get("expDataRateDL")) @@ -912,11 +923,11 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { 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'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", 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)) @@ -924,6 +935,8 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { payloadInput.addProperty("NSIID", execution.getVariable("nsiId")) payloadInput.addProperty("RANNFNSSIId", execution.getVariable("RANNFServiceInstanceId")) payloadInput.addProperty("callbackURL", callbackUrl) + payloadInput.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId")) + payloadInput.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType")) payloadInput.add("additionalproperties", new JsonObject()) payload.add("input", payloadInput) input.add("common-header", commonHeader) @@ -948,8 +961,8 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String bh_routeId = UUID.randomUUID().toString() execution.setVariable("tranportEp_ID_bh", bh_routeId) String role = "CU" - String CU_IpAddress = jsonUtil.getJsonValue(bh_endpoint, "IpAddress") - String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "LogicalLinkId") + String CU_IpAddress = jsonUtil.getJsonValue(bh_endpoint, "ipAddress") + String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "logicInterfaceId") String nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo") NetworkRoute bh_ep = new NetworkRoute() bh_ep.setRouteId(bh_routeId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy index a1afe9ae95..2801c11e47 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy @@ -94,12 +94,12 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { execution.setVariable("networkServiceModelUuid", networkServiceModelUuid) String sliceParams = execution.getVariable("sliceParams") logger.debug("sliceParams "+sliceParams) - List<String> bhEndPoints = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceParams, "endPoints")) + String bhEndPoints = jsonUtil.getJsonValue(sliceParams, "endPoint") if(bhEndPoints.empty) { logger.debug("End point info is empty") exceptionUtil.buildAndThrowWorkflowException(execution, 500, "End point info is empty") }else { - execution.setVariable("bh_endpoint", bhEndPoints.get(0)) + execution.setVariable("bh_endpoint", bhEndPoints) } logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice::: preProcessRequest ****") } @@ -130,6 +130,10 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { logger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } + //set shared or non shared value from sliceProfile object in request + String additionalParams = execution.getVariable("sliceParams") + //Get resourceSharingLevel from sliceProfile + String serviceFunction = jsonUtil.getJsonValue(additionalParams, "sliceProfile.resourceSharingLevel") String serviceInstanceName = "nssi_"+execution.getVariable("nsstName") ServiceInstance si = new ServiceInstance() si.setServiceInstanceId(execution.getVariable("nssiServiceInstanceId")) @@ -141,6 +145,7 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { si.setModelVersionId(execution.getVariable("modelUuid")) si.setEnvironmentContext(environmentContext) si.setWorkloadContext(workloadContext) + si.setServiceFunction(serviceFunction) logger.debug("AAI service Instance Request Payload : "+si.toString()) AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)) getAAIClient().create(uri, si) @@ -225,7 +230,7 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { logger.debug(("Service Vnfs JSON: "+jsonUtil.getJsonValue(json, "serviceResources.serviceVnfs"))) List serviceVnfs = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(json, "serviceResources.serviceVnfs")) String networkServiceVnfJson = serviceVnfs.get(0) - String vnfInstanceName = (jsonUtil.getJsonValue(networkServiceVnfJson, "modelInfo.modelInstanceName")).trim() ?: "" + String vnfInstanceName = (jsonUtil.getJsonValue(networkServiceVnfJson, "modelInfo.modelInstanceName")).replace(" ","") ?: "" execution.setVariable("vnfInstanceName", vnfInstanceName) } @@ -420,8 +425,8 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { String bh_routeId = UUID.randomUUID().toString() execution.setVariable("coreEp_ID_bh", bh_routeId) String role = "CN" - String cnIpAddress = jsonUtil.getJsonValue(bh_endpoint, "IpAddress") - String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "LogicalLinkId") + String cnIpAddress = jsonUtil.getJsonValue(bh_endpoint, "ipAddress") + String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "logicInterfaceId") String nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo") NetworkRoute bh_ep = new NetworkRoute() logger.debug("bh_endpoint: {}, bh_routeId: {}, cnIpAddress: {}, role: {}, LogicalLinkId: {}, nextHopInfo: {}, bh_ep: {}", bh_endpoint, bh_routeId, cnIpAddress, role, LogicalLinkId, nextHopInfo, bh_ep) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy index b3c99c6e9a..61528de793 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy @@ -80,14 +80,7 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: preProcessRequest ****") //Get NSSI Solutions String nssisolutions = execution.getVariable("solutions") - - //Get First Object - List<String> nssiSolutionList = jsonUtil.StringArrayToList(nssisolutions) - - logger.debug("nssiSolutionList : "+nssiSolutionList) - - String nssiId = jsonUtil.getJsonValue(nssiSolutionList.get(0), "NSSIId") - logger.debug("NSSIId : "+nssiId) + String nssiId = jsonUtil.getJsonValue(nssisolutions, "NSSIId") if (isBlank(nssiId)) { String msg = "solution nssiId is null" @@ -98,12 +91,20 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { } String sNssaiListAsString = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "snssaiList") - logger.debug("sNssaiListAsString "+sNssaiListAsString) List<String> sNssaiList = jsonUtil.StringArrayToList(sNssaiListAsString) - logger.debug("sNssaiList "+sNssaiList) String sNssai = sNssaiList.get(0) execution.setVariable("sNssai", sNssai) - logger.debug("sNssai: "+sNssai) + + //Setting this value in Map + Map<String, Object> spiWithsNssaiAndOrchStatus = new LinkedHashMap<>() + spiWithsNssaiAndOrchStatus.put("snssai", sNssai) + spiWithsNssaiAndOrchStatus.put("status", "created") + + List <Map<String, Object>> spiWithsNssaiAndOrchStatusList = new ArrayList<>(); + spiWithsNssaiAndOrchStatusList.add(spiWithsNssaiAndOrchStatus) + + execution.setVariable("snssaiAndOrchStatusList", spiWithsNssaiAndOrchStatusList) + logger.debug("service Profile's NSSAI And Orchestration Status: "+spiWithsNssaiAndOrchStatus) String serviceType = execution.getVariable("subscriptionServiceType") execution.setVariable("serviceType", serviceType) @@ -125,79 +126,77 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { String networkServiceInstanceId ="" if(nsi.isPresent()) { List<Relationship> relationshipList = nsi.get().getRelationshipList()?.getRelationship() - List spiWithsNssaiAndOrchStatusList = new ArrayList<>() + + List spiWithsNssaiAndOrchStatusList = execution.getVariable("snssaiAndOrchStatusList") + + if(spiWithsNssaiAndOrchStatusList == null) { + spiWithsNssaiAndOrchStatusList = new ArrayList<>(); + } for (Relationship relationship : relationshipList) { String relatedTo = relationship.getRelatedTo() - if (relatedTo == "service-instance") { + if ("service-instance".equals(relatedTo)) { List<RelationshipData> relationshipDataList = relationship.getRelationshipData() List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToProperty() for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "service-instance.service-instance-id") { + if ("service-instance.service-instance-id".equals(relationshipData.getRelationshipKey())) { logger.debug("**** service-instance.service-instance-id 1 :: getServiceInstanceRelationships :: "+ relationshipData.getRelationshipValue()) - execution.setVariable("networkServiceInstanceId", relationshipData.getRelationshipValue()) - } - } - for (RelatedToProperty relatedToProperty : relatedToPropertyList) { - if (relatedToProperty.getPropertyKey() == "service-instance.service-instance-name") { - execution.setVariable("networkServiceInstanceName", relatedToProperty.getPropertyValue()) - } - } - } - //If related to is allotted-Resource - if (relatedTo == "allotted-resource") { - //get slice Profile Instance Id from allotted resource in list by nssi - List<String> sliceProfileInstanceIdList = new ArrayList<>() - List<RelationshipData> relationshipDataList = relationship.getRelationshipData() - for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "service-instance.service-instance-id") { - sliceProfileInstanceIdList.add(relationshipData.getRelationshipValue()) - } - } - for (String sliceProfileServiceInstanceId : sliceProfileInstanceIdList) { - String errorSliceProfileMsg = "Slice Profile Service Instance was not found in aai" - - //Query Slice Profile Service Instance From AAI by sliceProfileServiceInstanceId - AAIResultWrapper sliceProfileInstanceWrapper = queryAAI(execution, Types.SERVICE_INSTANCE, sliceProfileServiceInstanceId, errorSliceProfileMsg) - Optional<ServiceInstance> sliceProfileServiceInstance = sliceProfileInstanceWrapper.asBean(ServiceInstance.class) - if (sliceProfileServiceInstance.isPresent()) { - String orchestrationStatus= sliceProfileServiceInstance.get().getOrchestrationStatus() - String sNssai = sliceProfileServiceInstance.get().getSliceProfiles().getSliceProfile().get(0).getSNssai() - if(sNssai.equals(execution.getVariable("sNssai"))) { - orchestrationStatus = execution.getVariable("oStatus") - //Slice Profile Service Instance to be updated in AAI - execution.setVariable("sliceProfileServiceInstance", sliceProfileServiceInstance) - } - Map<String, Object> spiWithsNssaiAndOrchStatus = new LinkedHashMap<>() - spiWithsNssaiAndOrchStatus.put("snssai", sNssai) - spiWithsNssaiAndOrchStatus.put("status", orchestrationStatus) - spiWithsNssaiAndOrchStatusList.add(spiWithsNssaiAndOrchStatus) - logger.debug("service Profile's NSSAI And Orchestration Status: "+spiWithsNssaiAndOrchStatus) + //Query Every related Service Instance From AAI by service Instance ID + AAIResultWrapper instanceWrapper = queryAAI(execution, Types.SERVICE_INSTANCE, relationshipData.getRelationshipValue(), "No Instance Present") + Optional<ServiceInstance> relatedServiceInstance = instanceWrapper.asBean(ServiceInstance.class) + if (relatedServiceInstance.isPresent()) { + ServiceInstance relatedServiceInstanceObj = relatedServiceInstance.get() + + String role = relatedServiceInstanceObj.getServiceRole(); + + if(role == null || role.isEmpty()) { + networkServiceInstanceId = relatedServiceInstanceObj.getServiceInstanceId() + networkServiceInstanceName = relatedServiceInstanceObj.getServiceInstanceName() + + logger.debug("networkServiceInstanceId: {} networkServiceInstanceName: {} ",networkServiceInstanceId, networkServiceInstanceName) + + execution.setVariable("networkServiceInstanceId", networkServiceInstanceId) + execution.setVariable("networkServiceInstanceName", networkServiceInstanceName) + + } else if("slice-profile-instance".equals(role)) { + + String orchestrationStatus= relatedServiceInstanceObj.getOrchestrationStatus() + String sNssai = relatedServiceInstanceObj.getEnvironmentContext() + if(sNssai.equals(execution.getVariable("sNssai"))) { + orchestrationStatus = execution.getVariable("oStatus") + //Slice Profile Service Instance to be updated in AAI + execution.setVariable("sliceProfileServiceInstance", relatedServiceInstanceObj) + } + + Map<String, Object> spiWithsNssaiAndOrchStatus = new LinkedHashMap<>() + spiWithsNssaiAndOrchStatus.put("snssai", sNssai) + spiWithsNssaiAndOrchStatus.put("status", orchestrationStatus) + spiWithsNssaiAndOrchStatusList.add(spiWithsNssaiAndOrchStatus) + logger.debug("service Profile's NSSAI And Orchestration Status: "+spiWithsNssaiAndOrchStatus) + } + + } } + } + } } execution.setVariable("snssaiAndOrchStatusList", spiWithsNssaiAndOrchStatusList) } - logger.debug("NSSI Id: ${serviceInstanceId}, network Service Instance Id: ${networkServiceInstanceId}, serviceName: ${networkServiceInstanceName}") - //Get ServiceInstance Relationships getServiceInstanceRelationships(execution) - //Get Vnf Relationships getVnfRelationships(execution) logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: getNetworkInstanceAssociatedWithNssiId ****") - } + } private void getServiceInstanceRelationships(DelegateExecution execution) { - - logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: getServiceInstanceRelationships ****") - + logger.debug(Prefix +" **** Enter DoAllocateCoreSharedSlice ::: getServiceInstanceRelationships ****") String serviceInstanceId = execution.getVariable("networkServiceInstanceId") - String errorMsg = "query Network Service Instance from AAI failed" AAIResultWrapper wrapper = queryAAI(execution, Types.SERVICE_INSTANCE, serviceInstanceId, errorMsg) Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) @@ -208,47 +207,45 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { List<Relationship> relationshipList = si.get().getRelationshipList()?.getRelationship() for (Relationship relationship : relationshipList) { String relatedTo = relationship.getRelatedTo() - if (relatedTo == "owning-entity") { + if (("owning-entity").equals(relatedTo)) { List<RelationshipData> relationshipDataList = relationship.getRelationshipData() for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "owning-entity.owning-entity-id") { + if (("owning-entity.owning-entity-id").equals(relationshipData.getRelationshipKey())) { execution.setVariable("owningEntityId", relationshipData.getRelationshipValue()) } } - } else if (relatedTo == "generic-vnf") { + } else if (("generic-vnf").equals(relatedTo)) { List<RelationshipData> relationshipDataList = relationship.getRelationshipData() List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToProperty() //Get VnfId for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "generic-vnf.vnf-id") { + if (("generic-vnf.vnf-id").equals(relationshipData.getRelationshipKey())) { execution.setVariable("vnfId", relationshipData.getRelationshipValue()) } } - //Get Vnf Name Check If necessary for (RelatedToProperty relatedToProperty : relatedToPropertyList) { - if (relatedToProperty.getPropertyKey() == "generic-vnf.vnf-name") { + if (("generic-vnf.vnf-name").equals(relatedToProperty.getPropertyKey())) { execution.setVariable("vnfName", relatedToProperty.getPropertyValue()) } } - } else if (relatedTo == "project") { + } else if (("project").equals(relatedTo)) { List<RelationshipData> relationshipDataList = relationship.getRelationshipData() for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "project.project-name") { + if (("project.project-name").equals(relationshipData.getRelationshipKey())) { execution.setVariable("projectName", relationshipData.getRelationshipValue()) } } } } - - logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: getServiceInstanceRelationships ****") + logger.debug(Prefix +" **** Exit DoAllocateCoreSharedSlice ::: getServiceInstanceRelationships ****") } } private void getVnfRelationships(DelegateExecution execution) { - logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: getVnfRelationships ****") + logger.debug(Prefix +" **** Enter DoAllocateCoreSharedSlice ::: getVnfRelationships ****") String msg = "query Generic Vnf from AAI failed" try { AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(execution.getVariable('vnfId'))) @@ -261,33 +258,34 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { List<Relationship> relationshipList = vnf.get().getRelationshipList()?.getRelationship() for (Relationship relationship : relationshipList) { String relatedTo = relationship.getRelatedTo() - if (relatedTo == "tenant") { + if (("tenant").equals(relatedTo)) { List<RelationshipData> relationshipDataList = relationship.getRelationshipData() for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "tenant.tenant-id") { + if (("tenant.tenant-id").equals(relationshipData.getRelationshipKey())) { execution.setVariable("tenantId", relationshipData.getRelationshipValue()) } } - } else if (relatedTo == "cloud-region") { + } else if (("cloud-region").equals(relatedTo)) { List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "cloud-region.cloud-owner") { + if (("cloud-region.cloud-owner").equals(relationshipData.getRelationshipKey())) { execution.setVariable("cloudOwner", relationshipData.getRelationshipValue()) - } else if (relationshipData.getRelationshipKey() == "cloud-region.cloud-region-id") { + } else if (("cloud-region.cloud-region-id").equals(relationshipData.getRelationshipKey())) { execution.setVariable("lcpCloudRegionId", relationshipData.getRelationshipValue()) } } - } else if (relatedTo == "platform") { + } else if (("platform").equals(relatedTo)) { List<RelationshipData> relationshipDataList = relationship.getRelationshipData() for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "platform.platform-name") { + if (("platform.platform-name").equals(relationshipData.getRelationshipKey())) { execution.setVariable("platformName", relationshipData.getRelationshipValue()) } } - } else if (relatedTo == "line-of-business") { + } else if (("line-of-business").equals(relatedTo)) { List<RelationshipData> relationshipDataList = relationship.getRelationshipData() for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "line-of-business.line-of-business-name") { + if (("line-of-business.line-of-business-name").equals(relationshipData.getRelationshipKey())) { execution.setVariable("lineOfBusinessName", relationshipData.getRelationshipValue()) } } @@ -301,9 +299,16 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { logger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: getVnfRelationships ****") + logger.debug(Prefix +" **** Exit DoAllocateCoreSharedSlice ::: getVnfRelationships ****") } + /** + * query AAI + * @param execution + * @param aaiObjectName + * @param instanceId + * @return AAIResultWrapper + */ private AAIResultWrapper queryAAI(DelegateExecution execution, AAIObjectName aaiObjectName, String instanceId, String errorMsg) { logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: queryAAI ****") String globalSubscriberId = execution.getVariable("globalSubscriberId") @@ -344,9 +349,7 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { public void prepareSOMacroRequestPayload(DelegateExecution execution) { logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: prepareSOMacroRequestPayLoad ****") String json = execution.getVariable("serviceVnfs") - logger.debug(">>>> json "+json) List<Object> vnfList = mapper.readValue(json, List.class); - logger.debug("vnfList: "+vnfList) Map<String,Object> serviceMap = mapper.readValue(execution.getVariable("serviceModelInfo"), Map.class); ModelInfo serviceModelInfo = new ModelInfo() serviceModelInfo.setModelType(ModelType.service) @@ -354,19 +357,12 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { serviceModelInfo.setModelVersionId(serviceMap.get("modelUuid")) serviceModelInfo.setModelName(serviceMap.get("modelName")) serviceModelInfo.setModelVersion(serviceMap.get("modelVersion")) - logger.debug("serviceModelInfo: "+serviceModelInfo) //List of Vnfs List<Object> vnfModelInfoList = new ArrayList<>() Map vnfMap = vnfList.get(0) - ModelInfo vnfModelInfo = vnfMap.get("modelInfo") - vnfModelInfo.setModelCustomizationId(vnfModelInfo.getModelCustomizationUuid()) - vnfModelInfo.setModelVersionId(vnfModelInfo.getModelId()) - logger.debug("vnfModelInfo "+vnfModelInfo) - //List of VFModules List<Map<String, Object>> vfModuleList = vnfMap.get("vfModules") - logger.debug("vfModuleList "+vfModuleList) //List of VfModules List<ModelInfo> vfModelInfoList = new ArrayList<>() @@ -376,16 +372,17 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { ModelInfo vfModelInfo = vfModule.get("modelInfo") vfModelInfo.setModelCustomizationId(vfModelInfo.getModelCustomizationUuid()) vfModelInfo.setModelVersionId(vfModelInfo.getModelId()) - logger.debug("vfModelInfo "+vfModelInfo) vfModelInfoList.add(vfModelInfo) } + + String networkServiceInstanceName = execution.getVariable("networkServiceInstanceName") //RequestInfo RequestInfo requestInfo = new RequestInfo() //Dummy Product FamilyId requestInfo.setProductFamilyId("test1234") requestInfo.setSource("VID") - requestInfo.setInstanceName(execution.getVariable("networkServiceInstanceName")) + requestInfo.setInstanceName(networkServiceInstanceName) requestInfo.setSuppressRollback(false) requestInfo.setRequestorId("NBI") @@ -395,10 +392,13 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { serviceParams.add(serviceParamsValues) //Cloud Configuration + String lcpCloudRegionId = execution.getVariable("lcpCloudRegionId") + String tenantId = execution.getVariable("tenantId") + String cloudOwner = execution.getVariable("cloudOwner") CloudConfiguration cloudConfiguration = new CloudConfiguration() - cloudConfiguration.setLcpCloudRegionId(execution.getVariable("lcpCloudRegionId")) - cloudConfiguration.setTenantId(execution.getVariable("tenantId")) - cloudConfiguration.setCloudOwner(execution.getVariable("cloudOwner")) + cloudConfiguration.setLcpCloudRegionId(lcpCloudRegionId) + cloudConfiguration.setTenantId(tenantId) + cloudConfiguration.setCloudOwner(cloudOwner) //VFModules List List<Map<String, Object>> vfModules = new ArrayList<>() @@ -415,8 +415,6 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { } //Vnf intsanceParams - Map<String, Object> sliceProfile = mapper.readValue(execution.getVariable("sliceProfile"), Map.class); - List<Map<String, Object>> vnfInstanceParamsList = new ArrayList<>() String supportedsNssaiJson= prepareVnfInstanceParamsJson(execution) @@ -425,13 +423,17 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { vnfInstanceParamsList.add(supportedNssai) Platform platform = new Platform() - String platformName = execution.getVariable("platformName") + String platformName = execution.getVariable("platformName") platform.setPlatformName(platformName) LineOfBusiness lineOfbusiness = new LineOfBusiness() String lineOfBusinessName = execution.getVariable("lineOfBusinessName") lineOfbusiness.setLineOfBusinessName(lineOfBusinessName) + ModelInfo vnfModelInfo = vnfMap.get("modelInfo") + vnfModelInfo.setModelCustomizationId(vnfModelInfo.getModelCustomizationUuid()) + vnfModelInfo.setModelVersionId(vnfModelInfo.getModelId()) + //Vnf Values Map<String, Object> vnfValues = new LinkedHashMap<>() vnfValues.put("lineOfBusiness", lineOfbusiness) @@ -449,9 +451,10 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { serviceResources.put("vnfs", vnfModelInfoList) //Service Values + String serviceInstanceName = execution.getVariable("networkServiceInstanceName") Map<String, Object> serviceValues = new LinkedHashMap<>() serviceValues.put("modelInfo", serviceModelInfo) - serviceValues.put("instanceName", execution.getVariable("networkServiceInstanceName")) + serviceValues.put("instanceName", serviceInstanceName) serviceValues.put("resources", serviceResources) serviceValues.put("instanceParams", serviceParams) @@ -469,22 +472,26 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { userParams.add(userParamsValues) //Request Parameters + String serviceType = execution.getVariable("serviceType") RequestParameters requestParameters = new RequestParameters() requestParameters.setaLaCarte(false) - requestParameters.setSubscriptionServiceType(execution.getVariable("serviceType")) + requestParameters.setSubscriptionServiceType(serviceType) requestParameters.setUserParams(userParams) //SubscriberInfo + String globalSubscriberId = execution.getVariable("globalSubscriberId") SubscriberInfo subscriberInfo = new SubscriberInfo() - subscriberInfo.setGlobalSubscriberId(execution.getVariable("globalSubscriberId")) + subscriberInfo.setGlobalSubscriberId(globalSubscriberId) //Owning Entity + String owningEntityId = execution.getVariable("owningEntityId") OwningEntity owningEntity = new OwningEntity() - owningEntity.setOwningEntityId(execution.getVariable("owningEntityId")) + owningEntity.setOwningEntityId(owningEntityId) //Project + String projectName = execution.getVariable("projectName") Project project = new Project() - project.setProjectName(execution.getVariable("projectName")) + project.setProjectName(projectName) RequestDetails requestDetails = new RequestDetails() requestDetails.setModelInfo(serviceModelInfo) @@ -500,17 +507,16 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { String requestPayload = mapper.writeValueAsString(requestDetailsMap) logger.debug("requestDetails "+requestPayload) execution.setVariable("requestPayload", requestPayload) + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: prepareSOMacroRequestPayLoad ****") } private String prepareVnfInstanceParamsJson(DelegateExecution execution) { - logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: prepareVnfInstanceParamsJson ****") + logger.debug(Prefix +" **** Enter DoAllocateCoreSharedSlice ::: prepareVnfInstanceParamsJson ****") List instanceParamsvalues = execution.getVariable("snssaiAndOrchStatusList") Map<String, Object> nSsai= new LinkedHashMap<>() nSsai.put("sNssai", instanceParamsvalues) String supportedsNssaiJson = mapper.writeValueAsString(nSsai) - //SupportedNssai - logger.debug("**** supportedsNssaiJson**** "+supportedsNssaiJson) logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: prepareVnfInstanceParamsJson ****") return supportedsNssaiJson } @@ -519,9 +525,13 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: sendPutRequestToSOMacro ****") try { String msoEndpoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution) - String url = msoEndpoint+"/serviceInstantiation/v7/serviceInstances/"+execution.getVariable("networkServiceInstanceId")+"/vnfs/"+execution.getVariable("vnfId") + String networkServiceInstanceId = execution.getVariable("networkServiceInstanceId") + String vnfId = execution.getVariable("vnfId") + String url = msoEndpoint+"/serviceInstantiation/v7/serviceInstances/"+networkServiceInstanceId+"/vnfs/"+vnfId String requestBody = execution.getVariable("requestPayload") - String encodeString = "Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==" + String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + String basicAuth = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) + String encodeString = utils.getBasicAuth(basicAuth, msoKey) logger.debug("msoEndpoint: "+msoEndpoint +" "+ "url: "+url +" requestBody: "+requestBody +" "+ "encodeString: "+encodeString) HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) httpClient.addAdditionalHeader("Authorization", encodeString) @@ -531,24 +541,28 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e } catch (any) { - String msg = Prefix+" Exception in DoAllocateCoreSharedSlice " + any.getCause() + String msg = Prefix+" Exception in DoAllocate Shared " + any.getCause() logger.error(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: sendPostRequestToSOMacro ****") } + /** + * Handle SO Response for PUT and prepare update operation status + * @param execution + */ private void handleSOResponse(Response httpResponse, DelegateExecution execution){ logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: handleSOResponse ****") + int soResponseCode = httpResponse.getStatus() logger.debug("soResponseCode : "+soResponseCode) if (soResponseCode >= 200 && soResponseCode < 204 && httpResponse.hasEntity()) { String soResponse = httpResponse.readEntity(String.class) logger.debug("soResponse: "+soResponse) - logger.debug("soResponse JsonUtil: "+jsonUtil.getJsonValue(soResponse, "requestReferences.requestId")) - def macroOperationId = jsonUtil.getJsonValue(soResponse, "requestReferences.requestId") - def requestSelfLink = jsonUtil.getJsonValue(soResponse, "requestReferences.requestSelfLink") + String macroOperationId = jsonUtil.getJsonValue(soResponse, "requestReferences.requestId") + String requestSelfLink = jsonUtil.getJsonValue(soResponse, "requestReferences.requestSelfLink") execution.setVariable("macroOperationId", macroOperationId) execution.setVariable("requestSelfLink", requestSelfLink) execution.setVariable("isSOTimeOut", "no") @@ -564,10 +578,11 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { public void getSOPUTProgress(DelegateExecution execution) { logger.debug(Prefix+ " **** Enter DoAllocateCoreSharedSlice ::: getSOPUTProgress ****") String url= execution.getVariable("requestSelfLink") - logger.debug("url "+url) HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) - //Hardcoding for now, will be updated in next patch - httpClient.addAdditionalHeader("Authorization", "Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==") + String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + String basicAuth = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) + String encodeString = utils.getBasicAuth(basicAuth, msoKey) + httpClient.addAdditionalHeader("Authorization", encodeString) httpClient.addAdditionalHeader("Accept", "application/json") Response httpResponse = httpClient.get() logger.debug("httpResponse "+httpResponse) @@ -586,71 +601,80 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { logger.debug(Prefix+ " **** Exit DoAllocateCoreSharedSlice ::: getSOPUTProgress ****") } - public void timeDelay(DelegateExecution execution) { + public void timeDelay() { try { logger.debug(Prefix+ " **** DoAllocateCoreSharedSlice ::: timeDelay going to sleep for 5 sec") Thread.sleep(5000) - logger.debug("**** DoAllocateCoreNonSharedSlice ::: timeDelay wakeup after 5 sec") + logger.debug("**** DoActivateCoreNSSI ::: timeDelay wakeup after 5 sec") } catch(InterruptedException e) { logger.error(Prefix+ " **** DoAllocateCoreSharedSlice ::: timeDelay exception" + e) } - } + } void prepareUpdateResourceOperationStatus(DelegateExecution execution) { logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: prepareUpdateResourceOperationStatus ****") //Prepare Update Status for PUT failure and success - if("COMPLETED".equals(execution.getVariable("requestState"))) { + if(execution.getVariable("isTimeOut").equals("YES")) { + logger.debug("TIMEOUT - SO PUT Failure") + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "SO PUT Failure") + } else { execution.setVariable("progress", "100") execution.setVariable("status", "finished") - execution.setVariable("operationContent", "AllocteCoreNSSI successful.") - logger.debug("Success ,result:${execution.getVariable("result")}, reason: ${execution.getVariable("reason")}") - } else { - logger.debug("SO PUT Failure") - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "SO PUT Failure") + execution.setVariable("operationContent", "AllocteCoreNSSI Shared successful.") + logger.debug("prepareFailureStatus,result:${execution.getVariable("result")}, reason: ${execution.getVariable("reason")}") } setResourceOperationStatus(execution) logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: prepareUpdateResourceOperationStatus ****") } + /** + * prepare ResourceOperation status + * @param execution + * @param operationType + */ private void setResourceOperationStatus(DelegateExecution execution) { logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: setResourceOperationStatus ****") - String serviceId = execution.getVariable("nssiId") + String serviceId = execution.getVariable("nsiId") String jobId = execution.getVariable("jobId") - String nsiId = execution.getVariable("nsiId") - String operationType = execution.getVariable("operationType") - logger.debug("serviceId: "+serviceId +" "+ " jobId: "+jobId +" "+ " nsiId: "+nsiId+" nssiId: "+nssiId+" operationType: "+operationType) + String nssiId = execution.getVariable("nssiId") + String operationType = "ALLOCATE" + String modelUuid= execution.getVariable("modelUuid") ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setJobId(jobId) resourceOperationStatus.setOperationId(jobId) - resourceOperationStatus.setResourceTemplateUUID(nsiId) - resourceOperationStatus.setResourceInstanceID(nssiId) + resourceOperationStatus.setResourceTemplateUUID(modelUuid) + resourceOperationStatus.setResourceInstanceID(nssiId) resourceOperationStatus.setOperType(operationType) - resourceOperationStatus.setStatus("finished") - resourceOperationStatus.setProgress("100") - resourceOperationStatus.setStatusDescription("Core Allocate successful") + resourceOperationStatus.setStatus(execution.getVariable("status")) + resourceOperationStatus.setProgress(execution.getVariable("progress")) + resourceOperationStatus.setStatusDescription(execution.getVariable("statusDescription")) requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: setResourceOperationStatus ****") } void prepareFailedOperationStatusUpdate(DelegateExecution execution){ logger.debug(Prefix + " **** Enter DoAllocateCoreSharedSlice ::: prepareFailedOperationStatusUpdate ****") - String serviceId = execution.getVariable("nsiId") + String serviceId = execution.getVariable("nsiId") String jobId = execution.getVariable("jobId") - String nsiId = execution.getVariable("nsiId") + String nssiId = execution.getVariable("nssiId") String operationType = "ALLOCATE" - logger.debug("serviceId: "+serviceId +" "+ " jobId: "+jobId +" "+ " nsiId: "+nsiId+" operationType: "+operationType) + //modelUuid String modelUuid= execution.getVariable("modelUuid") + logger.debug("serviceId: {}, jobId: {}, nssiId: {}, operationType: {}.", serviceId, jobId, nssiId, operationType) ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() resourceOperationStatus.setServiceId(serviceId) resourceOperationStatus.setJobId(jobId) resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceInstanceID(nssiId) resourceOperationStatus.setResourceTemplateUUID(modelUuid) resourceOperationStatus.setOperType(operationType) resourceOperationStatus.setProgress("0") resourceOperationStatus.setStatus("failed") - resourceOperationStatus.setStatusDescription("Core NSSI Allocate Failed") + resourceOperationStatus.setStatusDescription("Core NSSI Shared Allocate Failed") requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) logger.debug(Prefix + " **** Exit DoAllocateCoreSharedSlice ::: prepareFailedOperationStatusUpdate ****") } -}
\ No newline at end of file +} + 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 9221067cce..dd168519e5 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 @@ -297,7 +297,7 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { List<String> linkStrList = jsonUtil.StringArrayToList(linkArrayStr) for (String linkStr : linkStrList) { - String linkId = jsonUtil.getJsonValue(linkStr, "id") + String linkId = jsonUtil.getJsonValue(linkStr, "name") if (isBlank(linkId)) { linkId = "tn-nssmf-" + UUID.randomUUID().toString() } 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 8695946fd6..8859af25f6 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 @@ -28,6 +28,8 @@ import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils import org.onap.so.bpmn.common.scripts.OofUtils import org.onap.so.bpmn.common.scripts.RequestDBUtil import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.beans.nsmf.PerfReqEmbb +import org.onap.so.beans.nsmf.PerfReq import org.onap.so.db.request.beans.ResourceOperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -47,6 +49,9 @@ import org.onap.aai.domain.yang.Relationship 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.AllottedResource +import org.onap.aai.domain.yang.AllottedResources +import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.aaiclient.client.aai.entities.uri.AAISimplePluralUri import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.databind.SerializationFeature @@ -231,8 +236,28 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { Map<String, Object> profileInfo = objectMapper.readValue(execution.getVariable("RANSliceProfile"), Map.class) ServiceInstance ranSliceProfileInstance = execution.getVariable("ranSliceProfileInstance") profileInfo.put("sST",ranSliceProfileInstance.getServiceType()) - profileInfo.put("snssaiList",ranSliceProfileInstance.getEnvironmentContext()) - profileInfo.put("plmnIdList",ranSliceProfileInstance.getServiceInstanceLocationId()) + profileInfo.put("snssaiList",execution.getVariable("snssaiList")) + profileInfo.put("plmnIdList",Arrays.asList(ranSliceProfileInstance.getServiceInstanceLocationId())) + profileInfo.put("uEMobilityLevel",profileInfo.get("ueMobilityLevel")) + profileInfo.put("cSAvailabilityTarget",profileInfo.get("csAvailabilityTarget")) + profileInfo.put("maxNumberofPDUSession",profileInfo.get("maxNumberOfPDUSession")) + profileInfo.put("maxNumberofUEs",profileInfo.get("maxNumberOfUEs")) + + PerfReq perfReq = new PerfReq(); + List<PerfReqEmbb> perfReqEmbbs = new ArrayList<>(); + PerfReqEmbb perfReqEmbb = new PerfReqEmbb(); + perfReqEmbb.setExpDataRateDL(profileInfo.get("expDataRateDL")); + perfReqEmbb.setExpDataRateUL(profileInfo.get("expDataRateUL")); + perfReqEmbbs.add(perfReqEmbb); + perfReq.setPerfReqEmbbList(perfReqEmbbs); + profileInfo.put("perfReq",perfReq) + + profileInfo.remove("maxNumberOfUEs") + profileInfo.remove("resourceVersion") + profileInfo.remove("csAvailabilityTarget") + profileInfo.remove("ueMobilityLevel") + profileInfo.remove("maxNumberOfPDUSession") + profileInfo.remove("profileId") String modelUuid = ranSliceProfileInstance.getModelVersionId() String modelInvariantUuid = ranSliceProfileInstance.getModelInvariantId() String modelName = execution.getVariable("servicename") @@ -308,23 +333,25 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { logger.debug("getNssisFromAai ranConstituentNssis : "+ranConstituentNssis.toString()) ranConstituentNssis.each { key, val -> switch(key) { - case "AN-NF": + case "AN_NF": execution.setVariable("ANNF_NSSI", val.getServiceInstanceId()) execution.setVariable("ANNF_nssiName", val.getServiceInstanceName()) execution.setVariable("ANNF_modelInvariantUuid", val.getModelInvariantId()) execution.setVariable("ANNF_modelUuid", val.getModelVersionId()) break - case "TN-FH": + case "TN_FH": execution.setVariable("TNFH_NSSI", val.getServiceInstanceId()) execution.setVariable("TNFH_nssiName", val.getServiceInstanceName()) execution.setVariable("TNFH_modelInvariantUuid", val.getModelInvariantId()) execution.setVariable("TNFH_modelUuid", val.getModelVersionId()) + getConnectionLinks(execution, key, val) break - case "TN-MH": + case "TN_MH": execution.setVariable("TNMH_NSSI", val.getServiceInstanceId()) execution.setVariable("TNMH_nssiName", val.getServiceInstanceName()) execution.setVariable("TNMH_modelInvariantUuid", val.getModelInvariantId()) execution.setVariable("TNMH_modelUuid", val.getModelVersionId()) + getConnectionLinks(execution, key, val) break default: logger.error("No expected match found for current domainType "+ key) @@ -333,6 +360,50 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { } } + + private void getConnectionLinks(DelegateExecution execution, String domainType, ServiceInstance instance) { + AllottedResources allottedResources = instance.getAllottedResources() + if(allottedResources == null) { + String msg = "AllottedResourceFromAAI doesn't exist. " + instance + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + List<AllottedResource> AllottedResourceList = allottedResources.getAllottedResource() + for(AllottedResource allottedResource : AllottedResourceList) { + List<Relationship> relationshipList = allottedResource.getRelationshipList().getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo.toLowerCase() == "logical-link") { + String relatioshipurl = relationship.getRelatedLink() + String logicalLinkId= + relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, relatioshipurl.length()) + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(logicalLinkId)) + if (!client.exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, + "Resource was not found in aai: ${logicalLinkId}") + } + AAIResultWrapper wrapper01 = client.get(uri, NotFoundException.class) + Optional<org.onap.aai.domain.yang.LogicalLink> resource = wrapper01.asBean(org.onap.aai.domain.yang.LogicalLink.class) + if (resource.isPresent()) { + org.onap.aai.domain.yang.LogicalLink logicalLinkInstance = resource.get() + if(domainType.equalsIgnoreCase("TN-FH")) + { + execution.setVariable("tranportEp_ID_RU",logicalLinkInstance.getLinkName()) + execution.setVariable("tranportEp_ID_DUIN",logicalLinkInstance.getLinkName2()) + } + else if(domainType.equalsIgnoreCase("TN-MH")) + { + execution.setVariable("tranportEp_ID_DUEG",logicalLinkInstance.getLinkName()) + execution.setVariable("tranportEp_ID_CUIN",logicalLinkInstance.getLinkName2()) + } + } + } + } + } + } + def createSliceProfiles = { DelegateExecution execution -> logger.debug(Prefix+"createSliceProfiles method start") anNssmfUtils.createSliceProfilesInAai(execution) @@ -446,8 +517,6 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { JsonObject serviceInfo = new JsonObject() serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) - String sST = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST") - serviceInfo.addProperty("sST", sST) serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("plmnIdList"))) serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId")) serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType")) @@ -506,13 +575,13 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { logger.debug("getSliceProfilesFromAai ranConstituentSliceProfiles : "+ranConstituentSliceProfiles.toString()) ranConstituentSliceProfiles.each { key, val -> switch(key) { - case "AN-NF": + case "AN_NF": execution.setVariable("ANNF_sliceProfileInstanceId", val.getServiceInstanceId()) break - case "TN-FH": + case "TN_FH": execution.setVariable("TNFH_sliceProfileInstanceId", val.getServiceInstanceId()) break - case "TN-MH": + case "TN_MH": execution.setVariable("TNMH_sliceProfileInstanceId", val.getServiceInstanceId()) break default: @@ -655,7 +724,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai: ${serviceInstanceId} related to ${instanceId}") } - AAIResultWrapper wrapper01 = client01.get(uri01, NotFoundException.class) + AAIResultWrapper wrapper01 = client01.get(uri01.depth(Depth.TWO), NotFoundException.class) Optional<ServiceInstance> serviceInstance = wrapper01.asBean(ServiceInstance.class) if (serviceInstance.isPresent()) { ServiceInstance instance = serviceInstance.get() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy index bb8e516c3b..10846d4cfa 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy @@ -28,6 +28,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils import com.fasterxml.jackson.databind.ObjectMapper +import com.google.gson.Gson import com.google.gson.JsonObject import com.google.gson.JsonParser import java.time.Instant @@ -114,7 +115,7 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { logger.debug(Prefix+"createSdnrRequest method start") String callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.message.endpoint") + "/AsyncSdnrResponse/"+execution.getVariable("msoRequestId") String modifyAction = execution.getVariable("modifyAction") - String sdnrRequest = buildSdnrAllocateRequest(execution, modifyAction, "InstantiateRANSlice", callbackUrl) + String sdnrRequest = buildSdnrAllocateRequest(execution, modifyAction, "instantiateRANSlice", callbackUrl) execution.setVariable("createNSSI_sdnrRequest", sdnrRequest) execution.setVariable("createNSSI_timeout", "PT10M") execution.setVariable("createNSSI_correlator", execution.getVariable("msoRequestId")) @@ -152,7 +153,7 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { if(action.equals("allocate")) { sliceProfile = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class) sliceProfile.put("sliceProfileId", execution.getVariable("sliceProfileId")) - sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSessions")) + sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSession")) sliceProfile.put("uLThptPerSlice", sliceProfile.get("expDataRateUL")) sliceProfile.put("dLThptPerSlice", sliceProfile.get("expDataRateDL")) action = "modify-"+action @@ -174,9 +175,12 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { commonHeader.addProperty("request-id", requestId) commonHeader.addProperty("sub-request-id", "1") commonHeader.add("flags", new JsonObject()) - payloadInput.addProperty("sliceProfile", sliceProfile.toString()) + Gson jsonConverter = new Gson() + payloadInput.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile)) payloadInput.addProperty("RANNFNSSIId", execution.getVariable("serviceInstanceID")) payloadInput.addProperty("callbackURL", callbackUrl) + payloadInput.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId")) + payloadInput.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType")) payload.add("input", payloadInput) input.add("common-header", commonHeader) input.addProperty("action", action) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy index 9440b42124..25cb2f57f6 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy @@ -24,7 +24,11 @@ import com.fasterxml.jackson.databind.ObjectMapper import groovy.json.JsonSlurper import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.aai.domain.yang.* +import org.onap.aai.domain.yang.AllottedResource +import org.onap.aai.domain.yang.AllottedResources +import org.onap.aai.domain.yang.NetworkPolicy +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aai.domain.yang.SliceProfile 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 @@ -38,7 +42,9 @@ import org.onap.so.db.request.beans.ResourceOperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory -import static org.apache.commons.lang3.StringUtils.* +import static org.apache.commons.lang3.StringUtils.isBlank +import static org.apache.commons.lang3.StringUtils.isEmpty +import static org.apache.commons.lang3.StringUtils.isNotBlank public class DoModifyTnNssi extends AbstractServiceTaskProcessor { String Prefix = "TNMOD_" @@ -150,26 +156,31 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { AAIResourceUri ssServiceuri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) try { - if (resourceClient.exists(ssServiceuri)) { - ServiceInstance ss = resourceClient.get(ServiceInstance.class, ssServiceuri) - - AllottedResources ars = ss.getAllottedResources() - List<AllottedResource> arList = ars.getAllottedResource() - List<String> arIdList = new ArrayList<>() - Map<String, String> policyMap = new HashMap<>() - Map<String, List<String>> logicalLinksMap = new HashMap<>() - for (AllottedResource ar : arList) { - String arId = ar.getId() - arIdList.add(arId) - String policyId = tnNssmfUtils.getPolicyIdFromAr(execution, serviceInstanceId, arId, true) - policyMap.put(arId, policyId) - List<String> logicalLinkList = tnNssmfUtils.getLogicalLinkNamesFromAr(execution, - serviceInstanceId, arId, true) - logicalLinksMap.put(arId, logicalLinkList) + Optional<ServiceInstance> ssOpt = resourceClient.get(ServiceInstance.class, ssServiceuri) + if (ssOpt.isPresent()) { + ServiceInstance ss = ssOpt.get() + AllottedResources ars = tnNssmfUtils.getAllottedResourcesFromAai(execution, serviceInstanceId, true) + if (ars != null) { + List<AllottedResource> arList = ars.getAllottedResource() + List<String> arIdList = new ArrayList<>() + Map<String, String> policyMap = new HashMap<>() + Map<String, List<String>> logicalLinksMap = new HashMap<>() + for (AllottedResource ar : arList) { + String arId = ar.getId() + arIdList.add(arId) + String policyId = tnNssmfUtils.getPolicyIdFromAr(execution, serviceInstanceId, arId, true) + policyMap.put(arId, policyId) + List<String> logicalLinkList = tnNssmfUtils.getLogicalLinkNamesFromAr(execution, + serviceInstanceId, arId, true) + logicalLinksMap.put(arId, logicalLinkList) + } + execution.setVariable("arIdList", arIdList) + execution.setVariable("arPolicyMap", policyMap) + execution.setVariable("arLogicalLinkMap", logicalLinksMap) + } else { + logger.error("ERROR: getExistingServiceInstance: getAllottedResources() returned null. ss=" + ss + .toString()) } - execution.setVariable("arIdList", arIdList) - execution.setVariable("arPolicyMap", policyMap) - execution.setVariable("arLogicalLinkMap", logicalLinksMap) } else { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai to " + "associate allotted resource for service :" + serviceInstanceId) @@ -177,7 +188,7 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception ex) { - String msg = "Exception in getServiceInstance. " + ex.getMessage() + String msg = "Exception in getExistingServiceInstance. " + ex.getMessage() logger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } @@ -195,6 +206,7 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { //ss.setServiceInstanceId(ssInstanceId) String serviceStatus = "modified" ss.setOrchestrationStatus(serviceStatus) + ss.setEnvironmentContext("tn") AAIResourcesClient client = getAAIClient() AAIResourceUri uri = AAIUriFactory.createResourceUri( AAIFluentTypeBuilder.business() @@ -279,14 +291,15 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { void updateLogicalLinksInNetwork(DelegateExecution execution, String networkJsonStr) { try { - String arId = getValidArId(jsonUtil.getJsonValue(networkJsonStr, "id")) + String arId = getValidArId(execution, jsonUtil.getJsonValue(networkJsonStr, "id")) String linkArrayStr = jsonUtil.getJsonValue(networkJsonStr, "connectionLinks") updateLogicalLinksInAr(execution, arId, linkArrayStr) } catch (BpmnError e) { throw e } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, - "Exception in updateLogicalLinksInNetwork" + ex.getMessage()) + String msg = String.format("ERROR: updateLogicalLinksInNetwork: exception: %s", ex.getMessage()) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); } } @@ -351,7 +364,7 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { try { int maxBw = getMaxBw(execution) - String arId = getValidArId(jsonUtil.getJsonValue(networkJsonStr, "id")) + String arId = getValidArId(execution, jsonUtil.getJsonValue(networkJsonStr, "id")) Map<String, String> policyMap = execution.getVariable("arPolicyMap") String policyId = policyMap.get(arId) if (isBlank(policyId)) { @@ -365,8 +378,9 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, - "Exception in updateNetworkPolicy" + ex.getMessage()) + String msg = String.format("ERROR: updateNetworkPolicy: exception: %s", ex.getMessage()) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); } } @@ -428,7 +442,7 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { try { String serviceInstanceId = execution.getVariable("sliceServiceInstanceId") - String sdncRequest = tnNssmfUtils.buildSDNCRequest(execution, serviceInstanceId, "modify") + String sdncRequest = tnNssmfUtils.buildSDNCRequest(execution, serviceInstanceId, "update") execution.setVariable("TNNSSMF_SDNCRequest", sdncRequest) logger.debug("Outgoing SDNCRequest is: \n" + sdncRequest) @@ -483,6 +497,7 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { ResourceOperationStatus roStatus = tnNssmfUtils.buildRoStatus(modelUuid, ssInstanceId, jobId, nsiId, operType, status, progress, statusDescription) + logger.debug("prepareUpdateJobStatus: roStatus={}", roStatus) requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } 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 4624cdafe9..fc21ed4a5e 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 @@ -22,17 +22,19 @@ package org.onap.so.bpmn.infrastructure.scripts import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.AllottedResources import org.onap.aai.domain.yang.LogicalLink import org.onap.aai.domain.yang.NetworkPolicy import org.onap.aai.domain.yang.Relationship import org.onap.aai.domain.yang.ServiceInstance import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.AAIVersion import org.onap.aaiclient.client.aai.entities.AAIResultWrapper import org.onap.aaiclient.client.aai.entities.Relationships +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.AAIUriFactory import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder -import org.onap.aaiclient.client.generated.fluentbuilders.Activities import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils @@ -47,7 +49,7 @@ import org.slf4j.LoggerFactory import static org.apache.commons.lang3.StringUtils.isBlank class TnNssmfUtils { - static final String AAI_VERSION = "v23" + static final String AAI_VERSION = AAIVersion.LATEST private static final Logger logger = LoggerFactory.getLogger(TnNssmfUtils.class); @@ -91,6 +93,9 @@ class TnNssmfUtils { case "deactivate": reqAction = "DeactivateTransportSliceInstance" break + case "update": + reqAction = "ModifyTransportSliceInstance" + break default: reqAction = svcAction } @@ -433,7 +438,7 @@ class TnNssmfUtils { return null } - return si.modelVersionId() + return si.getModelVersionId() } AAIResourceUri buildNetworkPolicyUri(String networkPolicyId) { @@ -456,6 +461,52 @@ class TnNssmfUtils { return allottedResourceUri } + AAIPluralResourceUri buildAllottedResourcesUri(DelegateExecution execution, String serviceInstanceId) { + + AAIPluralResourceUri arsUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(serviceInstanceId) + .allottedResources()) + + return arsUri + } + + AllottedResources getAllottedResourcesFromAai(DelegateExecution execution, String serviceInstanceId, boolean exceptionOnErr) { + AllottedResources res + try { + AAIResourcesClient client = new AAIResourcesClient() + + AAIPluralResourceUri arsUri = buildAllottedResourcesUri(execution, serviceInstanceId) + + //AAIResultWrapper wrapperAllotted = client.get(arsUri, NotFoundException.class) + //Optional<AllottedResources> allAllotted = wrapperAllotted.asBean(AllottedResources.class) + //AllottedResources allottedResources = allAllotted.get() + + Optional<AllottedResources> arsOpt = client.get(AllottedResources.class, arsUri) + if (arsOpt.isPresent()) { + res = arsOpt.get() + return res + } else { + String msg = String.format("ERROR: getAllottedResourcesFromAai: ars not found. nssiId=%s", serviceInstanceId) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } catch (BpmnError e) { + if (exceptionOnErr) { + throw e; + } + } catch (Exception ex) { + if (exceptionOnErr) { + String msg = String.format("ERROR: getAllottedResourcesFromAai: %s", ex.getMessage()) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + + return res + } String getPolicyIdFromAr(DelegateExecution execution, String serviceInstanceId, String arId, boolean exceptionOnErr) { @@ -464,15 +515,15 @@ class TnNssmfUtils { AAIResourcesClient client = new AAIResourcesClient() AAIResourceUri arUri = buildAllottedResourceUri(execution, serviceInstanceId, arId) - List<AAIResourceUri> logicalLinkUriList = getRelationshipUriListInAai(execution, arUri, + List<AAIResourceUri> policyUriList = getRelationshipUriListInAai(execution, arUri, AAIFluentTypeBuilder.Types.NETWORK_POLICY, exceptionOnErr) - for (AAIResourceUri logicalLinkUri : logicalLinkUriList) { - Optional<NetworkPolicy> policyOpt = client.get(NetworkPolicy.class, logicalLinkUri) + for (AAIResourceUri policyUri : policyUriList) { + Optional<NetworkPolicy> policyOpt = client.get(NetworkPolicy.class, policyUri) if (policyOpt.isPresent()) { NetworkPolicy policy = policyOpt.get() return policy.getNetworkPolicyId() } else { - String msg = String.format("ERROR: getLogicalLinkNamesFromAr: logicalLinkUri=%s", logicalLinkUri) + String msg = String.format("ERROR: getPolicyIdFromAr: arUri=%s", policyUri) logger.error(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) } @@ -483,7 +534,7 @@ class TnNssmfUtils { } } catch (Exception ex) { if (exceptionOnErr) { - String msg = String.format("ERROR: getLogicalLinkNamesFromAr: %s", ex.getMessage()) + String msg = String.format("ERROR: getPolicyIdFromAr: %s", ex.getMessage()) logger.error(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) } @@ -494,7 +545,8 @@ class TnNssmfUtils { List<AAIResourceUri> getRelationshipUriListInAai(DelegateExecution execution, - AAIResourceUri uri, Activities.Info info, + AAIResourceUri uri, + Object info, boolean exceptionOnErr) { AAIResourcesClient client = new AAIResourcesClient() AAIResultWrapper wrapper = client.get(uri); |