Fix bugs found in TN Slicing integration involving OOF
[so.git] / bpmn / so-bpmn-infrastructure-common / src / main / groovy / org / onap / so / bpmn / infrastructure / scripts / DoAllocateAccessNSSI.groovy
index a4d503a..54fa2ab 100644 (file)
@@ -102,7 +102,7 @@ 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 plmnIdList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "pLMNIdList"))
                         String jsonArray = jsonUtil.getJsonValue(sliceProfile, "coverageAreaTAList")
                         List<Integer> list = new ArrayList<>();
                         JSONArray arr = new JSONArray(jsonArray);
@@ -121,7 +121,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                        } else {
                                execution.setVariable("sliceProfileId", sliceProfileId)
                                execution.setVariable("snssaiList", snssaiList)
-                               execution.setVariable("plmnIdList", plmnIdList)
+                               execution.setVariable("pLMNIdList", plmnIdList)
                                execution.setVariable("coverageAreaTAList", coverageAreaTAList)
                        }
                        String nsiName = jsonUtil.getJsonValue(sliceParams, "nsiInfo.nsiName")
@@ -190,6 +190,8 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                //RAN NSST decomposition
                String ranModelVersion = ranNsstServiceDecomposition.getModelInfo().getModelVersion()
                String ranModelName = ranNsstServiceDecomposition.getModelInfo().getModelName()
+               String serviceCategory=ranNsstServiceDecomposition.getServiceCategory()
+               logger.debug("serviceCategory : "+serviceCategory)
                List<ServiceProxy> serviceProxyList = ranNsstServiceDecomposition.getServiceProxy()
                List<String> nsstInfoList = new ArrayList<>()
                for(ServiceProxy serviceProxy : serviceProxyList)
@@ -198,10 +200,10 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                        String nsstModelInvariantUuid = serviceProxy.getModelInfo().getModelInvariantUuid()
                        String name = serviceProxy.getModelInfo().getModelName()
                        String nsstServiceModelInfo = """{
-            "UUID":"${nsstModelUuid}",
-            "invariantUUID":"${nsstModelInvariantUuid}",
-            "name":"${name}"
-             }"""
+                               "UUID":"${nsstModelUuid}",
+                               "invariantUUID":"${nsstModelInvariantUuid}",
+                               "name":"${name}"
+                        }"""
                        nsstInfoList.add(nsstServiceModelInfo)
                }
                int currentIndex=0
@@ -212,12 +214,19 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                        logger.info(msg)
                        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
                }
+                if(maxIndex == 1) {
+                        logger.info("RAN NSST have only RAN NF NSST")
+                        execution.setVariable("ranNfSliceProfile", execution.getVariable("sliceProfile"))
+                        execution.setVariable("IsRANNfAlonePresent", true)
+                }
                execution.setVariable("ranNsstInfoList", objectMapper.writeValueAsString(nsstInfoList))
-               execution.setVariable("ranModelVersion", ranModelVersion)
-               execution.setVariable("ranModelName", ranModelName)
                execution.setVariable("currentIndex",currentIndex)
                execution.setVariable("maxIndex",maxIndex)
+               execution.setVariable("ranModelVersion", ranModelVersion)
+               execution.setVariable("ranModelName", ranModelName)
                logger.debug(Prefix+"processDecomposition maxIndex value - "+maxIndex)
+
+               execution.setVariable("serviceCategory",serviceCategory)
        }
 
        /*
@@ -360,7 +369,6 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                modifySliceParams.addProperty("snssaiList", snssaiList)
                modifySliceParams.addProperty("sliceProfileId", sliceProfileId)
                modifySliceParams.addProperty("nsiInfo", nsiInfo)
-               modifySliceParams.addProperty("scriptName", scriptName)
                
                execution.setVariable("modifySliceParams", modifySliceParams.toString())
                //create operation status in request db
@@ -388,7 +396,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
                serviceInfo.addProperty("nssiName", execution.getVariable("servicename"))
                 serviceInfo.addProperty("sST", execution.getVariable("sst"))
-               serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("plmnIdList")))
+               serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("pLMNIdList")))
                serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
                serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
                serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("modelInvariantUuid"))
@@ -428,28 +436,28 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                ServiceDecomposition decomposedNsst = execution.getVariable("nsstServiceDecomposition")
                logger.debug("decomposedNsst : "+decomposedNsst.toString())
                
-               String nsstType = decomposedNsst.getServiceRole() //domainType
+               String nsstType = decomposedNsst.getServiceCategory() //domainType
                String modelVersion = decomposedNsst.getModelInfo().getModelVersion()
                String modelName = decomposedNsst.getModelInfo().getModelName()
                String modelUuid = decomposedNsst.getModelInfo().getModelUuid()
                String modelInvariantUuid = decomposedNsst.getModelInfo().getModelInvariantUuid()
                
                switch(nsstType) {
-                       case "AN_NF":
+                       case "AN NF NSST":
                                execution.setVariable("ANNF_modelInvariantUuid", modelInvariantUuid)
                                execution.setVariable("ANNF_modelUuid", modelUuid)
                                execution.setVariable("ANNF_modelVersion", modelVersion)
                                execution.setVariable("ANNF_modelName", modelName)
                                execution.setVariable("ANNF_ServiceDecomposition", decomposedNsst)
                                break
-                       case "TN_FH":
+                       case "TN FH NSST":
                                execution.setVariable("TNFH_modelInvariantUuid", modelInvariantUuid)
                                execution.setVariable("TNFH_modelUuid", modelUuid)
                                execution.setVariable("TNFH_modelVersion", modelVersion)
                                execution.setVariable("TNFH_modelName", modelName)
                                execution.setVariable("TNFH_ServiceDecomposition", decomposedNsst)
                                break
-                       case "TN_MH":
+                       case "TN MH NSST":
                                execution.setVariable("TNMH_modelInvariantUuid", modelInvariantUuid)
                                execution.setVariable("TNMH_modelUuid", modelUuid)
                                execution.setVariable("TNMH_modelVersion", modelVersion)
@@ -480,9 +488,12 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                //build oof request body
                boolean ranNfNssiPreferReuse = execution.getVariable("ranNfNssiPreferReuse");
                String requestId = execution.getVariable("msoRequestId")
+               String serviceCategory = execution.getVariable("serviceCategory")
                String messageType = "NSSISelectionResponse"
-               List<String> ranConstituentSliceProfiles = jsonUtil.StringArrayToList(execution.getVariable("RanConstituentSliceProfiles"))
-               anNssmfUtils.createDomainWiseSliceProfiles(ranConstituentSliceProfiles, execution)
+                if(execution.getVariable("maxIndex") > 1) {
+                    List<String> ranConstituentSliceProfiles = jsonUtil.StringArrayToList(execution.getVariable("RanConstituentSliceProfiles") as String)
+                    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")
@@ -558,13 +569,17 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                 ANServiceInstance.setServiceType(execution.getVariable("sst"))
                String serviceStatus = "deactivated"
                ANServiceInstance.setOrchestrationStatus(serviceStatus)
-               String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "plmnIdList")
+               String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "pLMNIdList")
                 ANServiceInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0))
                String serviceRole = "nssi"
                ANServiceInstance.setServiceRole(serviceRole)
                 List<String> snssaiList = execution.getVariable("snssaiList")
                String snssai = snssaiList.get(0)
-               //ANServiceInstance.setEnvironmentContext(snssai)
+                //ANServiceInstance.setEnvironmentContext(snssai)
+               String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
+               String modelUuid = execution.getVariable("modelUuid") as String
+               ANServiceInstance.setModelInvariantId(modelInvariantUuid)
+               ANServiceInstance.setModelVersionId(modelUuid)
                 ANServiceInstance.setEnvironmentContext(execution.getVariable("networkType")) //Network Type
                ANServiceInstance.setWorkloadContext("AN") //domain Type
                
@@ -617,47 +632,46 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                //create RAN NSSI 
                org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
                org.onap.aai.domain.yang.ServiceInstance ANNFServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+               String serviceCategory = execution.getVariable("serviceCategory")
+               String serviceStatus = "deactivated"
+               String serviceRole = "nssi"
                //AN instance creation
-               ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId"))
+               ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId") as String)
                String sliceInstanceName = execution.getVariable("servicename")
                ANServiceInstance.setServiceInstanceName(sliceInstanceName)
-               String serviceType = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST")
-                ANServiceInstance.setServiceType(execution.getVariable("sst"))
-               String serviceStatus = "deactivated"
+               ANServiceInstance.setServiceType(execution.getVariable("sst") as String)
                ANServiceInstance.setOrchestrationStatus(serviceStatus)
-               String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "plmnIdList")
-               ANServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
-               String serviceRole = "nssi"
+               String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "pLMNIdList") as String
+                ANServiceInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0))           
                ANServiceInstance.setServiceRole(serviceRole)
-               List<String> snssaiList = execution.getVariable("snssaiList")
+               List<String> snssaiList = jsonUtil.StringArrayToList(execution.getVariable("snssaiList") as String)
                String snssai = snssaiList.get(0)
-               //ANServiceInstance.setEnvironmentContext(snssai)
-                ANServiceInstance.setEnvironmentContext(execution.getVariable("networkType"))
-                String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
-                String modelUuid = execution.getVariable("modelUuid")
-                ANServiceInstance.setModelInvariantId(modelInvariantUuid)
-                ANServiceInstance.setModelVersionId(modelUuid)
+               String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
+               String modelUuid = execution.getVariable("modelUuid") as String
+               ANServiceInstance.setModelInvariantId(modelInvariantUuid)
+               ANServiceInstance.setModelVersionId(modelUuid)
+                ANServiceInstance.setEnvironmentContext(execution.getVariable("networkType")) //Network Type
                ANServiceInstance.setWorkloadContext("AN")
-               String serviceFunctionAn = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "resourceSharingLevel")
+               String serviceFunctionAn = jsonUtil.getJsonValue(execution.getVariable("sliceProfile") as String, "resourceSharingLevel")
                ANServiceInstance.setServiceFunction(serviceFunctionAn)
-               logger.debug("completed AN service instance build "+ ANServiceInstance.toString())
+               logger.debug("completed AN service instance build " + ANServiceInstance.toString())
                //create RAN NF NSSI
-               ANNFServiceInstance.setServiceInstanceId(execution.getVariable("RANNFServiceInstanceId"))
-               sliceInstanceName = "nssi_"+execution.getVariable("ANNF_modelName")
+               ANNFServiceInstance.setServiceInstanceId(execution.getVariable("RANNFServiceInstanceId") as String)
+                String ANNF_nssiInstanceId = UUID.randomUUID().toString()
+               sliceInstanceName = "nssi_an_nf_" + ANNF_nssiInstanceId
                ANNFServiceInstance.setServiceInstanceName(sliceInstanceName)
-               ANNFServiceInstance.setServiceType(execution.getVariable("sst"))
+               ANNFServiceInstance.setServiceType(execution.getVariable("sst") as String)
                ANNFServiceInstance.setOrchestrationStatus(serviceStatus)
-               serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "plmnIdList")
+               serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile") as String, "pLMNIdList")
                 ANNFServiceInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0))
                ANNFServiceInstance.setServiceRole(serviceRole)
-               snssaiList = execution.getVariable("snssaiList")
+               snssaiList = jsonUtil.StringArrayToList(execution.getVariable("snssaiList") as String)
                snssai = snssaiList.get(0)
-               //ANNFServiceInstance.setEnvironmentContext(snssai)
-                ANNFServiceInstance.setEnvironmentContext(execution.getVariable("networkType"))
+               ANNFServiceInstance.setEnvironmentContext(execution.getVariable("networkType") as String)
                 ANNFServiceInstance.setModelInvariantId(execution.getVariable("ANNF_modelInvariantUuid"))
                 ANNFServiceInstance.setModelVersionId(execution.getVariable("ANNF_modelUuid"))
                ANNFServiceInstance.setWorkloadContext("AN_NF")
-               String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "resourceSharingLevel")
+               String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile") as String, "resourceSharingLevel")
                ANNFServiceInstance.setServiceFunction(serviceFunctionAnnf)
                logger.debug("completed AN service instance build "+ ANNFServiceInstance.toString())
                
@@ -665,10 +679,10 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                try {
        
                        AAIResourcesClient client = new AAIResourcesClient()
-                       AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANServiceInstanceId")))
+                       AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId") as String).serviceSubscription(execution.getVariable("subscriptionServiceType") as String).serviceInstance(execution.getVariable("RANServiceInstanceId") as String))
                        client.create(nssiServiceUri, ANServiceInstance)
        
-                       AAIResourceUri nssiServiceUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANNFServiceInstanceId")))
+                       AAIResourceUri nssiServiceUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId") as String).serviceSubscription(execution.getVariable("subscriptionServiceType") as String).serviceInstance(execution.getVariable("RANNFServiceInstanceId") as String))
                        client.create(nssiServiceUri1, ANNFServiceInstance)
        
                } catch (BpmnError e) {
@@ -679,7 +693,9 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
                }
                //end point update
-               createEndPointsInAai(execution)
+               if (!execution.getVariable("IsRANNfAlonePresent")) {
+                       createEndPointsInAai(execution)
+               }
        }
        def prepareTnFhRequest = { DelegateExecution execution ->
                logger.debug(Prefix+"prepareTnFhRequest method start")
@@ -735,7 +751,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                JsonObject serviceInfo = new JsonObject()
                serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
                 serviceInfo.addProperty("sST", execution.getVariable("sst"))
-               serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("plmnIdList")))
+               serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("pLMNIdList")))
                serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
                serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
                if(domainType.equals("TN_FH")) {
@@ -803,64 +819,96 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
 
        def updateAairelationships = { DelegateExecution execution ->
                logger.debug(Prefix + "updateAairelationships Start")
+               String serviceCategory = execution.getVariable("serviceCategory")
                String msg = ""
-               try {
-                       def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
-                       def TNFH_serviceInstanceId = execution.getVariable("TNFH_NSSI")
-                       def TNMH_serviceInstanceId = execution.getVariable("TNMH_NSSI")
-                       def AN_profileInstanceId = execution.getVariable("sliceProfileId")
-                       def AN_NSSI = execution.getVariable("RANServiceInstanceId")
-                       def ANNF_profileInstanceId = execution.getVariable("ANNF_sliceProfileInstanceId")
-                       def TNFH_profileInstanceId = execution.getVariable("TNFH_sliceProfileInstanceId")
-                       def TNMH_profileInstanceId = execution.getVariable("TNMH_sliceProfileInstanceId")
-                       String globalSubscriberId = execution.getVariable("globalSubscriberId")
-                       String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
-
-                       Relationship ANNF_relationship = new Relationship()
-                       Relationship TNFH_relationship = new Relationship()
-                       Relationship TNMH_relationship = new Relationship()
-                       
-                       String ANNF_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_profileInstanceId}"
-                       String TNFH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_profileInstanceId}"
-                       String TNMH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_profileInstanceId}"
-                       
-                       String ANNF_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_serviceInstanceId}"
-                       String TNFH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_serviceInstanceId}"
-                       String TNMH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_serviceInstanceId}"
-                       
-                       ANNF_relationship.setRelatedLink(ANNF_relatedLink)
-                       ANNF_relationship.setRelatedTo("service-instance")
-                       ANNF_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
-                       TNFH_relationship.setRelatedLink(TNFH_relatedLink)
-                       TNFH_relationship.setRelatedTo("service-instance")
-                       TNFH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
-                       TNMH_relationship.setRelatedLink(TNMH_relatedLink)
-                       TNMH_relationship.setRelatedTo("service-instance")
-                       TNMH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
-                       
-                       // create SliceProfile and NSSI relationship in AAI
-                       anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,ANNF_serviceInstanceId)
-                       anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,TNFH_serviceInstanceId)
-                       anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,TNMH_serviceInstanceId)
-                       anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,AN_profileInstanceId)
-                       anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,AN_profileInstanceId)
-                       anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,AN_profileInstanceId)
-                       
-                       //create AN NSSI and ANNF,TNFH,TNMH relationship in AAI
-                       ANNF_relationship.setRelatedLink(ANNF_NSSI_relatedLink)
-                       TNFH_relationship.setRelatedLink(TNFH_NSSI_relatedLink)
-                       TNMH_relationship.setRelatedLink(TNMH_NSSI_relatedLink)
-                       anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,AN_NSSI)
-                       anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,AN_NSSI)
-                       anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,AN_NSSI)
+               if (execution.getVariable("IsRANNfAlonePresent")) {
+                       try {
+                               def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
+                               def AN_profileInstanceId = execution.getVariable("sliceProfileId")
+                                def AN_NSSI = execution.getVariable("RANServiceInstanceId")
+                               def ANNF_profileInstanceId = execution.getVariable("ANNF_sliceProfileInstanceId")
+                               String globalSubscriberId = execution.getVariable("globalSubscriberId")
+                               String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
 
-               } catch (BpmnError e) {
-                       throw e
-               } catch (Exception ex) {
+                               Relationship ANNF_relationship = new Relationship()
+                               String ANNF_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_profileInstanceId}"
+                               String ANNF_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_serviceInstanceId}"
+                               ANNF_relationship.setRelatedLink(ANNF_relatedLink)
+                               ANNF_relationship.setRelatedTo("service-instance")
+                               ANNF_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
+                               anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship, ANNF_serviceInstanceId)
+                               anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship, AN_profileInstanceId)
+                               ANNF_relationship.setRelatedLink(ANNF_NSSI_relatedLink)
+                               anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship, AN_NSSI)
 
-                       msg = "Exception in DoCreateE2EServiceInstance.createCustomRelationship. " + ex.getMessage()
-                       logger.info(msg)
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+                       } catch (BpmnError e) {
+                               throw e
+                       } catch (Exception ex) {
+
+                               msg = "Exception in DoCreateE2EServiceInstance.createCustomRelationship. " + ex.getMessage()
+                               logger.info(msg)
+                               exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+                       }
+               }
+               else {
+                       try {
+                               def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
+                               def TNFH_serviceInstanceId = execution.getVariable("TNFH_NSSI")
+                               def TNMH_serviceInstanceId = execution.getVariable("TNMH_NSSI")
+                               def AN_profileInstanceId = execution.getVariable("sliceProfileId")
+                               def AN_NSSI = execution.getVariable("RANServiceInstanceId")
+                               def ANNF_profileInstanceId = execution.getVariable("ANNF_sliceProfileInstanceId")
+                               def TNFH_profileInstanceId = execution.getVariable("TNFH_sliceProfileInstanceId")
+                               def TNMH_profileInstanceId = execution.getVariable("TNMH_sliceProfileInstanceId")
+                               String globalSubscriberId = execution.getVariable("globalSubscriberId")
+                               String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+
+                               Relationship ANNF_relationship = new Relationship()
+                               Relationship TNFH_relationship = new Relationship()
+                               Relationship TNMH_relationship = new Relationship()
+
+                               String ANNF_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_profileInstanceId}"
+                               String TNFH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_profileInstanceId}"
+                               String TNMH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_profileInstanceId}"
+
+                               String ANNF_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_serviceInstanceId}"
+                               String TNFH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_serviceInstanceId}"
+                               String TNMH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_serviceInstanceId}"
+
+                               ANNF_relationship.setRelatedLink(ANNF_relatedLink)
+                               ANNF_relationship.setRelatedTo("service-instance")
+                               ANNF_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
+                               TNFH_relationship.setRelatedLink(TNFH_relatedLink)
+                               TNFH_relationship.setRelatedTo("service-instance")
+                               TNFH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
+                               TNMH_relationship.setRelatedLink(TNMH_relatedLink)
+                               TNMH_relationship.setRelatedTo("service-instance")
+                               TNMH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
+
+                               // create SliceProfile and NSSI relationship in AAI
+                               anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship, ANNF_serviceInstanceId)
+                               anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship, TNFH_serviceInstanceId)
+                               anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship, TNMH_serviceInstanceId)
+                               anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship, AN_profileInstanceId)
+                               anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship, AN_profileInstanceId)
+                               anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship, AN_profileInstanceId)
+
+                               //create AN NSSI and ANNF,TNFH,TNMH relationship in AAI
+                               ANNF_relationship.setRelatedLink(ANNF_NSSI_relatedLink)
+                               TNFH_relationship.setRelatedLink(TNFH_NSSI_relatedLink)
+                               TNMH_relationship.setRelatedLink(TNMH_NSSI_relatedLink)
+                               anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship, AN_NSSI)
+                               anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship, AN_NSSI)
+                               anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship, AN_NSSI)
+
+                       } catch (BpmnError e) {
+                               throw e
+                       } catch (Exception ex) {
+
+                               msg = "Exception in DoCreateE2EServiceInstance.createCustomRelationship. " + ex.getMessage()
+                               logger.info(msg)
+                               exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+                       }
                }
        }
        
@@ -988,7 +1036,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                RU_ep.setType(type)
                RU_ep.setIpAddress("192.168.100.4")
                RU_ep.setLogicalInterfaceId("1234")
-               RU_ep.setNextHop("Host1")
+               RU_ep.setNextHop("networkId-providerId-10-clientId-0-topologyId-2-nodeId-10.1.1.1-ltpId-512")
                RU_ep.setPrefixLength(prefixLength)
                RU_ep.setAddressFamily(addressFamily)
                //DU Ingress
@@ -1002,7 +1050,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                DU_ep.setType(type)
                DU_ep.setIpAddress("192.168.100.5")
                DU_ep.setLogicalInterfaceId("1234")
-               DU_ep.setNextHop("Host2")
+               DU_ep.setNextHop("networkId-providerId-20-clientId-0-topologyId-2-nodeId-10.2.1.2-ltpId-512")
                DU_ep.setPrefixLength(prefixLength)
                DU_ep.setAddressFamily(addressFamily)
                //MH RAN end point update
@@ -1018,7 +1066,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                 DUEG_ep.setLogicalInterfaceId("1234")
                 DUEG_ep.setPrefixLength(prefixLength)
                 DUEG_ep.setAddressFamily(addressFamily)
-               DUEG_ep.setNextHop("Host3")
+               DUEG_ep.setNextHop("networkId-providerId-10-clientId-0-topologyId-2-nodeId-10.1.1.1-ltpId-512")
                //CUIN
                String CUIN_routeId = UUID.randomUUID().toString()
                execution.setVariable("tranportEp_ID_CUIN", CUIN_routeId)
@@ -1029,7 +1077,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                CUIN_ep.setType(type)
                CUIN_ep.setIpAddress("192.168.100.6")
                CUIN_ep.setLogicalInterfaceId("1234")
-               CUIN_ep.setNextHop("Host4")
+               CUIN_ep.setNextHop("networkId-providerId-20-clientId-0-topologyId-2-nodeId-10.2.1.2-ltpId-512")
                CUIN_ep.setPrefixLength(prefixLength)
                CUIN_ep.setAddressFamily(addressFamily)
                try {