diff options
author | sanket12345 <SX00562924@techmahindra.com> | 2021-07-17 11:36:42 +0530 |
---|---|---|
committer | sanket12345 <SX00562924@techmahindra.com> | 2021-07-17 11:37:41 +0530 |
commit | d19ffbc241d329218d9acb539ce3d6c72e66c0f3 (patch) | |
tree | 19716c5320d066a7587b7200c5c6143870d55a9d /bpmn/so-bpmn-infrastructure-common | |
parent | c6d26ca79dc70cdc8c133261897cfff1396be0d0 (diff) |
5G core nssmf - Allocate api
Code changes to fix issues observed during testing for share/non-shared nssmf Allocate api
Issue-ID: SO-3418
Signed-off-by: sanket12345 <SX00562924@techmahindra.com>
Change-Id: I88f22f115c112d713f42f0a800aeb6530d7c6ade
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common')
4 files changed, 244 insertions, 213 deletions
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/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy index fa1cef291e..dfbf93e3f6 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy @@ -64,7 +64,7 @@ class DoAllocateCoreNonSharedSliceTest extends MsoGroovyTest { "sourceModelUuid" : "f3666c56-744e-4055-9f4a-0726460898e0" }""" - String sliceParams= """{\r\n\t\"sliceProfile\": {\r\n\t\t\"snssaiList\": [\r\n\t\t\t\"001-100001\"\r\n\t\t],\r\n\t\t\"sliceProfileId\": \"ab9af40f13f721b5f13539d87484098\",\r\n\t\t\"plmnIdList\": [\r\n\t\t\t\"460-00\",\r\n\t\t\t\"460-01\"\r\n\t\t],\r\n\t\t\"perfReq\": {\r\n\t\t\t\"perfReqEmbbList \": [{\r\n\t\t\t\t\"activityFactor\": 50\r\n\t\t\t}]\r\n\t\t},\r\n\t\t\"maxNumberofUEs\": 200,\r\n\t\t\"coverageAreaTAList\": [\r\n\t\t\t\"1\",\r\n\t\t\t\"2\",\r\n\t\t\t\"3\",\r\n\t\t\t\"4\"\r\n\t\t],\r\n\t\t\"latency\": 2,\r\n\t\t\"resourceSharingLevel\": \"non-shared\"\r\n\t},\r\n\t\"endPoints\": [{\r\n\t\t\"IpAdress\": \"\",\r\n\t\t\"LogicalLinkId\": \"\",\r\n\t\t\"nextHopInfo\": \"\"\r\n\t}],\r\n\t\"nsiInfo\": {\r\n\t\t\"nsiId\": \"NSI-M-001-HDBNJ-NSMF-01-A-ZX\",\r\n\t\t\"nsiName\": \"eMBB-001\"\r\n\t},\r\n\t\"scriptName\": \"AN1\"\r\n}""" + String sliceParams= """{\r\n\t\"sliceProfile\": {\r\n\t\t\"snssaiList\": [\r\n\t\t\t\"001-100001\"\r\n\t\t],\r\n\t\t\"sliceProfileId\": \"ab9af40f13f721b5f13539d87484098\",\r\n\t\t\"plmnIdList\": [\r\n\t\t\t\"460-00\",\r\n\t\t\t\"460-01\"\r\n\t\t],\r\n\t\t\"perfReq\": {\r\n\t\t\t\"perfReqEmbbList \": [{\r\n\t\t\t\t\"activityFactor\": 50\r\n\t\t\t}]\r\n\t\t},\r\n\t\t\"maxNumberofUEs\": 200,\r\n\t\t\"coverageAreaTAList\": [\r\n\t\t\t\"1\",\r\n\t\t\t\"2\",\r\n\t\t\t\"3\",\r\n\t\t\t\"4\"\r\n\t\t],\r\n\t\t\"latency\": 2,\r\n\t\t\"resourceSharingLevel\": \"non-shared\"\r\n\t},\r\n\t\"endPoint\": {\r\n\t\t\"ipAdress\": \"\",\r\n\t\t\"logicalInterfaceId\": \"\",\r\n\t\t\"nextHopInfo\": \"\"\r\n\t},\r\n\t\"nsiInfo\": {\r\n\t\t\"nsiId\": \"NSI-M-001-HDBNJ-NSMF-01-A-ZX\",\r\n\t\t\"nsiName\": \"eMBB-001\"\r\n\t},\r\n\t\"scriptName\": \"AN1\"\r\n}""" when(mockExecution.getVariable("serviceInstanceId")).thenReturn("123456") when(mockExecution.getVariable("networkServiceModelInfo")).thenReturn(networkServiceModelInfo) @@ -122,6 +122,8 @@ class DoAllocateCoreNonSharedSliceTest extends MsoGroovyTest { ObjectMapper objectMapper = new ObjectMapper() Map<String, Object> serviceCharacteristic = objectMapper.readValue(sliceProfile, Map.class); + //provide mock vnfInstance name + when(mockExecution.getVariable("vnfInstanceName")).thenReturn("vf00") DoAllocateCoreNonSharedSlice allocateNssi = new DoAllocateCoreNonSharedSlice() List characteristicList=allocateNssi.retrieveServiceCharacteristicsAsKeyValue(mockExecution, serviceCharacteristic) assertEquals(expectedList, characteristicList) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSliceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSliceTest.groovy index 9068692e30..34945b9135 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSliceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSliceTest.groovy @@ -59,17 +59,12 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { @Test void testPreProcessRequest(){ - String solutions = """ [ - { - "invariantUUID": "y7685f64-5717-4562-b3fc-2c963f66afa6", - "UUID": "8u785f64-5717-4562-b3fc-2c963f66afa6", - "NSSIName": "embb-core-ser", - "NSSIId": "f4485f64-5717-4562-b3fc-2c963f66afa6", - "matchLevel": { - "blob":"content" - } - } - ]""" + String solutions = """ { + "NSSIId": "11c0c52a-d748-48aa-86e3-c783cbf5026f", + "invariantUUID": "8ebba719-f815-47e3-8473-c5f0db801356", + "NSSIName": "nssi_CN_NSST", + "UUID": "70e2b55b-8dca-4ff3-8f47-374c2965b731" + }""" String sliceProfile = "{\r\n \"snssaiList\": [ \r\n \"001-100001\"\r\n ],\r\n \"sliceProfileId\": \"ab9af40f13f721b5f13539d87484098\",\r\n \"plmnIdList\": [\r\n \"460-00\",\r\n \"460-01\"\r\n ],\r\n \"perfReq\": {\r\n \"perfReqEmbbList \": [\r\n {\r\n \"activityFactor\": 50\r\n }\r\n ]\r\n },\r\n \"maxNumberofUEs\": 200, \r\n \"coverageAreaTAList\": [ \r\n \"1\",\r\n \"2\",\r\n \"3\",\r\n \"4\"\r\n ],\r\n \"latency\": 2,\r\n \"resourceSharingLevel\": \"non-shared\" \r\n }" setUpBaseMockData() @@ -81,13 +76,13 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { Mockito.verify(mockExecution, times(1)).setVariable(eq("nssiId"), captor.capture()) def nssiId = captor.getValue() - assertEquals("f4485f64-5717-4562-b3fc-2c963f66afa6", nssiId) + assertEquals("11c0c52a-d748-48aa-86e3-c783cbf5026f", nssiId) Mockito.verify(mockExecution, times(1)).setVariable(eq("sNssai"), captor.capture()) def sNssai = captor.getValue() assertEquals("001-100001", sNssai) - Mockito.verify(mockExecution,times(3)).setVariable(captor.capture() as String, captor.capture()) + Mockito.verify(mockExecution,times(4)).setVariable(captor.capture() as String, captor.capture()) List<ExecutionEntity> values = captor.getAllValues() assertNotNull(values) } @@ -155,6 +150,14 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { //Check Vnf when(mockExecution.getVariable("vnfId")).thenReturn("eeb66c6f-36bd-47ad-8294-48f46b1aa912") + Map<String, Object> spiWithsNssaiAndOrchStatus = new LinkedHashMap<>() + spiWithsNssaiAndOrchStatus.put("snssai", "01-5C83F071") + spiWithsNssaiAndOrchStatus.put("status", "activated") + List <Map<String, Object>> spiWithsNssaiAndOrchStatusList = new ArrayList<>(); + spiWithsNssaiAndOrchStatusList.add(spiWithsNssaiAndOrchStatus) + //snssaiAndOrchStatusList + when(mockExecution.getVariable("snssaiAndOrchStatusList")).thenReturn(spiWithsNssaiAndOrchStatusList) + AAIResourceUri resourceUri3 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(mockExecution.getVariable("vnfId"))) when(client.exists(resourceUri3)).thenReturn(true) AAIResultWrapper wrapper3 = new AAIResultWrapper(mockQueryVnf()) @@ -197,10 +200,7 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { 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 @@ -227,12 +227,12 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { void setUpBaseMockData() { String sliceParams ="""{ - "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", - "snssaiList": [ - "01-5B179BD4" - ], - "sliceProfileId": "ab9af40f13f721b5f13539d87484098" - }""" + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "snssaiList": [ + "01-5B179BD4" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098" + }""" when(mockExecution.getVariable("msoRequestId")).thenReturn("5ad89cf9-0569-4a93-4509-d8324321e2be") when(mockExecution.getVariable("serviceInstanceID")).thenReturn("NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX") @@ -247,55 +247,55 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { String mockQueryNS() { return """ - { - "service-instance-id": "206535e7-77c9-4036-9387-3f1cf57b4379", - "service-instance-name": "nsi_DemoEmbb", - "environment-context": "General_Revenue-Bearing", - "workload-context": "Production", - "model-invariant-id": "848c5656-5594-4d41-84bb-7afc7c64765c", - "model-version-id": "2de92587-3395-44e8-bb2c-b9529747e580", - "resource-version": "1599228110527", - "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/206535e7-77c9-4036-9387-3f1cf57b4379/service-data/service-topology/", - "orchestration-status": "Assigned", - "relationship-list": { - "relationship": [{ - "related-to": "owning-entity", - "relationship-label": "org.onap.relationships.inventory.BelongsTo", - "related-link": "/aai/v19/business/owning-entities/owning-entity/OE-generic", - "relationship-data": [{ - "relationship-key": "owning-entity.owning-entity-id", - "relationship-value": "OE-generic" - }] - }, { - "related-to": "generic-vnf", - "relationship-label": "org.onap.relationships.inventory.ComposedOf", - "related-link": "/aai/v19/network/generic-vnfs/generic-vnf/eeb66c6f-36bd-47ad-8294-48f46b1aa912", - "relationship-data": [{ - "relationship-key": "generic-vnf.vnf-id", - "relationship-value": "eeb66c6f-36bd-47ad-8294-48f46b1aa912" - }], - "related-to-property": [{ - "property-key": "generic-vnf.vnf-name", - "property-value": "vfwuctest 0" - }] - }, { - "related-to": "project", - "relationship-label": "org.onap.relationships.inventory.Uses", - "related-link": "/aai/v19/business/projects/project/Project-generic", - "relationship-data": [{ - "relationship-key": "project.project-name", - "relationship-value": "Project-generic" - }] - }] - } + { + "service-instance-id": "206535e7-77c9-4036-9387-3f1cf57b4379", + "service-instance-name": "nsi_DemoEmbb", + "environment-context": "General_Revenue-Bearing", + "workload-context": "Production", + "model-invariant-id": "848c5656-5594-4d41-84bb-7afc7c64765c", + "model-version-id": "2de92587-3395-44e8-bb2c-b9529747e580", + "resource-version": "1599228110527", + "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/206535e7-77c9-4036-9387-3f1cf57b4379/service-data/service-topology/", + "orchestration-status": "Assigned", + "relationship-list": { + "relationship": [{ + "related-to": "owning-entity", + "relationship-label": "org.onap.relationships.inventory.BelongsTo", + "related-link": "/aai/v19/business/owning-entities/owning-entity/OE-generic", + "relationship-data": [{ + "relationship-key": "owning-entity.owning-entity-id", + "relationship-value": "OE-generic" + }] + }, { + "related-to": "generic-vnf", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/network/generic-vnfs/generic-vnf/eeb66c6f-36bd-47ad-8294-48f46b1aa912", + "relationship-data": [{ + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "eeb66c6f-36bd-47ad-8294-48f46b1aa912" + }], + "related-to-property": [{ + "property-key": "generic-vnf.vnf-name", + "property-value": "vfwuctest 0" + }] + }, { + "related-to": "project", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/projects/project/Project-generic", + "relationship-data": [{ + "relationship-key": "project.project-name", + "relationship-value": "Project-generic" + }] + }] + } } - """ + """ } String mockQueryVnf() { return """ - { + { "vnf-id": "eeb66c6f-36bd-47ad-8294-48f46b1aa912", "vnf-name": "vfwuctest 0", "vnf-type": "vfwuctest/null", @@ -379,7 +379,7 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { }] } } - """ + """ } String mockQuerySliceServiceReturn(){ @@ -414,7 +414,7 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { "property-value": "nsi_DemoEmbb" }] }, - { + { "related-to": "allotted-resource", "relationship-label": "org.onap.relationships.inventory.Uses", "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/0d3d3cce-46a8-486d-816a-954e71697c4e/allotted-resources/allotted-resource/d63c241a-4c0b-4294-b4c3-5a57421a1769", @@ -461,7 +461,7 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { "property-value": "Allotted_DemoEmbb" }] } - ] + ] } } """ |