From 903ed1e60d430c2a4b500283d286dbee0d8eefed Mon Sep 17 00:00:00 2001 From: aleemraja Date: Thu, 17 Sep 2020 11:58:30 +0530 Subject: Implement Activate and Deactivate Core NSSMF workflow Issue-ID: SO-3235 Signed-off-by: aleemraja Change-Id: I37ce7d21eaba8ea60a91a7034508965b2cf3a987 --- .../scripts/DoActivateCoreNSSI.groovy | 685 +++++++++++++++++++++ .../scripts/DoActivateCoreNSSITest.groovy | 631 +++++++++++++++++++ .../resources/subprocess/DoActivateCoreNSSI.bpmn | 420 +++++++++++++ 3 files changed, 1736 insertions(+) create mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy create mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateCoreNSSI.bpmn (limited to 'bpmn') 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 new file mode 100644 index 0000000000..306c53a73c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy @@ -0,0 +1,685 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Tech Mahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONObject +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.serviceinstancebeans.CloudConfiguration +import org.onap.so.serviceinstancebeans.LineOfBusiness +import org.onap.so.serviceinstancebeans.ModelInfo +import org.onap.so.serviceinstancebeans.ModelType +import org.onap.so.serviceinstancebeans.OwningEntity +import org.onap.so.serviceinstancebeans.Platform +import org.onap.so.serviceinstancebeans.Project +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.rest.catalog.beans.Vnf +import org.onap.so.serviceinstancebeans.RequestDetails +import org.onap.so.serviceinstancebeans.RequestInfo +import org.onap.so.serviceinstancebeans.RequestParameters +import org.onap.so.serviceinstancebeans.SubscriberInfo +import org.onap.aai.domain.yang.GenericVnf +import org.onap.aai.domain.yang.RelatedToProperty +import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.RelationshipData +import org.onap.aai.domain.yang.RelationshipList +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aai.domain.yang.v19.SliceProfile +import org.onap.aai.domain.yang.v19.SliceProfiles +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.db.request.beans.OperationStatus +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.onap.aaiclient.client.aai.AAIObjectType +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 com.fasterxml.jackson.databind.ObjectMapper + +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response + +class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { + String Prefix="DACTCNSSI_" + private static final Logger logger = LoggerFactory.getLogger(DoActivateCoreNSSI.class); + CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() + private RequestDBUtil requestDBUtil = new RequestDBUtil() + ExceptionUtil exceptionUtil = new ExceptionUtil() + ObjectMapper mapper = new ObjectMapper(); + + JsonUtils jsonUtil = new JsonUtils() + + private final Long TIMEOUT = 60 * 60 * 1000 + + @Override + public void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: preProcessRequest ****") + + String operationType = execution.getVariable("operationType") + String oStatus= "" + + if(operationType.equals("activateInstance")) { + oStatus ="activated" + } else { + oStatus ="deactivated" + } + + execution.setVariable("oStatus", oStatus) + String sNssaiListAsString = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "snssaiList") + + logger.debug("sNssaiListAsString "+sNssaiListAsString) + + List sNssaiList = jsonUtil.StringArrayToList(sNssaiListAsString) + + logger.debug("sNssaiList "+sNssaiList) + + + String sNssai = sNssaiList.get(0) + execution.setVariable("sNssai", sNssai) + + logger.debug("sNssai: "+sNssai) + + String serviceType = execution.getVariable("subscriptionServiceType") + execution.setVariable("serviceType", serviceType) + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: preProcessRequest ****") + } + + public void getNetworkInstanceWithSPInstanceAssociatedWithNssiId(DelegateExecution execution) { + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: getNetworkInstanceWithSPInstanceAssociatedWithNssiId ****") + //NSSI Id as service Instance Id to get from Request + String serviceInstanceId = execution.getVariable("serviceInstanceID") + String errorMsg = "query Network Service Instance from AAI failed" + AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg) + Optional nsi = wrapper.asBean(ServiceInstance.class) + String networkServiceInstanceName = "" + String networkServiceInstanceId ="" + if(nsi.isPresent()) { + List relationshipList = nsi.get().getRelationshipList()?.getRelationship() + List spiWithsNssaiAndOrchStatusList = new ArrayList<>() + + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo == "service-instance") { + List relationshipDataList = relationship.getRelationshipData() + List relatedToPropertyList = relationship.getRelatedToProperty() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "service-instance.service-instance-id") { + 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 sliceProfileInstanceIdList = new ArrayList<>() + List 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, AAIObjectType.SERVICE_INSTANCE, sliceProfileServiceInstanceId, errorSliceProfileMsg) + Optional 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 spiWithsNssaiAndOrchStatus = new LinkedHashMap<>() + spiWithsNssaiAndOrchStatus.put("snssai", sNssai) + spiWithsNssaiAndOrchStatus.put("status", orchestrationStatus) + spiWithsNssaiAndOrchStatusList.add(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 DoActivateCoreNSSI ::: getNetworkInstanceWithSPInstanceAssociatedWithNssiId ****") + } + + + private String prepareVnfInstanceParamsJson(DelegateExecution execution) { + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: prepareVnfInstanceParamsJson ****") + List instanceParamsvalues = execution.getVariable("snssaiAndOrchStatusList") + Map nSsai= new LinkedHashMap<>() + nSsai.put("sNssai", instanceParamsvalues) + String supportedsNssaiJson = mapper.writeValueAsString(nSsai) + //SupportedNssai + Map supportedNssai= new LinkedHashMap<>() + supportedNssai.put("supportedNssai", supportedsNssaiJson) + logger.debug("**** supportedsNssaiJson**** "+supportedNssai) + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: prepareVnfInstanceParamsJson ****") + return supportedNssai + } + + private void getServiceInstanceRelationships(DelegateExecution execution) { + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: getServiceInstanceRelationships ****") + String serviceInstanceId = execution.getVariable("networkServiceInstanceId") + logger.debug("**** serviceInstanceId :: getServiceInstanceRelationships :: "+serviceInstanceId) + String errorMsg = "query Network Service Instance from AAI failed" + AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg) + Optional si = wrapper.asBean(ServiceInstance.class) + + String networkServiceModelInvariantUuid = si.get().getModelInvariantId() + execution.setVariable("networkServiceModelInvariantUuid", networkServiceModelInvariantUuid) + if(si.isPresent()) { + List relationshipList = si.get().getRelationshipList()?.getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo == "owning-entity") { + List relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "owning-entity.owning-entity-id") { + execution.setVariable("owningEntityId", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "generic-vnf") { + List relationshipDataList = relationship.getRelationshipData() + List relatedToPropertyList = relationship.getRelatedToProperty() + + //Get VnfId + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "generic-vnf.vnf-id") { + execution.setVariable("vnfId", relationshipData.getRelationshipValue()) + String vnfId = relationshipData.getRelationshipValue() + logger.debug("vnfId :"+vnfId) + } + } + } else if (relatedTo == "project") { + List relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "project.project-name") { + execution.setVariable("projectName", relationshipData.getRelationshipValue()) + } + } + } + } + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: getServiceInstanceRelationships ****") + } + } + + private void getVnfRelationships(DelegateExecution execution) { + + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: getVnfRelationships ****") + String msg = "query Generic Vnf from AAI failed" + try { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable('vnfId')) + if (!getAAIClient().exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + AAIResultWrapper wrapper = getAAIClient().get(uri, NotFoundException.class) + Optional vnf = wrapper.asBean(GenericVnf.class) + if(vnf.isPresent()) { + List relationshipList = vnf.get().getRelationshipList()?.getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo == "tenant") { + List relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "tenant.tenant-id") { + execution.setVariable("tenantId", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "cloud-region") { + List relationshipDataList = relationship.getRelationshipData() + + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "cloud-region.cloud-owner") { + execution.setVariable("cloudOwner", relationshipData.getRelationshipValue()) + } else if (relationshipData.getRelationshipKey() == "cloud-region.cloud-region-id") { + execution.setVariable("lcpCloudRegionId", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "platform") { + List relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "platform.platform-name") { + execution.setVariable("platformName", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "line-of-business") { + List relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "line-of-business.line-of-business-name") { + execution.setVariable("lineOfBusinessName", relationshipData.getRelationshipValue()) + } + } + } + } + } + } catch(BpmnError e){ + throw e + } catch (Exception ex){ + msg = "Exception in getVnfRelationships " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: getVnfRelationships ****") + } + + + /** + * query AAI + * @param execution + * @param aaiObjectType + * @param instanceId + * @return AAIResultWrapper + */ + private AAIResultWrapper queryAAI(DelegateExecution execution, AAIObjectType aaiObjectType, String instanceId, String errorMsg) { + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: queryAAI ****") + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(aaiObjectType, globalSubscriberId, serviceType, instanceId) + if (!getAAIClient().exists(resourceUri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg) + } + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) + + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: queryAAI ****") + return wrapper + } + + public void getServiceVNFAndVFsFromCatalogDB(DelegateExecution execution) { + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: getServiceVNFAndVFsFromCatalogDB ****") + + String modelInvariantUuid = execution.getVariable("networkServiceModelInvariantUuid") + + try{ + CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() + String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution, modelInvariantUuid) + logger.debug("***** JSON IS: "+json) + + String serviceVnfs = jsonUtil.getJsonValue(json, "serviceResources.serviceVnfs") ?: "" + String serviceModelInfo = jsonUtil.getJsonValue(json, "serviceResources.modelInfo") ?: "" + + + execution.setVariable("serviceVnfs",serviceVnfs) + execution.setVariable("serviceModelInfo", serviceModelInfo) + logger.debug(Prefix +" ***** serviceVnfs is: "+ serviceVnfs) + }catch(BpmnError e){ + throw e + } catch (Exception ex){ + String msg = "Exception in getServiceVNFAndVFsFromCatalogDB " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: getServiceVNFAndVFsFromCatalogDB ****") + } + + public void prepareSOMacroRequestPayLoad(DelegateExecution execution) { + logger.debug("**** Enter DoActivateCoreNSSI ::: prepareSOMacroRequestPayLoad ****") + String json = execution.getVariable("serviceVnfs") + logger.debug(">>>> json "+json) + List vnfList = mapper.readValue(json, List.class); + logger.debug("vnfList: "+vnfList) + Map serviceMap = mapper.readValue(execution.getVariable("serviceModelInfo"), Map.class); + ModelInfo serviceModelInfo = new ModelInfo() + serviceModelInfo.setModelType(ModelType.service) + serviceModelInfo.setModelInvariantId(serviceMap.get("modelInvariantUuid")) + serviceModelInfo.setModelVersionId(serviceMap.get("modelUuid")) + serviceModelInfo.setModelName(serviceMap.get("modelName")) + serviceModelInfo.setModelVersion(serviceMap.get("modelVersion")) + + logger.debug("serviceModelInfo: "+serviceModelInfo) + //List of Vnfs + List vnfModelInfoList = new ArrayList<>() + + Map vnfMap = vnfList.get(0) + ModelInfo vnfModelInfo = vnfMap.get("modelInfo") + logger.debug("vnfModelInfo "+vnfModelInfo) + + //List of VFModules + List> vfModuleList = vnfMap.get("vfModules") + logger.debug("vfModuleList "+vfModuleList) + + //List of VfModules + List vfModelInfoList = new ArrayList<>() + + //Traverse VFModules List and add in vfModelInfoList + for (vfModule in vfModuleList) { + ModelInfo vfModelInfo = vfModule.get("modelInfo") + logger.debug("vfModelInfo "+vfModelInfo) + vfModelInfoList.add(vfModelInfo) + } + + //RequestInfo + RequestInfo requestInfo = new RequestInfo() + + //Dummy Product FamilyId + requestInfo.setProductFamilyId("test1234") + requestInfo.setSource("VID") + requestInfo.setInstanceName(execution.getVariable("networkServiceInstanceName")) + requestInfo.setSuppressRollback(false) + requestInfo.setRequestorId("NBI") + + //Service Level InstanceParams + List> serviceParams = new ArrayList<>() + Map serviceParamsValues = new LinkedHashMap<>() + serviceParams.add(serviceParamsValues) + + //Cloud Configuration + CloudConfiguration cloudConfiguration = new CloudConfiguration() + cloudConfiguration.setLcpCloudRegionId(execution.getVariable("lcpCloudRegionId")) + cloudConfiguration.setTenantId(execution.getVariable("tenantId")) + cloudConfiguration.setCloudOwner(execution.getVariable("cloudOwner")) + + //VFModules List + List> vfModules = new ArrayList<>() + for (ModelInfo vfModuleModelInfo : vfModelInfoList) { + //Individual VFModule List + Map vfModuleValues = new LinkedHashMap<>() + vfModuleValues.put("modelInfo", vfModuleModelInfo) + vfModuleValues.put("instanceName", vfModuleModelInfo.getModelInstanceName()) + + //VFModule InstanceParams should be empty or this field should not be there? + List> vfModuleInstanceParams = new ArrayList<>() + vfModuleValues.put("instanceParams", vfModuleInstanceParams) + } + + //Vnf intsanceParams + ObjectMapper objectMapper = new ObjectMapper(); + Map sliceProfile = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class); + + List vnfInstanceParamsList = new ArrayList<>() + String supportedsNssaiJson= prepareVnfInstanceParamsJson(execution) + vnfInstanceParamsList.add(supportedsNssaiJson) + + Platform platform = new Platform() + platform.setPlatformName(execution.getVariable("platform")) + + LineOfBusiness lineOfbusiness = new LineOfBusiness() + lineOfbusiness.setLineOfBusinessName(execution.getVariable("lineOfBusiness")) + + //Vnf Values + Map vnfValues = new LinkedHashMap<>() + vnfValues.put("lineOfBusiness", lineOfbusiness) + vnfValues.put("platform", platform) + vnfValues.put("productFamilyId", "test1234") + vnfValues.put("cloudConfiguration", cloudConfiguration) + vnfValues.put("vfModules", vfModules) + vnfValues.put("modelInfo", vnfModelInfo) + vnfValues.put("instanceName", execution.getVariable("vnfInstanceName")) + vnfValues.put("instanceParams",vnfInstanceParamsList) + + vnfModelInfoList.add(vnfValues) + //Service Level Resources + Map serviceResources = new LinkedHashMap<>() + serviceResources.put("vnfs", vnfModelInfoList) + + //Service Values + Map serviceValues = new LinkedHashMap<>() + serviceValues.put("modelInfo", serviceModelInfo) + serviceValues.put("instanceName", execution.getVariable("networkServiceInstanceName")) + serviceValues.put("resources", serviceResources) + serviceValues.put("instanceParams", serviceParams) + + //UserParams Values + Map userParamsValues = new LinkedHashMap<>() + + Map homingSolution = new LinkedHashMap<>() + homingSolution.put("Homing_Solution", "none") + + userParamsValues.put("service", serviceValues) + + //UserParams + List> userParams = new ArrayList<>() + userParams.add(homingSolution) + userParams.add(userParamsValues) + + //Request Parameters + RequestParameters requestParameters = new RequestParameters() + requestParameters.setaLaCarte(false) + requestParameters.setSubscriptionServiceType(execution.getVariable("serviceType")) + requestParameters.setUserParams(userParams) + + //SubscriberInfo + SubscriberInfo subscriberInfo = new SubscriberInfo() + subscriberInfo.setGlobalSubscriberId(execution.getVariable("globalSubscriberId")) + + //Owning Entity + OwningEntity owningEntity = new OwningEntity() + owningEntity.setOwningEntityId(execution.getVariable("owningEntityId")) + + //Project + Project project = new Project() + project.setProjectName(execution.getVariable("projectName")) + + RequestDetails requestDetails = new RequestDetails() + requestDetails.setModelInfo(serviceModelInfo) + requestDetails.setSubscriberInfo(subscriberInfo) + requestDetails.setRequestInfo(requestInfo) + requestDetails.setRequestParameters(requestParameters) + requestDetails.setCloudConfiguration(cloudConfiguration) + requestDetails.setOwningEntity(owningEntity) + requestDetails.setProject(project) + + Map requestDetailsMap = new LinkedHashMap<>() + requestDetailsMap.put("requestDetails", requestDetails) + String requestPayload = objectMapper.writeValueAsString(requestDetailsMap) + + logger.debug("requestDetails "+requestPayload) + execution.setVariable("requestPayload", requestPayload) + + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: prepareSOMacroRequestPayLoad ****") + } + + public void sendPutRequestToSOMacro(DelegateExecution execution) { + + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: 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 requestBody = execution.getVariable("requestPayload") + String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution) + String basicAuthValue = utils.encrypt(basicAuth, msoKey) + String encodeString = utils.getBasicAuth(basicAuthValue, msoKey) + + HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) + httpClient.addAdditionalHeader("Authorization", encodeString) + httpClient.addAdditionalHeader("Accept", "application/json") + Response httpResponse = httpClient.put(requestBody) + handleSOResponse(httpResponse, execution) + + } catch (BpmnError e) { + throw e + } catch (any) { + String msg = "Exception in DoActivateCoreNSSSI " + any.getCause() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: sendPostRequestToSOMacro ****") + } + + /** + * Handle SO Response for PUT and prepare update operation status + * @param execution + */ + private void handleSOResponse(Response httpResponse, DelegateExecution execution){ + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: handleSOResponse ****") + + int soResponseCode = httpResponse.getStatus() + logger.debug("soResponseCode : "+soResponseCode) + + if (soResponseCode >= 200 && soResponseCode < 204 && httpResponse.hasEntity()) { + String soResponse = httpResponse.readEntity(String.class) + String operationId = execution.getVariable("operationId") + def macroOperationId = jsonUtil.getJsonValue(soResponse, "operationId") + execution.setVariable("macroOperationId", macroOperationId) + execution.setVariable("isSOTimeOut", "no") + execution.setVariable("isSOResponseSucceed","yes") + } + else + { + String serviceName = execution.getVariable("serviceInstanceName") + execution.setVariable("isSOResponseSucceed","no") + prepareFailedOperationStatusUpdate(execution) + } + + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: handleSOResponse ****") + } + + /** + * prepare to call sub process CheckProcessStatus + * @param execution + */ + void prepareCallCheckProcessStatus(DelegateExecution execution){ + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: prepareCallCheckProcessStatus ****") + def successConditions = new ArrayList<>() + successConditions.add("finished") + execution.setVariable("successConditions", successConditions) + def errorConditions = new ArrayList<>() + errorConditions.add("error") + execution.setVariable("errorConditions", errorConditions) + execution.setVariable("processServiceType", "Network service") + execution.setVariable("subOperationType", "PUT") + execution.setVariable("initProgress", 20) + execution.setVariable("endProgress",90) + execution.setVariable("timeOut", TIMEOUT) + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: prepareCallCheckProcessStatus ****") + } + + void prepareUpdateResourceOperationStatus(DelegateExecution execution) { + + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: prepareUpdateResourceOperationStatus ****") + + String nssiOperationId = execution.getVariable("nssiOperationId") + execution.setVariable("operationId", nssiOperationId) + //Prepare Update Status for PUT failure and success + if(execution.getVariable("isTimeOut").equals("YES")) { + logger.debug("TIMEOUT - SO PUT Failure") + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "SO PUT Failure") + } + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: prepareUpdateResourceOperationStatus ****") + } + + void updateSliceProfileOrchestrationStatus(DelegateExecution execution) { + + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: updateSliceProfileOrchestrationStatus ****") + + String globalCustId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + String oStatus = execution.getVariable("oStatus") + + ServiceInstance si = execution.getVariable("sliceProfileServiceInstance") + String sliceProfileInstanceId = si.getServiceInstanceId() + si.setOrchestrationStatus(oStatus) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalCustId, serviceType, sliceProfileInstanceId) + try { + + Response response = getAAIClient().update(uri, si) + + if(response.getStatus()!=200 || response.getStatus()!=201 || response.getStatus()!=202) { + exceptionUtil.buildAndThrowWorkflowException(execution, response.getStatus(), "AAI failed to update sliceProlie service Instance orchestration status") + } else { + setResourceOperationStatus(execution) + } + } catch (Exception e) { + logger.info("Update OrchestrationStatus in AAI failed") + String msg = "Update OrchestrationStatus in AAI failed, " + e.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: updateSliceProfileOrchestrationStatus ****") + } + + /** + * prepare ResourceOperation status + * @param execution + * @param operationType + */ + private void setResourceOperationStatus(DelegateExecution execution) { + + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: setResourceOperationStatus ****") + + String serviceId = execution.getVariable("nssiId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() + resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setOperType(operationType) + resourceOperationStatus.setStatus("finished") + resourceOperationStatus.setProgress("100") + resourceOperationStatus.setStatusDescription("Core Activation Successful") + requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) + + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: setResourceOperationStatus ****") + } + + void prepareFailedOperationStatusUpdate(DelegateExecution execution){ + logger.debug(Prefix + " **** Enter DoActivateCoreNSSI ::: prepareFailedOperationStatusUpdate ****") + + String serviceId = execution.getVariable("nssiId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() + resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setOperType(operationType) + resourceOperationStatus.setProgress(0) + resourceOperationStatus.setStatus("failed") + resourceOperationStatus.setStatusDescription("Core NSSI Activation Failed") + requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) + + logger.debug(Prefix + " **** Exit DoActivateCoreNSSI ::: prepareFailedOperationStatusUpdate ****") + } + +} \ No newline at end of file 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 new file mode 100644 index 0000000000..a39ca04d71 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy @@ -0,0 +1,631 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Tech Mahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import static org.junit.Assert.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.slf4j.Logger +import org.mockito.Mockito +import org.onap.aaiclient.client.aai.AAIObjectType +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 static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when +import static org.mockito.ArgumentMatchers.eq + +import javax.ws.rs.NotFoundException + +class DoActivateCoreNSSITest extends MsoGroovyTest { + + DoActivateCoreNSSI doActivate = new DoActivateCoreNSSI() + @Before + void init() throws IOException { + super.init("DoActivateCoreNSSI") + } + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest(){ + + setUpMockdataFromCommonActivateSliceSubnet() + doActivate.preProcessRequest(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("oStatus"), captor.capture()) + def statusValue = captor.getValue() + assertEquals("deactivated", statusValue) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("sNssai"), captor.capture()) + def sNssai = captor.getValue() + assertEquals("01-5B179BD4", sNssai) + + Mockito.verify(mockExecution,times(3)).setVariable(captor.capture() as String, captor.capture()) + List values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testGetNetworkInstanceWithSPInstanceAssociatedWithNssiId(){ + + setUpMockdataFromCommonActivateSliceSubnet() + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + DoActivateCoreNSSI obj = spy(DoActivateCoreNSSI.class) + when(obj.getAAIClient()).thenReturn(client) + AAIResourceUri resourceUri1 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX") + when(client.exists(resourceUri1)).thenReturn(true) + AAIResultWrapper wrapper1 = new AAIResultWrapper(mockQuerySliceServiceReturn()) + when(client.get(resourceUri1, NotFoundException.class)).thenReturn(wrapper1) + + //networkServiceInstanceId + when(mockExecution.getVariable("networkServiceInstanceId")).thenReturn("206535e7-77c9-4036-9387-3f1cf57b4379") + + AAIResourceUri resourceUri2 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "206535e7-77c9-4036-9387-3f1cf57b4379") + when(client.exists(resourceUri2)).thenReturn(true) + AAIResultWrapper wrapper2 = new AAIResultWrapper(mockQueryNS()) + when(client.get(resourceUri2, NotFoundException.class)).thenReturn(wrapper2) + + //Check Vnf + when(mockExecution.getVariable("vnfId")).thenReturn("eeb66c6f-36bd-47ad-8294-48f46b1aa912") + AAIResourceUri resourceUri3 = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "eeb66c6f-36bd-47ad-8294-48f46b1aa912") + when(client.exists(resourceUri3)).thenReturn(true) + AAIResultWrapper wrapper3 = new AAIResultWrapper(mockQueryVnf()) + when(client.get(resourceUri3, NotFoundException.class)).thenReturn(wrapper3) + + + //Allotted Resources-1 + //when(mockExecution.getVariable("vnfId")).thenReturn("eeb66c6f-36bd-47ad-8294-48f46b1aa912") + AAIResourceUri resourceUri4 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "0d3d3cce-46a8-486d-816a-954e71697c4e") + when(client.exists(resourceUri4)).thenReturn(true) + AAIResultWrapper wrapper4 = new AAIResultWrapper(mockServiceProfile1()) + when(client.get(resourceUri4, NotFoundException.class)).thenReturn(wrapper4) + + //Allotted Resources-2 + //when(mockExecution.getVariable("vnfId")).thenReturn("eeb66c6f-36bd-47ad-8294-48f46b1aa912") + AAIResourceUri resourceUri5 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "1c7046f2-a5a3-4d7f-9da8-388ee641a795") + when(client.exists(resourceUri5)).thenReturn(true) + AAIResultWrapper wrapper5 = new AAIResultWrapper(mockServiceProfile2()) + when(client.get(resourceUri5, NotFoundException.class)).thenReturn(wrapper5) + + obj.getNetworkInstanceWithSPInstanceAssociatedWithNssiId(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceInstanceId"), captor.capture()) + assertEquals("206535e7-77c9-4036-9387-3f1cf57b4379", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceInstanceName"), captor.capture()) + assertEquals("nsi_DemoEmbb", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceModelInvariantUuid"), captor.capture()) + assertEquals("848c5656-5594-4d41-84bb-7afc7c64765c", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("owningEntityId"), captor.capture()) + assertEquals("OE-generic", captor.getValue()) + + //VnfId + 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> snssaiList = new ArrayList<>() + Map snssaiMap = new LinkedHashMap<>() + snssaiMap.put("snssai", "01-5C83F071") + snssaiMap.put("status", "activated") + snssaiList.add(snssaiMap) + Map 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()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("tenantId"), captor.capture()) + assertEquals("3d5819f1542e4ef9a4ccb0bcb278ca10", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("cloudOwner"), captor.capture()) + assertEquals("k8scloudowner", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("lcpCloudRegionId"), captor.capture()) + assertEquals("k8sregion", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("platformName"), captor.capture()) + assertEquals("test", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("lineOfBusinessName"), captor.capture()) + assertEquals("LOB-Demonstration", captor.getValue()) + + } + + @Test + void testPrepareVnfInstanceParamsJson() { + List> snssaiList = new ArrayList<>() + Map snssaiMap = new LinkedHashMap<>() + snssaiMap.put("snssai", "01-5C83F071") + snssaiMap.put("status", "activated") + snssaiList.add(snssaiMap) + Map snssaiMap1 = new LinkedHashMap<>() + snssaiMap1.put("snssai", "01-5B179BD4") + snssaiMap1.put("status", "activated") + snssaiList.add(snssaiMap1) + + when(mockExecution.getVariable("snssaiAndOrchStatusList")).thenReturn(snssaiList) + + String returnedJsonAsString= doActivate.prepareVnfInstanceParamsJson(mockExecution) + + String expectedJsonAsString = """{supportedNssai={"sNssai":[{"snssai":"01-5C83F071","status":"activated"},{"snssai":"01-5B179BD4","status":"activated"}]}}""" + assertEquals(expectedJsonAsString, returnedJsonAsString) + } + + + 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" + }] + }] + } +} + """ + } + + String mockQueryVnf() { + + return """ + { + "vnf-id": "eeb66c6f-36bd-47ad-8294-48f46b1aa912", + "vnf-name": "vfwuctest 0", + "vnf-type": "vfwuctest/null", + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "prov-status": "PREPROV", + "orchestration-status": "ConfigAssigned", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1599228155361", + "model-invariant-id": "1086e068-c932-4b61-ae3b-2d2eb0cbe3ec", + "model-version-id": "7fbb28cf-7dfc-447a-892c-4a3130b371d2", + "model-customization-id": "471b3188-e8f2-470b-9f4d-89e74d45445f", + "relationship-list": { + "relationship": [{ + "related-to": "tenant", + "relationship-label": "org.onap.relationships.inventory.BelongsTo", + "related-link": "/aai/v19/cloud-infrastructure/cloud-regions/cloud-region/k8scloudowner/k8sregion/tenants/tenant/3d5819f1542e4ef9a4ccb0bcb278ca10", + "relationship-data": [{ + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "k8scloudowner" + }, { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "k8sregion" + }, { + "relationship-key": "tenant.tenant-id", + "relationship-value": "3d5819f1542e4ef9a4ccb0bcb278ca10" + }], + "related-to-property": [{ + "property-key": "tenant.tenant-name", + "property-value": "onap-tm5g-dev" + }] + }, { + "related-to": "cloud-region", + "relationship-label": "org.onap.relationships.inventory.LocatedIn", + "related-link": "/aai/v19/cloud-infrastructure/cloud-regions/cloud-region/k8scloudowner/k8sregion", + "relationship-data": [{ + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "k8scloudowner" + }, { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "k8sregion" + }], + "related-to-property": [{ + "property-key": "cloud-region.owner-defined-type", + "property-value": "OwnerType" + }] + }, { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vfw-k8s/service-instances/service-instance/206535e7-77c9-4036-9387-3f1cf57b4379", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "Demonstration" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "vfw-k8s" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "206535e7-77c9-4036-9387-3f1cf57b4379" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "vfw-0201" + }] + }, { + "related-to": "platform", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/platforms/platform/test", + "relationship-data": [{ + "relationship-key": "platform.platform-name", + "relationship-value": "test" + }] + }, { + "related-to": "line-of-business", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/lines-of-business/line-of-business/LOB-Demonstration", + "relationship-data": [{ + "relationship-key": "line-of-business.line-of-business-name", + "relationship-value": "LOB-Demonstration" + }] + }] + } +} + """ + } + + String mockServiceProfile1() { + return """ + { + "service-instance-id": "0d3d3cce-46a8-486d-816a-954e71697c4e", + "service-instance-name": "DemoEmbb2", + "service-role": "e2esliceprofile-service", + "environment-context": "01-5C83F071", + "model-invariant-id": "040b1b40-3120-446b-b8e3-4f21d153d11e", + "model-version-id": "8b7dabb3-3f27-4555-a9fe-803e862b0292", + "service-instance-location-id": "39-00", + "resource-version": "1593511782269", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4b2bdbc0-cf7e-4c50-882a-f660e3ab8520", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "4b2bdbc0-cf7e-4c50-882a-f660e3ab8520" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "DemoEmbb" + }] + }] + }, + "allotted-resources": { + "allotted-resource": [{ + "id": "362e46c2-cd84-45e4-a6c1-77f4ef88328d", + "model-invariant-id": "e5941a50-ddb4-4f74-be03-25449ae02ddc", + "model-version-id": "ab171d60-c2cc-4903-ac1d-c451b647e461", + "resource-version": "1593511173712", + "type": "Allotted Resource", + "allotted-resource-name": "Allotted_DemoEmbb", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/ea107578-9854-4718-8145-7c7febf0de6c", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "ea107578-9854-4718-8145-7c7febf0de6c" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "nsi_DemoEmbb" + }] + }] + } + }] + }, + "slice-profiles": { + "slice-profile": [{ + "profile-id": "31a83df8-5bd0-4df7-a50f-7900476b81a2", + "latency": 3, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "Beijing;Beijing;HaidianDistrict;WanshouluStreet", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 500, + "exp-data-rate-DL": 2000, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "s-nssai": "01-5C83F071", + "resource-version": "1593525640617" + }] + } +} + + """ + } + + String mockServiceProfile2() { + return """ + { + "service-instance-id": "1c7046f2-a5a3-4d7f-9da8-388ee641a795", + "service-instance-name": "DemoEmbb", + "service-role": "e2esliceprofile-service", + "environment-context": "01-5B179BD4", + "model-invariant-id": "040b1b40-3120-446b-b8e3-4f21d153d12e", + "model-version-id": "8b7dabb3-3f27-4555-a9fe-803e862b0282", + "service-instance-location-id": "39-00", + "resource-version": "1593511782169", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4b2bdbc0-cf7e-4c50-882a-f660e3ab8520", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "4b2bdbc0-cf7e-4c50-882a-f660e3ab8520" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "DemoEmbb" + }] + }] + }, + "allotted-resources": { + "allotted-resource": [{ + "id": "362e46c2-cd84-45e4-a6c1-77f4ef88328d", + "model-invariant-id": "e5941a50-ddb4-4f74-be03-25449ae02ddc", + "model-version-id": "ab171d60-c2cc-4903-ac1d-c451b647e461", + "resource-version": "1593511173712", + "type": "Allotted Resource", + "allotted-resource-name": "Allotted_DemoEmbb", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/ea107578-9854-4718-8145-7c7febf0de6c", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "ea107578-9854-4718-8145-7c7febf0de6c" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "nsi_DemoEmbb" + }] + }] + } + }] + }, + "slice-profiles": { + "slice-profile": [{ + "profile-id": "b86df550-9d70-452b-a5a9-eb8823417255", + "latency": 6, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "Beijing;Beijing;HaidianDistrict;WanshouluStreet", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 500, + "exp-data-rate-DL": 1000, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "s-nssai": "01-5B179BD4", + "resource-version": "1593511356725" + }] + } +} + """ + } + + String mockQuerySliceServiceReturn(){ + String expect = + """{ + "service-instance-id": "NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX", + "service-instance-name": "nssi_DemoEmbb", + "service-role": "nssi", + "environment-context": "cn", + "model-invariant-id": "da575e8e-0863-4172-88b3-b3a9ead67895", + "model-version-id": "e398c92f-27da-44b9-a717-1dbfc1bdd82e", + "service-instance-location-id": "39-00", + "resource-version": "1593525640482", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/206535e7-77c9-4036-9387-3f1cf57b4379", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "206535e7-77c9-4036-9387-3f1cf57b4379" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "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", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "0d3d3cce-46a8-486d-816a-954e71697c4e" + }, { + "relationship-key": "allotted-resource.id", + "relationship-value": "d63c241a-4c0b-4294-b4c3-5a57421a1769" + }], + "related-to-property": [{ + "property-key": "allotted-resource.description" + }, { + "property-key": "allotted-resource.allotted-resource-name", + "property-value": "Allotted_DemoEmbb_shared" + }] + }, { + "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/1c7046f2-a5a3-4d7f-9da8-388ee641a795/allotted-resources/allotted-resource/362e46c2-cd84-45e4-a6c1-77f4ef88328d", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "1c7046f2-a5a3-4d7f-9da8-388ee641a795" + }, { + "relationship-key": "allotted-resource.id", + "relationship-value": "362e46c2-cd84-45e4-a6c1-77f4ef88328d" + }], + "related-to-property": [{ + "property-key": "allotted-resource.description" + }, { + "property-key": "allotted-resource.allotted-resource-name", + "property-value": "Allotted_DemoEmbb" + }] + } + ] + } +} + """ + return expect + } + + void setUpMockdataFromCommonActivateSliceSubnet() { + + String bpmnRequest = """ + { + "serviceInstanceID": "NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX", + "networkType": "an/cn/tn", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "additionalProperties": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "snssaiList": [ + "01-5B179BD4" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098" + } + } + """ + + String sliceParams ="""{ + "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") + when(mockExecution.getVariable("nsiId")).thenReturn("NSI-M-001-HDBNJ-NSMF-01-A-ZX") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5G") + when(mockExecution.getVariable("operationType")).thenReturn("deactivateInstance") + when(mockExecution.getVariable("jobId")).thenReturn("5ad89cf9-0569-4a93-9999-d8324321e2be") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(bpmnRequest) + when(mockExecution.getVariable("sliceParams")).thenReturn(sliceParams) + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateCoreNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateCoreNSSI.bpmn new file mode 100644 index 0000000000..b422545e84 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateCoreNSSI.bpmn @@ -0,0 +1,420 @@ + + + + + SequenceFlow_0wwo1lh + + + SequenceFlow_0wwo1lh + SequenceFlow_139ejmn + import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.preProcessRequest(execution) + + + SequenceFlow_1654pt0 + SequenceFlow_09nihof + import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.getServiceVNFAndVFsFromCatalogDB(execution) + + + SequenceFlow_09nihof + SequenceFlow_0fbr356 + import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.prepareSOMacroRequestPayLoad(execution) + + + SequenceFlow_1e20i9g + SequenceFlow_0j0egoi + import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.updateSliceProfileOrchestrationStatus(execution) + + + SequenceFlow_139ejmn + SequenceFlow_1654pt0 + import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.getNetworkInstanceWithSPInstanceAssociatedWithNssiId(execution) + + + SequenceFlow_1mi4waj + SequenceFlow_0rjd7tg + import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.sendPutRequestToSOMacro(execution) + + + Flow_039sx2v + SequenceFlow_18x9gdi + import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.prepareCallCheckProcessStatus(execution) + + + + + + + + + + + + + + + + + + + + + SequenceFlow_18x9gdi + SequenceFlow_1l9ry0a + + + SequenceFlow_1l9ry0a + SequenceFlow_0wx21io + import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.prepareUpdateResourceOperationStatus(execution) + + + + + + + + + SequenceFlow_0fbr356 + + + + + SequenceFlow_1mi4waj + + + + + SequenceFlow_0wx21io + SequenceFlow_1e20i9g + SequenceFlow_07u1gfw + + + + #{(execution.getVariable("isTimeOut") == "NO")} + + + SequenceFlow_0v0dntm + + + + SequenceFlow_0rjd7tg + Flow_039sx2v + Flow_1jchhgj + + + #{(execution.getVariable("isSOResponseSucceed" ) == "yes")} + + + + + + ${dbAdapterEndpoint} + + + application/soap+xml + Basic YnBlbDpwYXNzd29yZDEk + + + ${updateOperationStatus} + POST + ${statusCode} + ${response} + + http-connector + + + Flow_1jchhgj + SequenceFlow_0j0egoi + SequenceFlow_07u1gfw + SequenceFlow_0v0dntm + + + + + + + + Flow_149oqyp + + + + Flow_1qooaff + + + Flow_1iqw69c + Flow_1qooaff + import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution) + + + Flow_149oqyp + Flow_1dh5sht + import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.prepareFailedOperationStatusUpdate(execution) + + + + + + ${dbAdapterEndpoint} + + + application/soap+xml + Basic YnBlbDpwYXNzd29yZDEk + + + ${updateResourceOperationStatus} + POST + ${statusCode} + ${response} + + http-connector + + + Flow_1dh5sht + Flow_1iqw69c + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit 1.2.3-korg