From 306e4f9c037282bd4db44c55be24ad3bc7c088df Mon Sep 17 00:00:00 2001 From: deepikasatheesh Date: Fri, 28 Jan 2022 11:20:25 +0000 Subject: Fix in e2e activation flow for option1 Issue-ID: SO-3844 Signed-off-by: deepikasatheesh Change-Id: I206f0ddbb05c30abedfb558e70d320f547f8b6e7 --- .../scripts/DoActivateSliceService.groovy | 56 +++++++++++++++++++++- .../scripts/DoAllocateAccessNSSI.groovy | 2 +- 2 files changed, 56 insertions(+), 2 deletions(-) (limited to 'bpmn/so-bpmn-infrastructure-common') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy index d0fe1e9469..e54193470d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy @@ -20,6 +20,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import static org.apache.commons.lang3.StringUtils.isBlank import com.fasterxml.jackson.databind.ObjectMapper import com.google.gson.Gson import com.google.gson.reflect.TypeToken @@ -27,6 +28,15 @@ import org.apache.commons.lang3.StringUtils import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.logging.filter.base.ErrorCode +import javax.ws.rs.NotFoundException +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.entities.AAIResultWrapper +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.AAIFluentTypeBuilder.Types import org.onap.so.beans.nsmf.* import org.onap.so.beans.nsmf.oof.SubnetType import org.onap.so.bpmn.common.scripts.* @@ -160,8 +170,10 @@ class DoActivateSliceService extends AbstractServiceTaskProcessor { actDeActNssi.setNssiId(nssInstance.nssiId) actDeActNssi.setSnssaiList(Arrays.asList(customerInfo.snssai)) + String sliceProfileId = getRelatedSliceProfileId(execution, customerInfo.globalSubscriberId, customerInfo.subscriptionServiceType, nssInstance.nssiId, customerInfo.snssai, "slice-profile") + actDeActNssi.setSliceProfileId(sliceProfileId) - nbiRequest.setEsrInfo(esrInfo) + nbiRequest.setEsrInfo(esrInfo) nbiRequest.setServiceInfo(serviceInfo) nbiRequest.setActDeActNssi(actDeActNssi) execution.setVariable("nbiRequest", nbiRequest) @@ -176,6 +188,48 @@ class DoActivateSliceService extends AbstractServiceTaskProcessor { logger.debug("***** Exit processDecomposition *****") } + private String getRelatedSliceProfileId(DelegateExecution execution, String globalSubscriberId, String subscriptionServiceType, String instanceId, String snssai, String role) { + logger.debug("${Prefix} - Get Related Slice Profile") + if( isBlank(role) || isBlank(instanceId)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Role and instanceId are mandatory") + } + + String nssiId; + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(instanceId)) + if (!client.exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai : ${instanceId}") + } + AAIResultWrapper wrapper = client.get(uri, NotFoundException.class) + Optional si = wrapper.asBean(ServiceInstance.class) + if(si.isPresent()) { + List relationshipList = si.get().getRelationshipList().getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo.toLowerCase() == "service-instance") { + String relatioshipurl = relationship.getRelatedLink() + String serviceInstanceId = + relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, relatioshipurl.length()) + uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId)) + if (!client.exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, + "Service Instance was not found in aai: ${serviceInstanceId} related to ${instanceId}") + } + AAIResultWrapper wrapper01 = client.get(uri, NotFoundException.class) + Optional serviceInstance = wrapper01.asBean(ServiceInstance.class) + if (serviceInstance.isPresent()) { + ServiceInstance instance = serviceInstance.get() + if (role.equalsIgnoreCase(instance.getServiceRole()) && snssai.equalsIgnoreCase(instance.getEnvironmentContext())) { + nssiId = instance.getServiceInstanceId() + } + } + } + } + } + return nssiId + logger.debug("${Prefix} - Exit Get Related Slice Profile instances") + } + /** * send Create Request NSSMF * @param execution 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 9800428c68..bab3bee726 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy @@ -643,11 +643,11 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { ANServiceInstance.setServiceRole(serviceRole) List snssaiList = jsonUtil.StringArrayToList(execution.getVariable("snssaiList") as String) String snssai = snssaiList.get(0) - 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") String serviceFunctionAn = jsonUtil.getJsonValue(execution.getVariable("sliceProfile") as String, "resourceSharingLevel") ANServiceInstance.setServiceFunction(serviceFunctionAn) -- cgit 1.2.3-korg