diff options
author | sanket12345 <SX00562924@techmahindra.com> | 2021-07-29 14:59:01 +0530 |
---|---|---|
committer | SANKET KS <sx00562924@techmahindra.com> | 2021-08-17 06:25:15 +0000 |
commit | 12d11c2c6fe356d00dfb8a324f4e6ef8726a1aca (patch) | |
tree | ba343d592bf96ef58e94b1873dd0523b32c249d7 | |
parent | 3d8768d468510462c85008ded35dddc272a1b060 (diff) |
Fix Relationship update b/w core NSSI and its Sliceprofile
Code changes to fix issues observed during testing for:
- Core Allocate
- Core Activate
Issue-ID: SO-3605
Signed-off-by: sanket12345 <SX00562924@techmahindra.com>
Change-Id: I88f22f115c119d713f42f0a800aeb8320d7c9ade
4 files changed, 44 insertions, 74 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy index 2d18108acd..ad9dfa3425 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy @@ -90,7 +90,7 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { execution.setVariable("sNssai", sNssai) String serviceType = execution.getVariable("subscriptionServiceType") execution.setVariable("serviceType", serviceType) - logger.debug("operationType: {} , sNssai: {}, serviceType: {}.",operationType, sNssai, serviceType) + logger.debug("operationType: {} , sNssai: {}, serviceType: {}.",operationType, sNssai, serviceType) logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: preProcessRequest ****") } @@ -106,52 +106,42 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { if(nsi.isPresent()) { List<Relationship> relationshipList = nsi.get().getRelationshipList()?.getRelationship() List spiWithsNssaiAndOrchStatusList = new ArrayList<>() + for (Relationship relationship : relationshipList) { String relatedTo = relationship.getRelatedTo() - if (("service-instance").equals(relatedTo)) { + if ("service-instance".equals(relatedTo)) { List<RelationshipData> relationshipDataList = relationship.getRelationshipData() List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToProperty() for (RelationshipData relationshipData : relationshipDataList) { - if (("service-instance.service-instance-id").equals(relationshipData.getRelationshipKey())) { - execution.setVariable("networkServiceInstanceId", relationshipData.getRelationshipValue()) - } - } - for (RelatedToProperty relatedToProperty : relatedToPropertyList) { - if (("service-instance.service-instance-name").equals(relatedToProperty.getPropertyKey())) { - execution.setVariable("networkServiceInstanceName", relatedToProperty.getPropertyValue()) - } - } - } - - //If related to is allotted-Resource - if (("allotted-resource").equals(relatedTo)) { - //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().equals("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().getEnvironmentContext() - String sNssaiValueFromRequest = execution.getVariable("sNssai") - if(sNssai.equals(sNssaiValueFromRequest)) { - orchestrationStatus = execution.getVariable("oStatus") - //Slice Profile Service Instance to be updated in AAI - execution.setVariable("sliceProfileServiceInstance", sliceProfileServiceInstance.get()) + if ("service-instance.service-instance-id".equals(relationshipData.getRelationshipKey())) { + //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) + } } - Map<String, Object> spiWithsNssaiAndOrchStatus = new LinkedHashMap<>() - spiWithsNssaiAndOrchStatus.put("snssai", sNssai) - spiWithsNssaiAndOrchStatus.put("status", orchestrationStatus) - spiWithsNssaiAndOrchStatusList.add(spiWithsNssaiAndOrchStatus) } } } @@ -620,6 +610,10 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { ServiceInstance si = execution.getVariable("sliceProfileServiceInstance") String sliceProfileInstanceId = si.getServiceInstanceId() + + if(sliceProfileInstanceId==null) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Slice Profile Instance Update failed") + } si.setOrchestrationStatus(oStatus) AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(sliceProfileInstanceId)) 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 2801c11e47..bf3dda6832 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 @@ -112,33 +112,19 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { try { String serviceType = execution.getVariable("subscriptionServiceType") String oStatus = execution.getVariable("orchestrationStatus") - //Get workload context and environment context from DB - String environmentContext = "" - String workloadContext ="" + String environmentContext = execution.getVariable("networkType") + String workloadContext = "CN" String modelInvariantUuid = execution.getVariable("modelInvariantUuid") - try{ - String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid ) - logger.debug("JSON Response from DB: "+json) - environmentContext = jsonUtil.getJsonValue(json, "serviceResources.environmentContext") ?: "" - workloadContext = jsonUtil.getJsonValue(json, "serviceResources.workloadContext") ?: "" - logger.debug("Env Context is: "+ environmentContext) - logger.debug("Workload Context is: "+ workloadContext) - } catch(BpmnError e){ - throw e - } catch (Exception ex){ - msg = "Exception in createNSSIinAAI ::: DoAllocateCoreNonSharedSlice " + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } + String nssiServiceType = execution.getVariable("sst") //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") + String serviceInstanceName = execution.getVariable("servicename") ServiceInstance si = new ServiceInstance() si.setServiceInstanceId(execution.getVariable("nssiServiceInstanceId")) si.setServiceInstanceName(serviceInstanceName) - si.setServiceType(serviceType) + si.setServiceType(nssiServiceType) si.setServiceRole("nssi") si.setOrchestrationStatus(oStatus) si.setModelInvariantId(modelInvariantUuid) @@ -378,7 +364,7 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { //Update NSSI orchestration status nssiServiceInstance ServiceInstance si = execution.getVariable("nssiServiceInstance") logger.debug("nssiServiceInstance "+si) - si.setOrchestrationStatus("activated") + si.setOrchestrationStatus("deactivated") AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(nssiId)) logger.debug("uri to call: "+uri) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy index e4c6fe5f60..b32b96b123 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy @@ -136,18 +136,6 @@ class DoActivateCoreNSSITest extends MsoGroovyTest { Mockito.verify(mockExecution, times(1)).setVariable(eq("vnfId"), captor.capture()) assertEquals("eeb66c6f-36bd-47ad-8294-48f46b1aa912", captor.getValue()) - Mockito.verify(mockExecution, times(1)).setVariable(eq("snssaiAndOrchStatusList"), captor.capture()) - List<Map<String, Object>> snssaiList = new ArrayList<>() - Map<String, Object> snssaiMap = new LinkedHashMap<>() - snssaiMap.put("snssai", "01-5C83F071") - snssaiMap.put("status", "activated") - snssaiList.add(snssaiMap) - Map<String, Object> snssaiMap1 = new LinkedHashMap<>() - snssaiMap1.put("snssai", "01-5B179BD4") - snssaiMap1.put("status", "activated") - snssaiList.add(snssaiMap1) - assertEquals(snssaiList, captor.getValue()) - //Verify Project Mockito.verify(mockExecution, times(1)).setVariable(eq("projectName"), captor.capture()) assertEquals("Project-generic", captor.getValue()) diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreNSSI.bpmn index 45ebfb9664..ba2f6bbe3a 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreNSSI.bpmn @@ -42,7 +42,7 @@ allocateNssi.getNSSTName(execution)</bpmn:script> def allocateNssi = new DoAllocateCoreNSSI() allocateNssi.prepareOOFRequest(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:callActivity id="CallActivity_0ue7vug" name="Call non-shared slice flow" calledElement="DoAllocateCoreNonSharedSlice"> + <bpmn:callActivity id="CallActivity_0ue7vug" name="Call non-shared slice flow" calledElement="DoAllocateCoreNonSharedSlice"> <bpmn:extensionElements> <camunda:in source="coreServiceInstanceId" target="serviceInstanceId" /> <camunda:in source="networkServiceModelInfo" target="networkServiceModelInfo" /> @@ -58,6 +58,8 @@ allocateNssi.prepareOOFRequest(execution)</bpmn:script> <camunda:in source="servicename" target="servicename" /> <camunda:in source="msoRequestId" target="msoRequestId" /> <camunda:in source="sliceProfile" target="sliceProfile" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="sst" target="sst" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_1scva4p</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0tubodn</bpmn:outgoing> |