diff options
author | Byung-Woo Jun <byung-woo.jun@est.tech> | 2021-08-17 11:30:58 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-08-17 11:30:58 +0000 |
commit | 9e597da1e74ab81a27879f6100335e6815ff1702 (patch) | |
tree | f41804027c38ae4530e08ab8d9a4cae5413a3754 | |
parent | 1ceb7d62d1c1f53e680b5d5dbcc2cdd5e339bf28 (diff) | |
parent | 12d11c2c6fe356d00dfb8a324f4e6ef8726a1aca (diff) |
Merge "Fix Relationship update b/w core NSSI and its Sliceprofile"
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> |