diff options
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common')
28 files changed, 1600 insertions, 1305 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy index 36d579c7ab..5c030a9f86 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy @@ -20,9 +20,7 @@ package org.onap.so.bpmn.infrastructure.scripts -import static org.apache.commons.lang3.StringUtils.isBlank -import java.lang.reflect.Type -import javax.ws.rs.NotFoundException + import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.* @@ -32,9 +30,12 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder -import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.logging.filter.base.ErrorCode -import org.onap.so.beans.nsmf.NSSI +import org.onap.so.beans.nsmf.CustomerInfo +import org.onap.so.beans.nsmf.NetworkType +import org.onap.so.beans.nsmf.NssInstance +import org.onap.so.beans.nsmf.OperationType +import org.onap.so.beans.nsmf.OrchestrationStatusEnum import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils @@ -46,8 +47,11 @@ import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory -import com.google.gson.Gson -import com.google.gson.reflect.TypeToken + +import javax.ws.rs.NotFoundException +import java.util.function.Consumer + +import static org.apache.commons.lang3.StringUtils.isBlank /** * This groovy class supports the <class>ActivateSliceService.bpmn</class> process. @@ -66,6 +70,8 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { RequestDBUtil requestDBUtil = new RequestDBUtil() + AAIResourcesClient client = getAAIClient() + private static final Logger logger = LoggerFactory.getLogger(ActivateSliceService.class) void preProcessRequest(DelegateExecution execution) { @@ -75,7 +81,7 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { try { // check for incoming json message/input - String siRequest = execution.getVariable("bpmnRequest") + String siRequest = Objects.requireNonNull(execution.getVariable("bpmnRequest")) logger.debug(siRequest) String requestId = execution.getVariable("mso-request-id") @@ -109,13 +115,20 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { } else { execution.setVariable("subscriptionServiceType", subscriptionServiceType) } - String operationId = jsonUtil.getJsonValue(siRequest, "operationId") + String operationId = Objects.requireNonNull(jsonUtil.getJsonValue(siRequest, "operationId")) execution.setVariable("operationId", operationId) - String operationType = execution.getVariable("operationType") - execution.setVariable("operationType", operationType.toUpperCase()) - + String operationType = Objects.requireNonNull(execution.getVariable("operationType")) logger.info("operationType is " + execution.getVariable("operationType") ) + + CustomerInfo customerInfo = CustomerInfo.builder().operationId(operationId) + .operationType(Objects.requireNonNull(OperationType.getOperationType(operationType))) + .globalSubscriberId(globalSubscriberId).serviceInstanceId(serviceInstanceId) + .subscriptionServiceType(subscriptionServiceType) + .build() + + execution.setVariable("customerInfo", customerInfo) + } catch (BpmnError e) { throw e } catch (Exception ex) { @@ -126,14 +139,58 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { logger.debug(Prefix + "preProcessRequest Exit") } + /** + * Init the service Operation Status + */ + def prepareInitServiceOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareActivateServiceOperationStatus Start") + try { + CustomerInfo customerInfo = execution.getVariable("customerInfo") as CustomerInfo + String serviceId = customerInfo.getServiceInstanceId() + String operationId = customerInfo.getOperationId() + String operationType = customerInfo.getOperationType().getType() + String userId = customerInfo.getGlobalSubscriberId() + String result = "processing" + String progress = "0" + String reason = "" + String operationContent = "Prepare service activation" + + execution.setVariable("e2eserviceInstanceId", serviceId) + //execution.setVariable("operationType", operationType) + + OperationStatus initStatus = new OperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(operationId) + initStatus.setOperation(operationType) + initStatus.setUserId(userId) + initStatus.setResult(result) + initStatus.setProgress(progress) + initStatus.setReason(reason) + initStatus.setOperationContent(operationContent) + + requestDBUtil.prepareUpdateOperationStatus(execution, initStatus) + + } catch (Exception e) { + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + "Exception Occured Processing prepareInitServiceOperationStatus.", "BPMN", + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e) + execution.setVariable("CVFMI_ErrorResponse", + "Error Occurred during prepareInitServiceOperationStatus Method:\n" + e.getMessage()) + } + logger.debug(Prefix + "prepareInitServiceOperationStatus Exit") + } + def sendSyncResponse = { DelegateExecution execution -> logger.debug(Prefix + "sendSyncResponse Start") try { - String operationId = execution.getVariable("operationId") + CustomerInfo customerInfo = execution.getVariable("customerInfo") as CustomerInfo + String operationId = customerInfo.getOperationId() + // RESTResponse for API Handler (APIH) Reply Task String Activate5GsliceServiceRestRequest = """{"operationId":"${operationId}"}""".trim() logger.debug(" sendSyncResponse to APIH:" + "\n" + Activate5GsliceServiceRestRequest) + sendWorkflowResponse(execution, 202, Activate5GsliceServiceRestRequest) execution.setVariable("sentSyncResponse", true) } catch (Exception ex) { @@ -171,410 +228,289 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { logger.debug(Prefix + "sendSyncError Exit") } + def checkAAIOrchStatusOfE2ESlice = { DelegateExecution execution -> + logger.debug(Prefix + "CheckAAIOrchStatus Start") + execution.setVariable("isContinue", "false") + CustomerInfo customerInfo = execution.getVariable("customerInfo") as CustomerInfo + String msg + String serviceInstanceId = customerInfo.serviceInstanceId + String globalSubscriberId = customerInfo.globalSubscriberId + String subscriptionServiceType = customerInfo.subscriptionServiceType - def prepareCompletionRequest = { DelegateExecution execution -> - logger.debug(Prefix + "prepareCompletionRequest Start") - String serviceId = execution.getVariable("serviceInstanceId") - String operationId = execution.getVariable("operationId") - String userId = execution.getVariable("globalSubscriberId") - //String result = execution.getVariable("result") - String result = "finished" - String progress = "100" - String reason = "" - String operationContent = execution.getVariable("operationContent") - String operationType = execution.getVariable("operationType") - - OperationStatus initStatus = new OperationStatus() - initStatus.setServiceId(serviceId) - initStatus.setOperationId(operationId) - initStatus.setOperation(operationType) - initStatus.setUserId(userId) - initStatus.setResult(result) - initStatus.setProgress(progress) - initStatus.setReason(reason) - initStatus.setOperationContent(operationContent) - - requestDBUtil.prepareUpdateOperationStatus(execution, initStatus) - - logger.debug(Prefix + "prepareCompletionRequest Exit") - } - + logger.debug("serviceInstanceId: " + serviceInstanceId) - /** - * Init the service Operation Status - */ - def prepareInitServiceOperationStatus = { DelegateExecution execution -> - logger.debug(Prefix + "prepareActivateServiceOperationStatus Start") + //check the e2e slice status try { - String serviceId = execution.getVariable("serviceInstanceId") - String operationId = execution.getVariable("operationId") - String operationType = execution.getVariable("operationType") - String userId = execution.getVariable("globalSubscriberId") - String result = "processing" - String progress = "0" - String reason = "" - String operationContent = "Prepare service activation" - - execution.setVariable("e2eserviceInstanceId", serviceId) - execution.setVariable("operationType", operationType) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId) + .serviceSubscription(subscriptionServiceType) + .serviceInstance(serviceInstanceId)) - OperationStatus initStatus = new OperationStatus() - initStatus.setServiceId(serviceId) - initStatus.setOperationId(operationId) - initStatus.setOperation(operationType) - initStatus.setUserId(userId) - initStatus.setResult(result) - initStatus.setProgress(progress) - initStatus.setReason(reason) - initStatus.setOperationContent(operationContent) + AAIResultWrapper wrapper = client.get(uri, NotFoundException.class) + Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) + ServiceInstance serviceInstance = si.orElseThrow() - requestDBUtil.prepareUpdateOperationStatus(execution, initStatus) + boolean isContinue = handleOperation(customerInfo, serviceInstance) + execution.setVariable("isContinue", isContinue) + customerInfo.setSnssai(serviceInstance.getEnvironmentContext()) - } catch (Exception e) { - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - "Exception Occured Processing prepareInitServiceOperationStatus.", "BPMN", - ErrorCode.UnknownError.getValue(), "Exception is:\n" + e) - execution.setVariable("CVFMI_ErrorResponse", - "Error Occurred during prepareInitServiceOperationStatus Method:\n" + e.getMessage()) + execution.setVariable("customerInfo", customerInfo) + execution.setVariable("ssInstance", serviceInstance) + execution.setVariable("ssiUri", uri) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + execution.setVariable("isContinue", "false") + msg = "Exception in org.onap.so.bpmn.common.scripts.CompleteMsoProcess.CheckAAIOrchStatus, " + + "Requested e2eservice does not exist: " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - logger.debug(Prefix + "prepareInitServiceOperationStatus Exit") - } + logger.debug(Prefix + "CheckAAIOrchStatus Exit") + } - private getSNSSIStatusByNsi = { DelegateExecution execution, String NSIServiceId -> + static boolean handleOperation(CustomerInfo customerInfo, ServiceInstance serviceInstance) { + OperationType operationType = customerInfo.operationType + OrchestrationStatusEnum status = OrchestrationStatusEnum.getStatus(Objects.requireNonNull( + serviceInstance.getOrchestrationStatus())) - logger.debug(Prefix + "getSNSSIStatusByNsi Start") - String globalSubscriberId = execution.getVariable("globalSubscriberId") - String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + return ((OrchestrationStatusEnum.ACTIVATED == status && OperationType.DEACTIVATE == operationType) + || (OrchestrationStatusEnum.DEACTIVATED == status && OperationType.ACTIVATE == operationType)) + } - AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(NSIServiceId)) - if (!client.exists(uri)) { - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") - } - AAIResultWrapper wrapper = client.get(uri, NotFoundException.class) - Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) - if (si.isPresent()) { + void checkAAIOrchStatusOfAllocates(DelegateExecution execution) { + logger.debug(Prefix + "CheckAAIOrchStatus Start") + CustomerInfo customerInfo = execution.getVariable("customerInfo") as CustomerInfo + String msg + String serviceInstanceId = customerInfo.serviceInstanceId + String globalSubscriberId = customerInfo.globalSubscriberId + String subscriptionServiceType = customerInfo.subscriptionServiceType - List<Relationship> relatedList = si.get().getRelationshipList().getRelationship() - for (Relationship relationship : relatedList) { - String relatedTo = relationship.getRelatedTo() - if (relatedTo.toLowerCase() == "allotted-resource") { - //get snssi from allotted resource in list by nsi - List<String> SNSSIList = new ArrayList<>() - List<RelationshipData> relationshipDataList = relationship.getRelationshipData() - for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "service-instance.service-instance-id") { - SNSSIList.add(relationshipData.getRelationshipValue()) - } - } - for (String snssi : SNSSIList) { - AAIResourcesClient client01 = new AAIResourcesClient() - AAIResourceUri uri01 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(snssi)) - if (!client.exists(uri01)) { - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, - "Service Instance was not found in aai") - } - AAIResultWrapper wrapper01 = client01.get(uri01, NotFoundException.class) - Optional<ServiceInstance> nssiSi = wrapper01.asBean(ServiceInstance.class) - if (nssiSi.isPresent()) { - return nssiSi.get().getOrchestrationStatus() == "deactivated" - } - } + logger.debug("serviceInstanceId: " + serviceInstanceId) - } - } + //check the NSI is exist or the status of NSI is active or de-active + try { - } - logger.debug(Prefix + "getSNSSIStatusByNsi Exit") - } + //get the allotted-resources by e2e slice id + AAIPluralResourceUri uriAllotted = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId) + .serviceSubscription(subscriptionServiceType) + .serviceInstance(serviceInstanceId) + .allottedResources() + ) + AAIResultWrapper wrapperAllotted = client.get(uriAllotted, NotFoundException.class) + Optional<AllottedResources> allAllotted = wrapperAllotted.asBean(AllottedResources.class) - def updateStatusSNSSAIandNSIandNSSI = { DelegateExecution execution -> - logger.debug(Prefix + "updateStatusSNSSAIandNSIandNSSI Start") - logger.debug(" ***** update SNSSAI NSI NSSI slicing ***** ") - String e2eserviceInstanceId = execution.getVariable("e2eserviceInstanceId") - String NSIserviceInstanceId = execution.getVariable("NSIserviceid") - - String globalCustId = execution.getVariable("globalSubscriberId") - String serviceType = execution.getVariable("serviceType") - String operationType = execution.getVariable("operationType") - - String nssiMap = execution.getVariable("nssiMap") - Type type = new TypeToken<HashMap<String, NSSI>>() {}.getType() - Map<String, NSSI> activateNssiMap = new Gson().fromJson(nssiMap, type) - //update tn/cn/an nssi - for (Map.Entry<String, NSSI> entry : activateNssiMap.entrySet()) { - NSSI nssi = entry.getValue() - String nssiid = nssi.getNssiId() - updateStratus(execution, globalCustId, serviceType, nssiid, operationType) - } - if (operationType.equalsIgnoreCase("activation")) { - //update the s-nssai - updateStratus(execution, globalCustId, serviceType, e2eserviceInstanceId, operationType) - //update the nsi - updateStratus(execution, globalCustId, serviceType, NSIserviceInstanceId, operationType) - } else { - //update the s-nssai - updateStratus(execution, globalCustId, serviceType, e2eserviceInstanceId, operationType) - boolean flag = getSNSSIStatusByNsi(execution, NSIserviceInstanceId) - if (flag) { - //update the nsi - updateStratus(execution, globalCustId, serviceType, NSIserviceInstanceId, operationType) - } else { - logger.error("Service's status update failed") - String msg = "Service's status update failed" - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + AllottedResources allottedResources = allAllotted.get() + List<AllottedResource> AllottedResourceList = allottedResources.getAllottedResource() + if (AllottedResourceList.isEmpty()) { + execution.setVariable("isContinue", "false") + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, + "allottedResources in aai is empty") } + AllottedResource ar = AllottedResourceList.first() + String relatedLink = ar.getRelationshipList().getRelationship().first().getRelatedLink() + String nsiServiceId = relatedLink.substring(relatedLink.lastIndexOf("/") + 1, relatedLink.length()) + customerInfo.setNsiId(nsiServiceId) + execution.setVariable("customerInfo", customerInfo) + logger.info("the NSI ID is:" + nsiServiceId) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + logger.info("NSI Service doesnt exist") + execution.setVariable("isContinue", "false") + msg = "Exception in org.onap.so.bpmn.common.scripts.CompleteMsoProcess.CheckAAIOrchStatus " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - logger.debug(Prefix + "updateStatusSNSSAIandNSIandNSSI Exit") + logger.debug(Prefix + "CheckAAIOrchStatus Exit") } + void checkAAIOrchStatusOfNSI(DelegateExecution execution) { - def updateStratus = { DelegateExecution execution, String globalCustId, - String serviceType, String serviceId, String operationType -> - logger.debug(Prefix + "updateStratus Start") + logger.debug(Prefix + "CheckAAIOrchStatus Start") + CustomerInfo customerInfo = execution.getVariable("customerInfo") as CustomerInfo + String msg = "" + String globalSubscriberId = customerInfo.globalSubscriberId + String subscriptionServiceType = customerInfo.subscriptionServiceType + String nsiServiceId = customerInfo.getNsiId() + + logger.debug("network slice instance id: " + nsiServiceId) + //check the NSI is exist or the status of NSI is active or de-active try { - AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(serviceId)) - if (!client.exists(uri)) { - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") - } + //Query nsi by nsi id + + //get the NSI id by e2e slice id + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId) + .serviceSubscription(subscriptionServiceType) + .serviceInstance(nsiServiceId)) + AAIResultWrapper wrapper = client.get(uri, NotFoundException.class) Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) - if (si.isPresent()) { - if (operationType.equalsIgnoreCase("activation")) { - if (si.get().getOrchestrationStatus() == "deactivated") { - si.get().setOrchestrationStatus("activated") - client.update(uri, si.get()) - } - } else { - if (si.get().getOrchestrationStatus() == "activated") { - si.get().setOrchestrationStatus("deactivated") - client.update(uri, si.get()) - } - } - + ServiceInstance nsInstance = si.get() + if (!"nsi".equalsIgnoreCase(nsInstance.getServiceRole().toLowerCase())) { + logger.info("the service id" + nsInstance.getServiceInstanceId() + "is " + + nsInstance.getServiceRole()) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - } catch (Exception e) { - logger.info("Service is already in active state") - String msg = "Service is already in active state, " + e.getMessage() + execution.setVariable("nsInstance", nsInstance) + execution.setVariable("nsiUri", uri) + boolean isContinue = handleOperation(customerInfo, nsInstance) + execution.setVariable("isContinue", isContinue) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + logger.info("NSI Service doesnt exist") + execution.setVariable("isActivate", "false") + execution.setVariable("isContinue", "false") + msg = "Exception in org.onap.so.bpmn.common.scripts.CompleteMsoProcess.CheckAAIOrchStatus " + ex.getMessage() + logger.info(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - - logger.debug(Prefix + "updateStratus Exit") + logger.debug(Prefix + "CheckAAIOrchStatus Exit") } - - def prepareActivation = { DelegateExecution execution -> + void prepareActivation(DelegateExecution execution) { logger.debug(Prefix + "prepareActivation Start") - logger.debug(" ***** prepare active NSI/AN/CN/TN slice ***** ") - String NSIserviceInstanceId = execution.getVariable("NSIserviceid") - - String globalSubscriberId = execution.getVariable("globalSubscriberId") - String subscriptionServiceType = execution.getVariable("subscriptionServiceType") - - Map<String, NSSI> nssiMap = new HashMap<>() + CustomerInfo customerInfo = execution.getVariable("customerInfo") as CustomerInfo + String globalSubscriberId = customerInfo.globalSubscriberId + String subscriptionServiceType = customerInfo.subscriptionServiceType - List<String> activationSequence = new ArrayList<>(Arrays.asList("an", "tn", "cn")) - - def activationCount = activationSequence.size() - - execution.setVariable("activationIndex", "0") + logger.debug(" ***** prepare active NSI/AN/CN/TN slice ***** ") - execution.setVariable("activationCount", activationCount) + Queue<NssInstance> nssInstances = new LinkedList<>() + ServiceInstance nsInstance = + execution.getVariable("nsInstance") as ServiceInstance try { //get the TN NSSI id by NSI id, active NSSI TN slicing - AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(NSIserviceInstanceId)) - if (!client.exists(uri)) { - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") - } - AAIResultWrapper wrapper = client.get(uri, NotFoundException.class) - Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) - if (si.isPresent()) { - - List<Relationship> relatedList = si.get().getRelationshipList().getRelationship() - for (Relationship relationship : relatedList) { - String relatedTo = relationship.getRelatedTo() - if (relatedTo.toLowerCase() == "service-instance") { - String relatioshipurl = relationship.getRelatedLink() - String nssiserviceid = - relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, relatioshipurl.length()) - - AAIResourcesClient client01 = new AAIResourcesClient() - AAIResourceUri uri01 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiserviceid)) - if (!client.exists(uri01)) { - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, - "Service Instance was not found in aai") - } - AAIResultWrapper wrapper01 = client01.get(uri01, NotFoundException.class) - Optional<ServiceInstance> nssiSi = wrapper01.asBean(ServiceInstance.class) - if (nssiSi.isPresent()) { - if (nssiSi.get().getEnvironmentContext().toLowerCase().contains("an") - || nssiSi.get().getEnvironmentContext().toLowerCase().contains("cn") - || nssiSi.get().getEnvironmentContext().toLowerCase().contains("tn")) { - nssiMap.put(nssiSi.get().getEnvironmentContext(), - new NSSI(nssiSi.get().getServiceInstanceId(), - nssiSi.get().getModelInvariantId(), nssiSi.get().getModelVersionId())) - } - } - } + List<Relationship> relatedList = nsInstance.getRelationshipList().getRelationship() + for (Relationship relationship : relatedList) { + String relatedTo = relationship.getRelatedTo() + if (!"service-instance".equalsIgnoreCase(relatedTo)) { + continue } - - + String relatioshipurl = relationship.getRelatedLink() + String nssiserviceid = relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, + relatioshipurl.length()) + + AAIResourceUri nsiUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId) + .serviceSubscription(subscriptionServiceType) + .serviceInstance(nssiserviceid)) + if (!client.exists(nsiUri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, + "Service Instance was not found in aai") + } + AAIResultWrapper wrapper01 = client.get(nsiUri, NotFoundException.class) + Optional<ServiceInstance> nssiSi = wrapper01.asBean(ServiceInstance.class) + nssiSi.ifPresent(new Consumer<ServiceInstance>() { + @Override + void accept(ServiceInstance instance) { + String env = Objects.requireNonNull(instance.getEnvironmentContext()) + NssInstance nssi = NssInstance.builder().nssiId(instance.getServiceInstanceId()) + .modelInvariantId(instance.getModelInvariantId()) + .modelVersionId(instance.getModelVersionId()) + .networkType(NetworkType.fromString(env)) + .operationType(customerInfo.operationType) + .snssai(customerInfo.snssai) + .serviceType(instance.getServiceType()) + .build() + nssInstances.offer(nssi) + } + }) } + execution.setVariable("nssInstances", nssInstances) + execution.setVariable("nssInstanceInfos", nssInstances) } catch (Exception e) { String msg = "Requested service does not exist:" + e.getMessage() logger.info("Service doesnt exist") exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - if (nssiMap.size() > 0) { - execution.setVariable("isNSSIActivate", "true") - String nssiMap01 = mapToJsonStr(nssiMap) - execution.setVariable("nssiMap", nssiMap01) - execution.setVariable("operation_type", "activate") - execution.setVariable("activationCount", nssiMap.size()) - logger.info("the nssiMap01 is :" + nssiMap01) - } else { - execution.setVariable("isNSSIActivate", "false") - } - logger.debug(Prefix + "prepareActivation Exit") } - - private mapToJsonStr = { HashMap<String, NSSI> stringNSSIHashMap -> - HashMap<String, NSSI> map = new HashMap<String, NSSI>() - for (Map.Entry<String, NSSI> child : stringNSSIHashMap.entrySet()) { - map.put(child.getKey(), child.getValue()) + void isOperationFinished(DelegateExecution execution) { + Queue<NssInstance> nssInstances = execution.getVariable("nssInstances") as Queue<NssInstance> + if (nssInstances.isEmpty()) { + execution.setVariable("isOperationFinished", "true") } - return new Gson().toJson(map) } + def updateStatusSNSSAIandNSIandNSSI = { DelegateExecution execution -> + logger.debug(Prefix + "updateStatusSNSSAIandNSIandNSSI Start") + logger.debug(" ***** update SNSSAI NSI NSSI slicing ***** ") + ServiceInstance ssInstance = execution.getVariable("ssInstance") as ServiceInstance + AAIResourceUri ssUri = execution.getVariable("ssiUri") as AAIResourceUri - def checkAAIOrchStatusofslice = { DelegateExecution execution -> - logger.debug(Prefix + "CheckAAIOrchStatus Start") + CustomerInfo customerInfo = execution.getVariable("customerInfo") as CustomerInfo + OperationType operationType = customerInfo.operationType - String msg = "" - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String globalSubscriberId = execution.getVariable("globalSubscriberId") - String subscriptionServiceType = execution.getVariable("subscriptionServiceType") - String operationType = execution.getVariable("operationType") + updateStratus(execution, ssInstance, operationType, ssUri) + //update the nsi + ServiceInstance nsInstance = execution.getVariable("nsInstance") as ServiceInstance + AAIResourceUri nsiUri = execution.getVariable("nsiUri") as AAIResourceUri - logger.debug("serviceInstanceId: " + serviceInstanceId) + updateStratus(execution, nsInstance, operationType, nsiUri) - //check the e2e slice status - try { - try { - AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId)) - if (!client.exists(uri)) { - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, - "Service Instance was not found in aai") - } - AAIResultWrapper wrapper = client.get(uri, NotFoundException.class) - Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) - if (si.isPresent()) { - if (si.get().getOrchestrationStatus().toLowerCase() == "activated" && - operationType.equalsIgnoreCase("deactivation")) { - logger.info("Service is in active state") - execution.setVariable("e2eservicestatus", "activated") - execution.setVariable("isContinue", "true") - String snssai = si.get().getEnvironmentContext() - execution.setVariable("snssai", snssai) - } else if (si.get().getOrchestrationStatus().toLowerCase() == "deactivated" && - operationType.equalsIgnoreCase("activation")) { - logger.info("Service is in de-activated state") - execution.setVariable("e2eservicestatus", "deactivated") - execution.setVariable("isContinue", "true") - String snssai = si.get().getEnvironmentContext() - execution.setVariable("snssai", snssai) - } else { - execution.setVariable("isContinue", "false") - } - } - } catch (Exception e) { - msg = "Requested e2eservice does not exist" - logger.info("e2eservice doesnt exist") - execution.setVariable("isContinue", "false") - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - //check the NSI is exist or the status of NSI is active or de-active - try { + logger.debug(Prefix + "updateStatusSNSSAIandNSIandNSSI Exit") + } - //get the allotted-resources by e2e slice id - AAIResourcesClient client_allotted = new AAIResourcesClient() - AAIPluralResourceUri uri_allotted = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId).allottedResources() - ) - if (!client_allotted.exists(uri_allotted)) { - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") - } - AAIResultWrapper wrapper_allotted = client_allotted.get(uri_allotted, NotFoundException.class) - Optional<AllottedResources> all_allotted = wrapper_allotted.asBean(AllottedResources.class) - - if (all_allotted.isPresent() && all_allotted.get().getAllottedResource()) { - List<AllottedResource> AllottedResourceList = all_allotted.get().getAllottedResource() - AllottedResource ar = AllottedResourceList.first() - String relatedLink = ar.getRelationshipList().getRelationship().first().getRelatedLink() - String nsiserviceid = relatedLink.substring(relatedLink.lastIndexOf("/") + 1, relatedLink.length()) - execution.setVariable("NSIserviceid", nsiserviceid) - logger.info("the NSI ID is:" + nsiserviceid) - - //Query nsi by nsi id - try { - //get the NSI id by e2e slice id - AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nsiserviceid)) - if (!client.exists(uri)) { - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, - "Service Instance was not found in aai") - } - AAIResultWrapper wrapper = client.get(uri, NotFoundException.class) - Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) - - if (si.isPresent()) { - if (si.get().getServiceRole().toLowerCase() == "nsi") { - if (si.get().getOrchestrationStatus() == "activated") { - logger.info("NSI services is in activated state") - execution.setVariable("NSIservicestatus", "activated") - } else { - logger.info("NSI services is in deactivated state") - execution.setVariable("NSIservicestatus", "deactivated") - } - } else { - logger.info("the service id" + si.get().getServiceInstanceId() + "is " + - si.get().getServiceRole()) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - } - } catch (Exception e) { - msg = "Requested NSI service does not exist:" + e.getMessage() - logger.info("NSI service doesnt exist") - execution.setVariable("isContinue", "false") - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - } - } catch (Exception e) { - msg = "Requested service does not exist: " + e.getMessage() - logger.info("NSI Service doesnt exist") - execution.setVariable("isActivate", "false") - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + void updateStratus(DelegateExecution execution, ServiceInstance serviceInstance, + OperationType operationType, AAIResourceUri uri) { + + logger.debug(Prefix + "updateStratus Start") + + try { + serviceInstance.setOrchestrationStatus() + if (OperationType.ACTIVATE == operationType) { + serviceInstance.setOrchestrationStatus(OrchestrationStatusEnum.ACTIVATED.getValue()) + } else { + serviceInstance.setOrchestrationStatus(OrchestrationStatusEnum.DEACTIVATED.getValue()) } - } catch (BpmnError e) { - throw e - } catch (Exception ex) { - msg = "Exception in org.onap.so.bpmn.common.scripts.CompleteMsoProcess.CheckAAIOrchStatus " + ex.getMessage() - logger.info(msg) + client.update(uri, serviceInstance) + } catch (Exception e) { + logger.info("Service is already in active state") + String msg = "Service is already in active state, " + e.getMessage() exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - logger.debug(Prefix + "CheckAAIOrchStatus Exit") + logger.debug(Prefix + "updateStratus Exit") } + def prepareCompletionRequest = { DelegateExecution execution -> + logger.debug(Prefix + "prepareCompletionRequest Start") + CustomerInfo customerInfo = execution.getVariable("customerInfo") as CustomerInfo + String serviceId = customerInfo.getServiceInstanceId() + String operationId = customerInfo.getOperationId() + String userId = customerInfo.getGlobalSubscriberId() + + String result = "finished" + String progress = "100" + String reason = "" + String operationContent = "action finished success" + String operationType = customerInfo.operationType.getType() + + OperationStatus initStatus = new OperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(operationId) + initStatus.setOperation(operationType) + initStatus.setUserId(userId) + initStatus.setResult(result) + initStatus.setProgress(progress) + initStatus.setReason(reason) + initStatus.setOperationContent(operationContent) + + requestDBUtil.prepareUpdateOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareCompletionRequest Exit") + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy index 9100f2773b..e2d9c16328 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy @@ -149,16 +149,17 @@ class AllocateSliceSubnet extends AbstractServiceTaskProcessor { def prepareInitOperationStatus = { DelegateExecution execution -> logger.debug(Prefix + "prepareInitOperationStatus Start") - String serviceId = execution.getVariable("dummyServiceId") + String modelUuid = execution.getVariable("modelUuid") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") - logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) + logger.debug("Generated new job for Service Instance serviceId:" + modelUuid + " jobId:" + jobId) ResourceOperationStatus initStatus = new ResourceOperationStatus() - initStatus.setServiceId(serviceId) - initStatus.setOperationId(jobId) - initStatus.setResourceTemplateUUID(nsiId) - initStatus.setOperType("Allocate") + initStatus.setServiceId(nsiId) // set nsiId to this field + initStatus.setOperationId(jobId) // set jobId to this field + initStatus.setResourceTemplateUUID(modelUuid) // set modelUuid to this field + initStatus.setOperType("ALLOCATE") + //initStatus.setResourceInstanceID() // set nssiId to this field requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) logger.debug(Prefix + "prepareInitOperationStatus Exit") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy index 4108ccecff..da9584771c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy @@ -37,6 +37,7 @@ import java.sql.Timestamp import java.util.List import static org.apache.commons.lang3.StringUtils.isBlank import com.google.gson.JsonObject +import com.google.gson.JsonParser import com.fasterxml.jackson.databind.ObjectMapper import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.AAIResourcesClient @@ -48,14 +49,13 @@ import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.T import javax.ws.rs.NotFoundException import org.onap.so.beans.nsmf.AllocateTnNssi import org.onap.so.beans.nsmf.DeAllocateNssi -import org.onap.so.beans.nsmf.EsrInfo import org.onap.so.beans.nsmf.ServiceInfo import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.aai.domain.yang.ServiceInstance import org.onap.aai.domain.yang.SliceProfile import org.onap.aai.domain.yang.SliceProfiles import org.onap.aai.domain.yang.Relationship - +import com.google.gson.Gson class AnNssmfUtils { @@ -65,12 +65,11 @@ class AnNssmfUtils { JsonUtils jsonUtil = new JsonUtils() public String buildSelectRANNSSIRequest(String requestId, String messageType, String UUID,String invariantUUID, String name, Map<String, Object> profileInfo, List<String> nsstInfoList, JsonArray capabilitiesList, Boolean preferReuse){ - + JsonParser parser = new JsonParser() def transactionId = requestId logger.debug( "transactionId is: " + transactionId) String correlator = requestId String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator - ObjectMapper objectMapper = new ObjectMapper(); String profileJson = objectMapper.writeValueAsString(profileInfo); String nsstInfoListString = objectMapper.writeValueAsString(nsstInfoList); //Prepare requestInfo object @@ -91,8 +90,8 @@ class AnNssmfUtils { JsonObject json = new JsonObject() json.add("requestInfo", requestInfo) json.add("NSTInfo", ranNsstInfo) - json.addProperty("serviceProfile", profileJson) - json.addProperty("NSSTInfo", nsstInfoListString) + json.add("serviceProfile", (JsonObject) parser.parse(profileJson)) + //json.add("NSSTInfo", (JsonArray) parser.parse(nsstInfoListString)) json.add("subnetCapabilities", capabilitiesList) json.addProperty("preferReuse", preferReuse) @@ -100,29 +99,33 @@ class AnNssmfUtils { } public String buildCreateTNNSSMFSubnetCapabilityRequest() { - EsrInfo esrInfo = new EsrInfo() - esrInfo.setNetworkType("TN") - esrInfo.setVendor("ONAP") + JsonObject esrInfo = new JsonObject() + esrInfo.addProperty("networkType", "tn") + esrInfo.addProperty("vendor", "ONAP_internal") JsonArray subnetTypes = new JsonArray() subnetTypes.add("TN_FH") subnetTypes.add("TN_MH") JsonObject response = new JsonObject() - response.add("subnetCapabilityQuery", subnetTypes) - response.addProperty("esrInfo", objectMapper.writeValueAsString(esrInfo)) + JsonObject subnetTypesObj = new JsonObject() + subnetTypesObj.add("subnetTypes", subnetTypes) + response.add("subnetCapabilityQuery", subnetTypesObj) + response.add("esrInfo", esrInfo) return response.toString() } public String buildCreateANNFNSSMFSubnetCapabilityRequest() { - EsrInfo esrInfo = new EsrInfo() - esrInfo.setNetworkType("AN") - esrInfo.setVendor("ONAP") + JsonObject esrInfo = new JsonObject() + esrInfo.addProperty("networkType", "an") + esrInfo.addProperty("vendor", "ONAP_internal") JsonArray subnetTypes = new JsonArray() subnetTypes.add("AN_NF") JsonObject response = new JsonObject() - response.add("subnetCapabilityQuery", subnetTypes) - response.addProperty("esrInfo", objectMapper.writeValueAsString(esrInfo)) + JsonObject subnetTypesObj = new JsonObject() + subnetTypesObj.add("subnetTypes", subnetTypes) + response.add("subnetCapabilityQuery", subnetTypesObj) + response.add("esrInfo", esrInfo) return response.toString() } public void createDomainWiseSliceProfiles(List<String> ranConstituentSliceProfiles, DelegateExecution execution) { @@ -194,12 +197,15 @@ public void createSliceProfilesInAai(DelegateExecution execution) { ANNF_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid) String serviceRole = "slice-profile-instance" ANNF_sliceProfileInstance.setServiceRole(serviceRole) - List<String> snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class) + ArrayList<String> snssaiList = execution.getVariable("snssaiList") String snssai = snssaiList.get(0) ANNF_sliceProfileInstance.setEnvironmentContext(snssai) ANNF_sliceProfileInstance.setWorkloadContext("AN-NF") ANNF_sliceProfileInstance.setSliceProfiles(ANNF_SliceProfiles) - logger.debug("completed ANNF sliceprofileinstance build "+ ANNF_sliceProfileInstance.toString()) + String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "resourceSharingLevel") + ANNF_sliceProfileInstance.setServiceFunction(serviceFunctionAnnf) + logger.debug("completed ANNF sliceprofileinstance build : "+ ANNF_sliceProfileInstance.toString()) + //TNFH slice profile instance creation TNFH_sliceProfileInstance.setServiceInstanceId(TNFH_sliceProfileInstanceId) sliceInstanceName = "sliceprofile_"+TNFH_sliceProfileId @@ -213,7 +219,10 @@ public void createSliceProfilesInAai(DelegateExecution execution) { TNFH_sliceProfileInstance.setEnvironmentContext(snssai) TNFH_sliceProfileInstance.setWorkloadContext("TN-FH") TNFH_sliceProfileInstance.setSliceProfiles(TNFH_SliceProfiles) - logger.debug("completed TNFH sliceprofileinstance build "+TNFH_sliceProfileInstance) + String serviceFunctionTnFH = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "resourceSharingLevel") + TNFH_sliceProfileInstance.setServiceFunction(serviceFunctionTnFH) + logger.debug("completed TNFH sliceprofileinstance build : "+TNFH_sliceProfileInstance) + //TNMH slice profile instance creation TNMH_sliceProfileInstance.setServiceInstanceId(TNMH_sliceProfileInstanceId) sliceInstanceName = "sliceprofile_"+TNMH_sliceProfileId @@ -227,7 +236,10 @@ public void createSliceProfilesInAai(DelegateExecution execution) { TNMH_sliceProfileInstance.setEnvironmentContext(snssai) TNMH_sliceProfileInstance.setWorkloadContext("TN-MH") TNMH_sliceProfileInstance.setSliceProfiles(TNMH_SliceProfiles) - logger.debug("completed TNMH sliceprofileinstance build "+TNMH_sliceProfileInstance) + String serviceFunctionTnMH = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "resourceSharingLevel") + TNMH_sliceProfileInstance.setServiceFunction(serviceFunctionTnMH) + logger.debug("completed TNMH sliceprofileinstance build : "+TNMH_sliceProfileInstance) + String msg = "" try { @@ -256,17 +268,15 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe Map<String,Object> profile switch(domainType) { case "AN-NF": - profile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)//pending fields - maxBandwidth, sST, pLMNIdList, cSReliabilityMeanTime, + profile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)//pending fields - maxBandwidth, sST, plmnIdList, cSReliabilityMeanTime, //msgSizeByte, maxNumberofPDUSessions,overallUserDensity,transferIntervalTarget result.setJitter(profile.get("jitter")) result.setLatency(profile.get("latency")) result.setResourceSharingLevel(profile.get("resourceSharingLevel")) - result.setSNssai(profile.get("sNSSAI")) result.setUeMobilityLevel(profile.get("uEMobilityLevel")) result.setMaxNumberOfUEs(profile.get("maxNumberofUEs")) result.setActivityFactor(profile.get("activityFactor")) result.setCoverageAreaTAList(profile.get("coverageAreaTAList")) - result.setCsAvailability(profile.get("cSAvailabilityTarget")) result.setExpDataRateDL(profile.get("expDataRateDL")) result.setExpDataRateUL(profile.get("expDataRateUL")) result.setSurvivalTime(profile.get("survivalTime")) @@ -276,19 +286,17 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe result.setProfileId(execution.getVariable("ANNF_sliceProfileId")) break case "TN-FH": - profile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class) //pending fields - maxBandwidth, sST, pLMNIdList + profile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class) //pending fields - maxBandwidth, sST, plmnIdList result.setJitter(profile.get("jitter")) result.setLatency(profile.get("latency")) result.setResourceSharingLevel(profile.get("resourceSharingLevel")) - result.setSNssai(profile.get("sNSSAI")) result.setProfileId(execution.getVariable("TNFH_sliceProfileId")) break case "TN-MH": - profile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class)//pending fields - maxBandwidth, sST, pLMNIdList + profile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class)//pending fields - maxBandwidth, sST, plmnIdList result.setJitter(profile.get("jitter")) result.setLatency(profile.get("latency")) result.setResourceSharingLevel(profile.get("resourceSharingLevel")) - result.setSNssai(profile.get("sNSSAI")) result.setProfileId(execution.getVariable("TNMH_sliceProfileId")) break default: @@ -307,13 +315,13 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe String msg AAIResourcesClient client = new AAIResourcesClient() try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(instanceId).relationshipAPI()) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(instanceId)).relationshipAPI() client.create(uri, relationship) } catch (BpmnError e) { throw e } catch (Exception ex) { - msg = "Exception in CreateCommunicationService.createRelationShipInAAI. " + ex.getMessage() + msg = "Exception in AN NSSMF Utils : CreateRelationShipInAAI. " + ex.getMessage() logger.info(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } @@ -333,18 +341,18 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe } public String buildCreateNSSMFRequest(DelegateExecution execution, String domainType, String action) { - EsrInfo esrInfo = new EsrInfo() - esrInfo.setNetworkType("TN") - esrInfo.setVendor("ONAP") - String esrInfoString = objectMapper.writeValueAsString(esrInfo) + JsonObject esrInfo = new JsonObject() + esrInfo.addProperty("networkType", "tn") + esrInfo.addProperty("vendor", "ONAP_internal") JsonObject response = new JsonObject() JsonObject allocateTnNssi = new JsonObject() JsonObject serviceInfo = new JsonObject() JsonArray transportSliceNetworksList = new JsonArray() JsonArray connectionLinksList = new JsonArray() JsonObject connectionLinks = new JsonObject() + Gson jsonConverter = new Gson() if(action.equals("allocate")){ - Map<String, String> endpoints + JsonObject endpoints = new JsonObject() if(domainType.equals("TN_FH")) { serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNFH_modelInvariantUuid")) serviceInfo.addProperty("serviceUuid", execution.getVariable("TNFH_modelUuid")) @@ -352,12 +360,10 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe allocateTnNssi.addProperty("nssiName", execution.getVariable("TNFH_modelName")) Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class) sliceProfile.put("sliceProfileId", execution.getVariable("TNFH_sliceProfileInstanceId")) - String sliceProfileString = objectMapper.writeValueAsString(sliceProfile) - allocateTnNssi.addProperty("sliceProfile", sliceProfileString) - endpoints.put("transportEndpointA", execution.getVariable("tranportEp_ID_RU")) - endpoints.put("transportEndpointB", execution.getVariable("tranportEp_ID_DUIN")) - String endpointsString = objectMapper.writeValueAsString(endpoints) - connectionLinksList.add(endpointsString) + allocateTnNssi.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile)) + endpoints.addProperty("transportEndpointA", execution.getVariable("tranportEp_ID_RU")) + endpoints.addProperty("transportEndpointB", execution.getVariable("tranportEp_ID_DUIN")) + connectionLinksList.add(endpoints) }else if(domainType.equals("TN_MH")) { serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNMH_modelInvariantUuid")) serviceInfo.addProperty("serviceUuid", execution.getVariable("TNMH_modelUuid")) @@ -365,46 +371,37 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe allocateTnNssi.addProperty("nssiName", execution.getVariable("TNMH_modelName")) Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class) sliceProfile.put("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId")) - String sliceProfileString = objectMapper.writeValueAsString(sliceProfile) - allocateTnNssi.addProperty("sliceProfile", sliceProfileString) - endpoints.put("transportEndpointA", execution.getVariable("tranportEp_ID_DUEG")) - endpoints.put("transportEndpointB", execution.getVariable("tranportEp_ID_CUIN")) - String endpointsString = objectMapper.writeValueAsString(endpoints) - connectionLinksList.add(endpointsString) + allocateTnNssi.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile)) + endpoints.addProperty("transportEndpointA", execution.getVariable("tranportEp_ID_DUEG")) + endpoints.addProperty("transportEndpointB", execution.getVariable("tranportEp_ID_CUIN")) + connectionLinksList.add(endpoints) } //Connection links connectionLinks.add("connectionLinks", connectionLinksList) transportSliceNetworksList.add(connectionLinks) allocateTnNssi.add("transportSliceNetworks", transportSliceNetworksList) - allocateTnNssi.addProperty("nssiId", null) - serviceInfo.addProperty("nssiId", null) }else if(action.equals("modify-allocate")) { if(domainType.equals("TN_FH")) { - serviceInfo.addProperty("serviceInvariantUuid", null) - serviceInfo.addProperty("serviceUuid", null) - allocateTnNssi.addProperty("nsstId", null) allocateTnNssi.addProperty("nssiName", execution.getVariable("TNFH_nssiName")) allocateTnNssi.addProperty("sliceProfileId", execution.getVariable("TNFH_sliceProfileInstanceId")) allocateTnNssi.addProperty("nssiId", execution.getVariable("TNFH_NSSI")) serviceInfo.addProperty("nssiId", execution.getVariable("TNFH_NSSI")) }else if(domainType.equals("TN_MH")) { - serviceInfo.addProperty("serviceInvariantUuid", null) - serviceInfo.addProperty("serviceUuid", null) - allocateTnNssi.addProperty("nsstId", null) allocateTnNssi.addProperty("nssiName", execution.getVariable("TNMH_nssiName")) allocateTnNssi.addProperty("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId")) allocateTnNssi.addProperty("nssiId", execution.getVariable("TNMH_NSSI")) serviceInfo.addProperty("nssiId", execution.getVariable("TNMH_NSSI")) } } + JsonParser parser = new JsonParser() String nsiInfo = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "nsiInfo") - allocateTnNssi.addProperty("nsiInfo", nsiInfo) + allocateTnNssi.add("nsiInfo",(JsonObject) parser.parse(nsiInfo)) allocateTnNssi.addProperty("scriptName", "TN1") serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId")) serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType")) - response.addProperty("esrInfo", esrInfoString) + response.add("esrInfo", esrInfo) response.add("serviceInfo", serviceInfo) response.add("allocateTnNssi", allocateTnNssi) return response.toString() @@ -429,9 +426,9 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe deAllocateNssi.addProperty("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId")) } - EsrInfo esrInfo = new EsrInfo() - esrInfo.setVendor("ONAP") - esrInfo.setNetworkType("TN") + JsonObject esrInfo = new JsonObject() + esrInfo.addProperty("networkType", "tn") + esrInfo.addProperty("vendor", "ONAP_internal") JsonObject serviceInfo = new JsonObject() serviceInfo.addProperty("serviceInvariantUuid", null) @@ -441,9 +438,9 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe JsonObject json = new JsonObject() json.add("deAllocateNssi", deAllocateNssi) - json.addProperty("esrInfo", objectMapper.writeValueAsString(esrInfo)) + json.add("esrInfo", esrInfo) json.add("serviceInfo", serviceInfo) return json.toString() } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy index 8cab146006..d00f349690 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy @@ -19,6 +19,7 @@ */ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.aaiclient.client.aai.entities.uri.AAISimpleUri import static org.apache.commons.lang3.StringUtils.isBlank import javax.ws.rs.NotFoundException @@ -215,11 +216,12 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { 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) +// 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("Authorization", encodeString) + httpClient.addAdditionalHeader("Authorization", basicAuth) httpClient.addAdditionalHeader("Accept", "application/json") Response httpResponse = httpClient.delete(requestBody) handleNSSMFWFResponse(httpResponse, execution) @@ -318,12 +320,12 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { CommunicationServiceProfile csProfile = csProfiles.getCommunicationServiceProfile().get(0) profileId = csProfile ? csProfile.getProfileId() : "" } - resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId).communicationServiceProfile(profileId)) - if (!getAAIClient().exists(resourceUri)) { + AAISimpleUri profileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId).communicationServiceProfile(profileId)) + if (!getAAIClient().exists(profileUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "communication service profile was not found in aai") } - getAAIClient().delete(resourceUri) + getAAIClient().delete(profileUri) LOGGER.debug("end delete communication service profile from AAI") } catch (any) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy index 4c008a2eb9..8c04675193 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy @@ -20,6 +20,8 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.aaiclient.client.aai.entities.uri.AAISimpleUri + import static org.apache.commons.lang3.StringUtils.isBlank import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.BpmnError @@ -176,11 +178,11 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { ServiceProfile serviceProfile = serviceProfiles.getServiceProfile().get(0) profileId = serviceProfile ? serviceProfile.getProfileId() : "" } - resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId).serviceProfile(profileId)) - if (!getAAIClient().exists(resourceUri)) { + AAISimpleUri profileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId).serviceProfile(profileId)) + if (!getAAIClient().exists(profileUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } - getAAIClient().delete(resourceUri) + getAAIClient().delete(profileUri) } catch (any) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy new file mode 100644 index 0000000000..3d9f67653b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy @@ -0,0 +1,273 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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 com.fasterxml.jackson.databind.ObjectMapper +import com.google.gson.Gson +import com.google.gson.reflect.TypeToken +import org.apache.commons.lang3.StringUtils +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.logging.filter.base.ErrorCode +import org.onap.so.beans.nsmf.* +import org.onap.so.beans.nsmf.oof.SubnetType +import org.onap.so.bpmn.common.scripts.* +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.ServiceArtifact +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.LoggingAnchor +import org.onap.so.logger.MessageEnum +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.springframework.web.util.UriUtils + +import java.lang.reflect.Type + +/** + * This class supports the DoCreateVnf building block subflow + * with the creation of a generic vnf for + * infrastructure. + * + */ +class DoActivateSliceService extends AbstractServiceTaskProcessor { + + private static final Logger logger = LoggerFactory.getLogger(DoActivateSliceService.class) + + private static final NSSMF_ACTIVATION_URL = "/api/rest/provMns/v1/NSS/%s/activation" + + private static final NSSMF_DEACTIVATION_URL = "/api/rest/provMns/v1/NSS/%s/deactivation" + + private static final NSSMF_QUERY_JOB_STATUS_URL = "/api/rest/provMns/v1/NSS/jobs/%s" + + String Prefix="DoCNSSMF_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + JsonUtils jsonUtil = new JsonUtils() + + ObjectMapper objectMapper = new ObjectMapper() + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) + + /** + * This method gets and validates the incoming + * request. + * + * @param - execution + * + */ + public void preProcessRequest(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + logger.debug("STARTED Do sendcommandtoNssmf PreProcessRequest Process") + + /*******************/ + try{ + Queue<NssInstance> nssInstances = execution.getVariable("nssInstances") as Queue<NssInstance> + NssInstance nssInstance = nssInstances.poll() + execution.setVariable("nssInstances", nssInstances) + execution.setVariable("nssInstance", nssInstance) + + logger.info("the end !!") + }catch(BpmnError b){ + logger.debug("Rethrowing MSOWorkflowException") + throw b + }catch(Exception e){ + logger.info("the end of catch !!") + logger.debug(" Error Occured in DoSendCommandToNSSMF PreProcessRequest method!" + e.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoSendCommandToNSSMF PreProcessRequest") + + } + logger.trace("COMPLETED DoSendCommandToNSSMF PreProcessRequest Process") + } + + void prepareCompose(DelegateExecution execution) { + NssInstance nssInstance = execution.getVariable("nssInstance") as NssInstance + execution.setVariable("nssInstanceId", nssInstance.nssiId) + String serviceModelInfo = """{ + "modelInvariantUuid":"${nssInstance.modelInvariantId}", + "modelUuid":"${nssInstance.modelVersionId}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + } + + /** + * get vendor Info + * @param execution + */ + void processDecomposition(DelegateExecution execution) { + logger.debug("***** processDecomposition *****") + + try { + ServiceDecomposition serviceDecomposition = + execution.getVariable("serviceDecomposition") as ServiceDecomposition + + String vendor = serviceDecomposition.getServiceRole() + CustomerInfo customerInfo = execution.getVariable("customerInfo") as CustomerInfo + NssInstance nssInstance = execution.getVariable("nssInstance") as NssInstance + String reqUrl + String actionType + if (OperationType.ACTIVATE == nssInstance.operationType) { + reqUrl = String.format(NSSMF_ACTIVATION_URL, nssInstance.snssai) + actionType = "activate" + } else { + reqUrl = String.format(NSSMF_DEACTIVATION_URL, nssInstance.snssai) + actionType = "deactivate" + } + execution.setVariable("reqUrl", reqUrl) + + NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest() + + EsrInfo esrInfo = new EsrInfo() + esrInfo.setVendor(vendor) + esrInfo.setNetworkType(nssInstance.networkType) + + ServiceInfo serviceInfo = ServiceInfo.builder() + .nssiId(nssInstance.nssiId) + .subscriptionServiceType(customerInfo.subscriptionServiceType) + .globalSubscriberId(customerInfo.globalSubscriberId) + .nsiId(customerInfo.nsiId) + .serviceInvariantUuid(nssInstance.modelInvariantId) + .serviceUuid(nssInstance.modelVersionId) + .serviceType(nssInstance.serviceType) + .actionType(actionType) + .build() + + ActDeActNssi actDeActNssi = new ActDeActNssi() + actDeActNssi.setNsiId(customerInfo.nsiId) + actDeActNssi.setNssiId(nssInstance.nssiId) + + nbiRequest.setEsrInfo(esrInfo) + nbiRequest.setServiceInfo(serviceInfo) + nbiRequest.setActDeActNssi(actDeActNssi) + execution.setVariable("nbiRequest", nbiRequest) + execution.setVariable("esrInfo", esrInfo) + execution.setVariable("serviceInfo", serviceInfo) + + } catch (any) { + String exceptionMessage = "Bpmn error encountered in deallocate nssi. processDecomposition() - " + any.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + logger.debug("***** Exit processDecomposition *****") + } + + /** + * send Create Request NSSMF + * @param execution + */ + void sendCreateRequestNSSMF(DelegateExecution execution) { + NssmfAdapterNBIRequest nbiRequest = execution.getVariable("nbiRequest") as NssmfAdapterNBIRequest + String nssmfRequest = objectMapper.writeValueAsString(nbiRequest) + logger.debug("sendCreateRequestNSSMF: " + nssmfRequest) + + String reqUrl = execution.getVariable("reqUrl") + String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, reqUrl, nssmfRequest) + + if (response != null) { + NssiResponse nssiResponse = objectMapper.readValue(response, NssiResponse.class) + execution.setVariable("nssiAllocateResult", nssiResponse) + } + //todo: error + } + + /** + * query nssi allocate status + * @param execution + */ + void queryNSSIStatus(DelegateExecution execution) { + NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest() + EsrInfo esrInfo = execution.getVariable("esrInfo") as EsrInfo + ServiceInfo serviceInfo = execution.getVariable("serviceInfo") as ServiceInfo + nbiRequest.setEsrInfo(esrInfo) + nbiRequest.setServiceInfo(serviceInfo) + + NssiResponse nssiAllocateResult = execution.getVariable("nssiAllocateResult") as NssiResponse + String jobId = nssiAllocateResult.getJobId() + + String endpoint = String.format(NSSMF_QUERY_JOB_STATUS_URL, jobId) + + String response = + nssmfAdapterUtils.sendPostRequestNSSMF(execution, endpoint, objectMapper.writeValueAsString(nbiRequest)) + + logger.debug("nssmf response nssiAllocateStatus:" + response) + + if (response != null) { + JobStatusResponse jobStatusResponse = objectMapper.readValue(response, JobStatusResponse.class) + + execution.setVariable("nssiAllocateStatus", jobStatusResponse) + if (jobStatusResponse.getResponseDescriptor().getProgress() == 100) { + execution.setVariable("jobFinished", true) + } + } + } + + void timeDelay(DelegateExecution execution) { + logger.trace("Enter timeDelay in DoAllocateNSSI()") + try { + Thread.sleep(60000) + + int currentCycle = execution.hasVariable("currentCycle") ? + execution.getVariable("currentCycle") as Integer : 1 + + currentCycle = currentCycle + 1 + if(currentCycle > 60) + { + logger.trace("Completed all the retry times... but still nssmf havent completed the creation process...") + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "NSSMF creation didnt complete by time...") + } + execution.setVariable("currentCycle", currentCycle) + } catch(InterruptedException e) { + logger.info("Time Delay exception" + e) + } + logger.trace("Exit timeDelay in DoAllocateNSSI()") + } + + void sendSyncError (DelegateExecution execution) { + logger.trace("start sendSyncError") + try { + String errorMessage = "" + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + WorkflowException wfe = execution.getVariable("WorkflowException") + errorMessage = wfe.getErrorMessage() + } else { + errorMessage = "Sending Sync Error." + } + + String buildworkflowException = + """<aetgt:WorkflowException xmlns:aetgt="http://org.onap/so/workflow/schema/v1"> + <aetgt:ErrorMessage>${MsoUtils.xmlEscape(errorMessage)}</aetgt:ErrorMessage> + <aetgt:ErrorCode>7000</aetgt:ErrorCode> + </aetgt:WorkflowException>""" + + logger.debug(buildworkflowException) + sendWorkflowResponse(execution, 500, buildworkflowException) + + } catch (Exception ex) { + logger.debug("Sending Sync Error Activity Failed. " + "\n" + ex.getMessage()) + } + logger.trace("finished sendSyncError") + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy index 05996d3671..ff7b0a3b6d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy @@ -83,6 +83,7 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor { String actionType = operationType.equals("activateInstance") ? "activate" : "deactivate" execution.setVariable("actionType", actionType) + tnNssmfUtils.setEnableSdncConfig(execution) logger.debug("Finish preProcessRequest") } @@ -116,6 +117,19 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor { } + String getOrchStatusBasedOnActionType(String actionType) { + String res = "unknown" + if (actionType.equals("activate")) { + res = "activated" + } else if (actionType.equals("deactivate")) { + res = "deactivated" + } else { + logger.error("ERROR: getOrchStatusBasedOnActionType bad actionType= \n" + actionType) + } + + return res + } + void updateAAIOrchStatus(DelegateExecution execution) { logger.debug("Start updateAAIOrchStatus") String tnNssiId = execution.getVariable("sliceServiceInstanceId") @@ -142,20 +156,17 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor { String status, String progress, String statusDescription) { - String serviceId = execution.getVariable("sliceServiceInstanceId") + String ssInstanceId = execution.getVariable("sliceServiceInstanceId") + String modelUuid = execution.getVariable("modelUuid") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") String operType = execution.getVariable("actionType") + operType = operType.toUpperCase() + + ResourceOperationStatus roStatus = tnNssmfUtils.buildRoStatus(modelUuid, ssInstanceId, + jobId, nsiId, operType, status, progress, statusDescription) - ResourceOperationStatus roStatus = new ResourceOperationStatus() - roStatus.setServiceId(serviceId) - roStatus.setOperationId(jobId) - roStatus.setResourceTemplateUUID(nsiId) - roStatus.setOperType(operType) - roStatus.setProgress(progress) - roStatus.setStatus(status) - roStatus.setStatusDescription(statusDescription) requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy index fc14da3a7d..33724bd011 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy @@ -31,17 +31,17 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.db.request.beans.ResourceOperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory -import java.sql.Timestamp import java.util.List import static org.apache.commons.lang3.StringUtils.isBlank import com.google.gson.JsonObject +import com.google.gson.Gson import com.fasterxml.jackson.databind.ObjectMapper import com.google.gson.JsonArray +import com.google.gson.JsonParser import org.onap.aai.domain.yang.Relationship import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.so.beans.nsmf.AllocateTnNssi -import org.onap.so.beans.nsmf.EsrInfo import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.ServiceInstance @@ -185,7 +185,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { List<String> nsstInfoList = new ArrayList<>() for(ServiceProxy serviceProxy : serviceProxyList) { - String nsstModelUuid = serviceProxy.getModelInfo().getModelUuid() + String nsstModelUuid = serviceProxy.getSourceModelUuid() String nsstModelInvariantUuid = serviceProxy.getModelInfo().getModelInvariantUuid() String name = serviceProxy.getModelInfo().getModelName() String nsstServiceModelInfo = """{ @@ -203,7 +203,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { logger.info(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - execution.setVariable("ranNsstInfoList",nsstInfoList) + execution.setVariable("ranNsstInfoList", objectMapper.writeValueAsString(nsstInfoList)) execution.setVariable("ranModelVersion", ranModelVersion) execution.setVariable("ranModelName", ranModelName) execution.setVariable("currentIndex",currentIndex) @@ -255,7 +255,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) logger.debug( "get NSSI option OOF Url: " + urlString) - + JsonParser parser = new JsonParser() //build oof request body boolean ranNssiPreferReuse = execution.getVariable("ranNssiPreferReuse"); String requestId = execution.getVariable("msoRequestId") @@ -265,7 +265,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelName = execution.getVariable("ranModelName") String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); - List<String> nsstInfoList = objectMapper.readValue(execution.getVariable("nsstInfoList"), List.class) + List<String> nsstInfoList = objectMapper.readValue(execution.getVariable("ranNsstInfoList"), List.class) JsonArray capabilitiesList = new JsonArray() String FHCapabilities = execution.getVariable("FHCapabilities") String MHCapabilities = execution.getVariable("MHCapabilities") @@ -274,11 +274,11 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { JsonObject MH = new JsonObject() JsonObject ANNF = new JsonObject() FH.addProperty("domainType", "TN_FH") - FH.addProperty("capabilityDetails", FHCapabilities) + FH.add("capabilityDetails", (JsonObject) parser.parse(FHCapabilities)) MH.addProperty("domainType", "TN_MH") - MH.addProperty("capabilityDetails", MHCapabilities) + MH.add("capabilityDetails", (JsonObject) parser.parse(MHCapabilities)) ANNF.addProperty("domainType", "AN_NF") - ANNF.addProperty("capabilityDetails", FHCapabilities) + ANNF.add("capabilityDetails", (JsonObject) parser.parse(ANNFCapabilities)) capabilitiesList.add(FH) capabilitiesList.add(MH) capabilitiesList.add(ANNF) @@ -302,13 +302,18 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String oofResponse = execution.getVariable("nssiSelection_asyncCallbackResponse") String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus") if(requestStatus.equals("completed")) { - List<String> solution = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(oofResponse, "solutions")) - boolean existingNSI = jsonUtil.getJsonValue(solution.get(0), "existingNSI") + String solutions = jsonUtil.getJsonValue(oofResponse, "solutions") + logger.debug("solutions value : "+solutions) + JsonParser parser = new JsonParser() + JsonArray solution = parser.parse(solutions) + JsonObject sol = solution.get(0) + boolean existingNSI = sol.get("existingNSI").getAsBoolean() + logger.debug("existingNSI value : "+existingNSI) if(existingNSI) { - def sharedNSISolution = jsonUtil.getJsonValue(solution.get(0), "sharedNSISolution") - execution.setVariable("sharedRanNSSISolution", sharedNSISolution) + JsonObject sharedNSISolution = sol.get("sharedNSISolution").getAsJsonObject() + execution.setVariable("sharedRanNSSISolution", sharedNSISolution.toString()) logger.debug("sharedRanNSSISolution from OOF "+sharedNSISolution) - String RANServiceInstanceId = jsonUtil.getJsonValue(solution.get(0), "sharedNSISolution.NSIId") + String RANServiceInstanceId = sharedNSISolution.get("NSIId").getAsString() execution.setVariable("RANServiceInstanceId", RANServiceInstanceId) ServiceInstance serviceInstance = new ServiceInstance(); serviceInstance.setInstanceId(RANServiceInstanceId); @@ -317,9 +322,10 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { execution.setVariable("ranNsstServiceDecomposition", serviceDecomposition) execution.setVariable("isRspRanNssi", true) }else { - def sliceProfiles = jsonUtil.getJsonValue(solution.get(0), "newNSISolution.sliceProfiles") - execution.setVariable("RanConstituentSliceProfiles", sliceProfiles) + JsonObject newNSISolution = sol.get("newNSISolution").getAsJsonObject() + JsonArray sliceProfiles = newNSISolution.get("slice_profiles").getAsJsonArray() logger.debug("RanConstituentSliceProfiles list from OOF "+sliceProfiles) + execution.setVariable("RanConstituentSliceProfiles", sliceProfiles.toString()) } }else { String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage") @@ -362,11 +368,11 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { def createModifyNssiQueryJobStatus = { DelegateExecution execution -> logger.debug(Prefix+"createModifyNssiQueryJobStatus method start") - EsrInfo esrInfo = new EsrInfo() - esrInfo.setNetworkType("AN") - esrInfo.setVendor("ONAP") - String esrInfoString = objectMapper.writeValueAsString(esrInfo) - execution.setVariable("esrInfo", esrInfoString) + JsonObject esrInfo = new JsonObject() + esrInfo.addProperty("networkType", "tn") + esrInfo.addProperty("vendor", "ONAP_internal") + + execution.setVariable("esrInfo", esrInfo.toString()) JsonObject serviceInfo = new JsonObject() serviceInfo.addProperty("nssiId", execution.getVariable("RANServiceInstanceId")) serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) @@ -491,12 +497,16 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String oofResponse = execution.getVariable("nfNssiSelection_asyncCallbackResponse") String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus") if(requestStatus.equals("completed")) { - List<String> solution = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(oofResponse, "solutions")) + String solutions = jsonUtil.getJsonValue(oofResponse, "solutions") + logger.debug("nssi solutions value : "+solutions) + JsonParser parser = new JsonParser() + JsonArray solution = parser.parse(solutions) if(solution.size()>=1) { - String ranNfNssiId = jsonUtil.getJsonValue(solution.get(0), "NSSIId") - String invariantUuid = jsonUtil.getJsonValue(solution.get(0), "invariantUUID") - String uuid = jsonUtil.getJsonValue(solution.get(0), "UUID") - String nssiName = jsonUtil.getJsonValue(solution.get(0), "NSSIName") + JsonObject sol = solution.get(0) + String ranNfNssiId = sol.get("NSSIId").getAsString() + String invariantUuid = sol.get("invariantUUID").getAsString() + String uuid = sol.get("UUID").getAsString() + String nssiName = sol.get("NSSIName").getAsString() execution.setVariable("RANNFServiceInstanceId", ranNfNssiId) execution.setVariable("RANNFInvariantUUID", invariantUuid) execution.setVariable("RANNFUUID", uuid) @@ -528,7 +538,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug(Prefix+"processRanNfModifyRsp method start") anNssmfUtils.processRanNfModifyRsp(execution) //create RAN NSSI - org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new ServiceInstance(); + org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new org.onap.aai.domain.yang.ServiceInstance(); //AN instance creation ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId")) String sliceInstanceName = execution.getVariable("servicename") @@ -568,7 +578,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { def createSdnrRequest = { DelegateExecution execution -> logger.debug(Prefix+"createSdnrRequest method start") String callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.message.endpoint") + "/AsyncSdnrResponse/"+execution.getVariable("msoRequestId") - String sdnrRequest = buildSdnrAllocateRequest(execution, "allocate", "InstantiateRANSlice", callbackUrl) + String sdnrRequest = buildSdnrAllocateRequest(execution, "allocate", "instantiateRANSlice", callbackUrl) execution.setVariable("createNSSI_sdnrRequest", sdnrRequest) execution.setVariable("createNSSI_timeout", "PT10M") execution.setVariable("createNSSI_correlator", execution.getVariable("msoRequestId")) @@ -593,8 +603,8 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { def updateAaiWithRANInstances = { DelegateExecution execution -> logger.debug(Prefix+"updateAaiWithRANInstances method start") //create RAN NSSI - org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new ServiceInstance(); - org.onap.aai.domain.yang.ServiceInstance ANNFServiceInstance = new ServiceInstance(); + org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new org.onap.aai.domain.yang.ServiceInstance(); + org.onap.aai.domain.yang.ServiceInstance ANNFServiceInstance = new org.onap.aai.domain.yang.ServiceInstance(); //AN instance creation ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId")) String sliceInstanceName = execution.getVariable("servicename") @@ -603,15 +613,16 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { ANServiceInstance.setServiceType(serviceType) String serviceStatus = "deactivated" ANServiceInstance.setOrchestrationStatus(serviceStatus) - String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "plmnIdList") + String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "pLMNIdList") ANServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid) String serviceRole = "nssi" ANServiceInstance.setServiceRole(serviceRole) - List<String> snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class) + List<String> snssaiList = execution.getVariable("snssaiList") String snssai = snssaiList.get(0) ANServiceInstance.setEnvironmentContext(snssai) ANServiceInstance.setWorkloadContext("AN") - + String serviceFunctionAn = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "resourceSharingLevel") + ANServiceInstance.setServiceFunction(serviceFunctionAn) logger.debug("completed AN service instance build "+ ANServiceInstance.toString()) //create RAN NF NSSI ANNFServiceInstance.setServiceInstanceId(execution.getVariable("RANNFServiceInstanceId")) @@ -619,13 +630,15 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { ANNFServiceInstance.setServiceInstanceName(sliceInstanceName) ANNFServiceInstance.setServiceType(serviceType) ANNFServiceInstance.setOrchestrationStatus(serviceStatus) - serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "plmnIdList") + serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "pLMNIdList") ANNFServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid) ANNFServiceInstance.setServiceRole(serviceRole) - snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class) + snssaiList = execution.getVariable("snssaiList") snssai = snssaiList.get(0) ANNFServiceInstance.setEnvironmentContext(snssai) ANNFServiceInstance.setWorkloadContext("AN-NF") + String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "resourceSharingLevel") + ANNFServiceInstance.setServiceFunction(serviceFunctionAnnf) logger.debug("completed AN service instance build "+ ANNFServiceInstance.toString()) String msg = "" @@ -685,23 +698,21 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { } def createFhAllocateNssiJobQuery = { DelegateExecution execution -> - logger.debug(Prefix+"createModifyNssiQueryJobStatus method start") + logger.debug(Prefix+"createFhAllocateNssiJobQuery method start") createTnAllocateNssiJobQuery(execution, "TN_FH") } def createMhAllocateNssiJobQuery = { DelegateExecution execution -> - logger.debug(Prefix+"createModifyNssiQueryJobStatus method start") + logger.debug(Prefix+"createMhAllocateNssiJobQuery method start") createTnAllocateNssiJobQuery(execution, "TN_MH") } private void createTnAllocateNssiJobQuery(DelegateExecution execution, String domainType) { - EsrInfo esrInfo = new EsrInfo() - esrInfo.setNetworkType("TN") - esrInfo.setVendor("ONAP") - String esrInfoString = objectMapper.writeValueAsString(esrInfo) - execution.setVariable("esrInfo", esrInfoString) + JsonObject esrInfo = new JsonObject() + esrInfo.addProperty("networkType", "tn") + esrInfo.addProperty("vendor", "ONAP_internal") + execution.setVariable("esrInfo", esrInfo.toString()) JsonObject serviceInfo = new JsonObject() - serviceInfo.addProperty("nssiId", null) serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) String sST = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST") serviceInfo.addProperty("sST", sST) @@ -725,14 +736,14 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug(Prefix+"processJobStatusRsp method start") String jobResponse = execution.getVariable("TNFH_jobResponse") logger.debug("Job status response "+jobResponse) - String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status") - String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi") + String status = jsonUtil.getJsonValue(jobResponse, "status") + String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId") if(status.equalsIgnoreCase("finished")) { execution.setVariable("TNFH_NSSI", nssi) logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi) } else { - String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription") + String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription") logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) } @@ -742,14 +753,14 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug(Prefix+"processJobStatusRsp method start") String jobResponse = execution.getVariable("TNMH_jobResponse") logger.debug("Job status response "+jobResponse) - String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status") - String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi") + String status = jsonUtil.getJsonValue(jobResponse, "status") + String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId") if(status.equalsIgnoreCase("finished")) { execution.setVariable("TNMH_NSSI", nssi) logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi) } else { - String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription") + String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription") logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) } @@ -759,13 +770,13 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug(Prefix+"processJobStatusRsp method start") String jobResponse = execution.getVariable("jobResponse") logger.debug("Job status response "+jobResponse) - String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status") - String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi") + String status = jsonUtil.getJsonValue(jobResponse, "status") + String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId") if(status.equalsIgnoreCase("finished")) { logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi) } else { - String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription") + String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription") logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) } @@ -853,7 +864,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { updateStatus.setResourceTemplateUUID(nsiId) updateStatus.setResourceInstanceID(nssiId) updateStatus.setOperType("Allocate") - updateStatus.setProgress(100) + updateStatus.setProgress("100") updateStatus.setStatus("finished") requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus) @@ -875,7 +886,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { updateStatus.setResourceTemplateUUID(nsiId) updateStatus.setResourceInstanceID(nssiId) updateStatus.setOperType("Allocate") - updateStatus.setProgress(0) + updateStatus.setProgress("0") updateStatus.setStatus("failed") requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus) } @@ -883,41 +894,40 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { private String buildSdnrAllocateRequest(DelegateExecution execution, String action, String rpcName, String callbackUrl) { String requestId = execution.getVariable("msoRequestId") - Date date = new Date().getTime() - Timestamp time = new Timestamp(date) Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class) sliceProfile.put("sliceProfileId", execution.getVariable("ANNF_sliceProfileInstanceId")) sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSessions")) sliceProfile.put("uLThptPerSlice", sliceProfile.get("expDataRateUL")) sliceProfile.put("dLThptPerSlice", sliceProfile.get("expDataRateDL")) - String sliceProfileString = objectMapper.writeValueAsString(sliceProfile) + JsonObject response = new JsonObject() JsonObject body = new JsonObject() JsonObject input = new JsonObject() JsonObject commonHeader = new JsonObject() JsonObject payload = new JsonObject() JsonObject payloadInput = new JsonObject() - commonHeader.addProperty("TimeStamp", time.toString()) - commonHeader.addProperty("APIver", "1.0") - commonHeader.addProperty("RequestID", requestId) - commonHeader.addProperty("SubRequestID", "1") - commonHeader.add("RequestTrack", new JsonObject()) - commonHeader.add("Flags", new JsonObject()) - payloadInput.addProperty("sliceProfile", sliceProfileString) + commonHeader.addProperty("TimeStamp",new Date(System.currentTimeMillis()).format("yyyy-MM-dd'T'HH:mm:ss.sss'Z'", TimeZone.getDefault())) + commonHeader.addProperty("api-ver", "1.0") + commonHeader.addProperty("request-id", requestId) + commonHeader.addProperty("sub-request-id", "1") + commonHeader.add("request-track", new JsonObject()) + commonHeader.add("flags", new JsonObject()) + Gson jsonConverter = new Gson() + payloadInput.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile)) payloadInput.addProperty("RANNSSIId", execution.getVariable("RANServiceInstanceId")) payloadInput.addProperty("NSIID", execution.getVariable("nsiId")) payloadInput.addProperty("RANNFNSSIId", execution.getVariable("RANNFServiceInstanceId")) payloadInput.addProperty("callbackURL", callbackUrl) payloadInput.add("additionalproperties", new JsonObject()) payload.add("input", payloadInput) - input.add("CommonHeader", commonHeader) - input.addProperty("Action", action) - input.add("Payload", payload) + input.add("common-header", commonHeader) + input.addProperty("action", action) + input.addProperty("payload", payload.toString()) body.add("input", input) response.add("body", body) response.addProperty("version", "1.0") response.addProperty("rpc-name", rpcName) - response.addProperty("correlation-id", requestId+"-1") + response.addProperty("correlation-id", (requestId+"-1")) response.addProperty("type", "request") return response.toString() } @@ -979,8 +989,15 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String DUEG_routeId = UUID.randomUUID().toString() execution.setVariable("tranportEp_ID_DUEG", DUEG_routeId) NetworkRoute DUEG_ep = new NetworkRoute() - DU_ep.setRouteId(DUEG_routeId) - DU_ep.setNextHop("Host3") + DUEG_ep.setRouteId(DUEG_routeId) + DUEG_ep.setFunction(function) + DUEG_ep.setRole(role) + DUEG_ep.setType(type) + DUEG_ep.setIpAddress("192.168.100.5") + DUEG_ep.setLogicalInterfaceId("1234") + DUEG_ep.setPrefixLength(prefixLength) + DUEG_ep.setAddressFamily(addressFamily) + DUEG_ep.setNextHop("Host3") //CUIN String CUIN_routeId = UUID.randomUUID().toString() execution.setVariable("tranportEp_ID_CUIN", CUIN_routeId) @@ -1005,9 +1022,9 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug("creating DUIN endpoint . ID : "+DUIN_routeId+" node details : "+DU_ep.toString()) networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUIN_routeId) client.create(networkRouteUri, DU_ep) - logger.debug("creating DUEG endpoint . ID : "+DUEG_routeId+" node details : "+DU_ep.toString()) + logger.debug("creating DUEG endpoint . ID : "+DUEG_routeId+" node details : "+DUEG_ep.toString()) networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUEG_routeId) - client.create(networkRouteUri, DU_ep) + client.create(networkRouteUri, DUEG_ep) logger.debug("creating CUIN endpoint . ID : "+CUIN_routeId+" node details : "+CUIN_ep.toString()) networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), CUIN_routeId) client.create(networkRouteUri, CUIN_ep) @@ -1041,3 +1058,4 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { } } } + diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy index 64c36e7026..01aefe2054 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy @@ -68,10 +68,7 @@ class DoAllocateCoreNSSI extends AbstractServiceTaskProcessor { execution.setVariable("coreServiceInstanceId", coreServiceInstanceId) logger.debug(Prefix+" **** Exit DoAllocateCoreNSSI ::: preProcessRequest ****") } - /** - * Query NSST name from CatalogDB - * @param execution - */ + void getNSSTName(DelegateExecution execution){ logger.debug(Prefix+" **** Enter DoAllocateCoreNSSI ::: getNSSTName ****") String nsstModelInvariantUuid = execution.getVariable("modelInvariantUuid") @@ -79,8 +76,8 @@ class DoAllocateCoreNSSI extends AbstractServiceTaskProcessor { String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution, nsstModelInvariantUuid) logger.debug("***** JSON Response is: "+json) String nsstName = jsonUtil.getJsonValue(json, "serviceResources.modelInfo.modelName") ?: "" - String networkServiceModelInfo = jsonUtil.getJsonValue(json, "serviceResources.serviceProxy.modelInfo") ?: "" - + List serviceProxyList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(json, "serviceResources.serviceProxy")) + String networkServiceModelInfo = serviceProxyList.get(0) execution.setVariable("networkServiceModelInfo", networkServiceModelInfo) logger.debug("***** nsstName is: "+ nsstName) execution.setVariable("nsstName",nsstName) @@ -93,6 +90,7 @@ class DoAllocateCoreNSSI extends AbstractServiceTaskProcessor { } logger.debug(Prefix+" **** Exit DoAllocateCoreNSSI ::: getNSSTName ****") } + void prepareOOFRequest(DelegateExecution execution){ logger.debug(Prefix+" **** Enter DoAllocateCoreNSSI ::: prepareOOFRequest ****") //API Path @@ -105,8 +103,6 @@ class DoAllocateCoreNSSI extends AbstractServiceTaskProcessor { //Setting messageType for all Core slice as cn String messageType = "cn" execution.setVariable("NSSI_messageType", messageType) - //Is there any specific timeout we have to set or else we don't need to send - //if blank will be set default value in DoHandleOofRequest String timeout = "PT30M" execution.setVariable("NSSI_timeout", timeout) Map<String, Object> profileInfo = mapper.readValue(execution.getVariable("sliceProfile"), Map.class) @@ -127,7 +123,10 @@ class DoAllocateCoreNSSI extends AbstractServiceTaskProcessor { execution.setVariable("OOFResponse", OOFResponse) String solutions ="" if(requestStatus.equals("completed")) { - solutions = jsonUtil.getJsonValue(OOFResponse, "solutions") + List solutionsList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(OOFResponse, "solutions")) + if(solutionsList!=null && !solutionsList.isEmpty() ) { + solutions = solutionsList.get(0) + } } else { String statusMessage = jsonUtil.getJsonValue(OOFResponse, "statusMessage") logger.error("received failed status from oof "+ statusMessage) @@ -139,16 +138,20 @@ class DoAllocateCoreNSSI extends AbstractServiceTaskProcessor { void prepareFailedOperationStatusUpdate(DelegateExecution execution){ logger.debug(Prefix + " **** Enter DoAllocateCoreNSSI ::: prepareFailedOperationStatusUpdate ****") - 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") + String nssiId = execution.getVariable("nssiId") + String operationType = "ALLOCATE" + logger.debug("serviceId: "+serviceId+" jobId: "+jobId+" nsiId: "+nsiId+" operationType: "+operationType) + String modelUuid= execution.getVariable("modelUuid") ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setJobId(jobId) resourceOperationStatus.setOperationId(jobId) - resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setResourceTemplateUUID(modelUuid) resourceOperationStatus.setOperType(operationType) - resourceOperationStatus.setProgress(0) + resourceOperationStatus.setProgress("0") resourceOperationStatus.setStatus("failed") resourceOperationStatus.setStatusDescription("Core NSSI Allocate Failed") requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) 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 c5a928aaf9..91599700ef 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 @@ -64,6 +64,8 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.http.HttpEntity +import org.onap.aai.domain.yang.NetworkPolicy +import org.onap.aaiclient.client.aai.AAINamespaceConstants import javax.ws.rs.NotFoundException @@ -79,24 +81,26 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { public void preProcessRequest(DelegateExecution execution) { logger.debug(Prefix+ "**** Enter DoAllocateCoreNonSharedSlice::: preProcessRequest ****") String nssiServiceInstanceId= execution.getVariable("serviceInstanceId") + logger.debug("nssiServiceInstanceId: "+nssiServiceInstanceId) execution.setVariable("nssiServiceInstanceId", nssiServiceInstanceId) //Set orchestration-status as created execution.setVariable("orchestrationStatus", "created") //networkServiceName - String networkServiceName = jsonUtil.getJsonValue(execution.getVariable("networkServiceModelInfo"), "modelName") ?: "" + String networkServiceName = jsonUtil.getJsonValue(execution.getVariable("networkServiceModelInfo"), "modelInfo.modelName") ?: "" execution.setVariable("networkServiceName", networkServiceName.replaceAll(" Service Proxy", "")) //networkServiceModelUuid - String networkServiceModelUuid = jsonUtil.getJsonValue(execution.getVariable("networkServiceModelInfo"), "modelUuid") ?: "" + logger.debug("networkServiceName: "+networkServiceName) + String networkServiceModelUuid = jsonUtil.getJsonValue(execution.getVariable("networkServiceModelInfo"), "sourceModelUuid") ?: "" execution.setVariable("networkServiceModelUuid", networkServiceModelUuid) - String sliceParams = execution.getVariable("sliceParams") - logger.debug("sliceParams "+sliceParams) - List<String> bhEndPoints = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceParams, "endPoints")) - 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)) - } + String sliceParams = execution.getVariable("sliceParams") + logger.debug("sliceParams "+sliceParams) + List<String> bhEndPoints = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceParams, "endPoints")) + 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)) + } logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice::: preProcessRequest ****") } @@ -139,10 +143,8 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { si.setWorkloadContext(workloadContext) logger.debug("AAI service Instance Request Payload : "+si.toString()) AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)) - Response response = getAAIClient().create(uri, si) - if(response.getStatus()!=200) { - exceptionUtil.buildAndThrowWorkflowException(execution, response.getStatus(), "AAI instance creation failed") - } + getAAIClient().create(uri, si) + execution.setVariable("nssiServiceInstance", si) } catch (BpmnError e) { throw e; @@ -151,12 +153,14 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { logger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } + getVnfInstanceName(execution) logger.debug(Prefix+ " Exit DoAllocateCoreNonSharedSlice ::: Enter createNSSIinAAI ****") } public void prepareServiceOrderRequest(DelegateExecution execution) { logger.debug("**** Enter DoAllocateCoreNonSharedSlice ::: prepareServiceOrderRequest ****") - String extAPIPath = UrnPropertiesReader.getVariable("extapi.endpoint", execution) + '/serviceOrder' + //extAPI path hardcoded for testing purposes, will be updated in next patch + String extAPIPath = "https://nbi.onap:8443/nbi/api/v4" + "/serviceOrder" execution.setVariable("ExternalAPIURL", extAPIPath) ObjectMapper objectMapper = new ObjectMapper(); Map<String, Object> serviceOrder = new LinkedHashMap() @@ -186,10 +190,10 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { // service Details Map<String, Object> service = new LinkedHashMap() //ServiceName - String serviceName= "nsi_"+execution.getVariable("networkServiceName") + String serviceName= "ns_"+execution.getVariable("networkServiceName")+"_"+execution.getVariable("serviceInstanceId") service.put("name", serviceName) // Service Type - service.put("serviceType", execution.getVariable("serviceType")) + service.put("serviceType", execution.getVariable("subscriptionServiceType")) //Service State service.put("serviceState", "active") Map<String, String> serviceSpecification = new LinkedHashMap() @@ -198,7 +202,7 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { //serviceCharacteristic List List serviceCharacteristicList = new ArrayList() Map<String, Object> serviceCharacteristic = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class); - List serviceCharacteristicListMap = retrieveServiceCharacteristicsAsKeyValue(serviceCharacteristic) + List serviceCharacteristicListMap = retrieveServiceCharacteristicsAsKeyValue(execution, serviceCharacteristic) logger.debug("serviceCharacteristicListMap "+serviceCharacteristicListMap) serviceCharacteristicList.add(serviceCharacteristic) //service.put("serviceCharacteristic", serviceCharacteristicList) @@ -213,10 +217,23 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: prepareServiceOrderRequest****") } - private List retrieveServiceCharacteristicsAsKeyValue(Map serviceCharacteristics) { + private void getVnfInstanceName(DelegateExecution execution) { + //Get NetworkService modelInvariantUuid + String networkServiceModelUuid = execution.getVariable("networkServiceModelUuid") + String json = catalogDbUtils.getServiceResourcesByServiceModelUuid(execution, networkServiceModelUuid, "v2") + logger.debug("json returned: "+json) + 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() ?: "" + execution.setVariable("vnfInstanceName", vnfInstanceName) + } + + private List retrieveServiceCharacteristicsAsKeyValue(DelegateExecution execution, Map serviceCharacteristics) { logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: retrieveServiceCharacteristicsAsKeyValue ****") List serviceCharacteristicsList = new ArrayList() ObjectMapper mapperObj = new ObjectMapper(); + String vnfInstanceName = execution.getVariable("vnfInstanceName") Map<String, Object> serviceCharacteristicsObject = new LinkedHashMap() for (Map.Entry<String, Integer> entry : serviceCharacteristics.entrySet()) { Map<String, Object> ServiceCharacteristicValueObject = new LinkedHashMap<>() @@ -224,7 +241,7 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { //For G Release we are sending single value from snssaiList if(entry.getKey().equals("snssaiList")) { List sNssaiValue = entry.getValue() - serviceCharacteristicsObject.put("name", "snssai") + serviceCharacteristicsObject.put("name", vnfInstanceName+"_snssai") ServiceCharacteristicValueObject.put("serviceCharacteristicValue", sNssaiValue.get(0)) serviceCharacteristicsObject.put("value", ServiceCharacteristicValueObject) } @@ -303,18 +320,12 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { JSONObject item = items.get(0) JSONObject service = item.get("service") String networkServiceId = service.get("id") - if (networkServiceId == null || networkServiceId.equals("null")) { - prepareFailedOperationStatusUpdate(execution) - return - } + execution.setVariable("networkServiceId", networkServiceId) String serviceOrderState = item.get("state") execution.setVariable("ServiceOrderState", serviceOrderState) // Get serviceOrder State and process progress - if("ACKNOWLEDGED".equalsIgnoreCase(serviceOrderState)) { - execution.setVariable("status", "processing") - } - else if("INPROGRESS".equalsIgnoreCase(serviceOrderState)) { + if("ACKNOWLEDGED".equalsIgnoreCase(serviceOrderState) || "INPROGRESS".equalsIgnoreCase(serviceOrderState)) { execution.setVariable("status", "processing") } else if("COMPLETED".equalsIgnoreCase(serviceOrderState)) { @@ -328,6 +339,7 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { msg = "ServiceOrder failed" exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } + logger.debug("NBI serviceOrder state: "+serviceOrderState) } else{ msg = "Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode @@ -340,9 +352,6 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: getNBIServiceOrderProgress ****") } - /** - * delay 5 sec - */ public void timeDelay(DelegateExecution execution) { try { logger.debug(Prefix+ " **** DoAllocateCoreNonSharedSlice ::: timeDelay going to sleep for 5 sec") @@ -353,47 +362,42 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { } } - void updateRelationship(DelegateExecution execution) { logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: updateRelationship ****") - String networkServiceInstanceId = execution.getVariable("networkServiceId") String nssiId = execution.getVariable("nssiServiceInstanceId") String globalCustId = execution.getVariable("globalSubscriberId") - String serviceType = execution.getVariable("serviceType") + String serviceType = execution.getVariable("subscriptionServiceType") + logger.debug("networkServiceInstanceId: "+networkServiceInstanceId +" nssiId: "+nssiId +" globalCustId: "+globalCustId+ " serviceType: "+serviceType) try{ //Update NSSI orchestration status nssiServiceInstance ServiceInstance si = execution.getVariable("nssiServiceInstance") + logger.debug("nssiServiceInstance "+si) si.setOrchestrationStatus("activated") + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(nssiId)) + logger.debug("uri to call: "+uri) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(networkServiceInstanceId)) try { getAAIClient().update(uri, si) } catch (Exception e) { logger.info("Update OrchestrationStatus in AAI failed") - String msg = "Update OrchestrationStatus in AAI failed, " + e.getMessage() + String msg = "Update OrchestrationStatus in AAI failed, " + e exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - //URI for NSSI AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)); - + logger.debug("nssiUri to update RelationShip : "+nssiUri) //URI for Network Service Instance AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(networkServiceInstanceId)) - + logger.debug("networkServiceInstanceUri to update RelationShip : "+networkServiceInstanceUri) // Update Relationship in AAI - Response response = getAAIClient().connect(nssiUri, networkServiceInstanceUri, AAIEdgeLabel.COMPOSED_OF); - - if(response.getStatus()!=200 || response.getStatus()!=201 || response.getStatus()!=202) { - exceptionUtil.buildAndThrowWorkflowException(execution, response.getStatus(), "Set association of NSSI and Network service instance has failed in AAI") - } else { - //end point update - createEndPointsInAai(execution) - execution.setVariable("progress", 100) - execution.setVariable("status", "finished") - execution.setVariable("statusDescription", "DoAllocateCoreNonSharedNSSI success") - setResourceOperationStatus(execution) - } + getAAIClient().connect(nssiUri, networkServiceInstanceUri, AAIEdgeLabel.COMPOSED_OF); + //end point update + createEndPointsInAai(execution) + execution.setVariable("progress", "100") + execution.setVariable("status", "finished") + execution.setVariable("statusDescription", "DoAllocateCoreNonSharedNSSI success") + setResourceOperationStatus(execution) }catch(Exception ex) { String msg = "Exception while creating relationship " + ex.getMessage() logger.info(msg) @@ -402,78 +406,81 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: updateRelationship ****") } - private void createEndPointsInAai(DelegateExecution execution) { - String type = "endpoint" - String function = "core_EP" - int prefixLength = 24 - String addressFamily = "ipv4" - //BH RAN end point update - String bh_endpoint = execution.getVariable("bhEndPoints") - 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 nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo") - NetworkRoute bh_ep = new NetworkRoute() - bh_ep.setRouteId(bh_routeId) - bh_ep.setFunction(function) - bh_ep.setRole(role) - bh_ep.setType(type) - bh_ep.setIpAddress(cnIpAddress) - bh_ep.setLogicalInterfaceId(LogicalLinkId) - bh_ep.setNextHop(nextHopInfo) - bh_ep.setPrefixLength(prefixLength) - bh_ep.setAddressFamily(addressFamily) - try { - AAIResourcesClient client = new AAIResourcesClient() - logger.debug("creating bh endpoint . ID : "+bh_routeId+" node details : "+bh_ep.toString()) - AAIResourceUri networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), bh_routeId) - client.create(networkRouteUri, bh_ep) - //relationship b/w bh_ep and Core NSSI - def coreNssi = execution.getVariable("NSSIserviceInstanceId") - Relationship relationship = new Relationship() - String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}" - relationship.setRelatedLink(relatedLink) - relationship.setRelatedTo("network-route") - relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf") - try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - execution.getVariable("globalSubscriberId"), - execution.getVariable("subscriptionServiceType"), - coreNssi).relationshipAPI() - client.create(uri, relationship) - } catch (BpmnError e) { - throw e - } catch (Exception ex) { - String msg = "Exception in CreateCommunicationService.createRelationShipInAAI. " + ex.getMessage() - logger.info(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - } catch (BpmnError e) { - throw e - } catch (Exception ex) { - String msg = "Exception in createEndPointsInAai " + ex.getMessage() - logger.info(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - } - /** - * prepare ResourceOperation status + * creates EndPoints in AAI * @param execution - * @param operationType */ + private void createEndPointsInAai(DelegateExecution execution) { + String type = "endpoint" + String function = "core_EP" + int prefixLength = 24 + String addressFamily = "ipv4" + //BH end point update + String bh_endpoint = execution.getVariable("bh_endpoint") + 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 nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo") + NetworkRoute bh_ep = new NetworkRoute() + logger.debug("bh_endpoint: "+bh_endpoint +" "+ "bh_routeId: "+bh_routeId +" "+ "cnIpAddress: "+cnIpAddress +" "+ "role: "+role +" "+ "cnIpAddress: "+cnIpAddress +" "+ "LogicalLinkId: "+LogicalLinkId +" "+ "nextHopInfo: "+nextHopInfo +" "+ "bh_ep: "+bh_ep) + bh_ep.setRouteId(bh_routeId) + bh_ep.setFunction(function) + bh_ep.setRole(role) + bh_ep.setType(type) + bh_ep.setIpAddress(cnIpAddress) + bh_ep.setLogicalInterfaceId(LogicalLinkId) + bh_ep.setNextHop(nextHopInfo) + bh_ep.setPrefixLength(prefixLength) + bh_ep.setAddressFamily(addressFamily) + try { + AAIResourcesClient client = new AAIResourcesClient() + logger.debug("creating bh endpoint . ID : "+bh_routeId+" node details : "+bh_ep.toString()) + AAIResourceUri networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), bh_routeId) + client.create(networkRouteUri, bh_ep) + //relationship b/w bh_ep and Core NSSI + String coreNssi = execution.getVariable("nssiServiceInstanceId") + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + Relationship relationship = new Relationship() + String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}" + relationship.setRelatedLink(relatedLink) + relationship.setRelatedTo("network-route") + relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf") + logger.debug("networkRouteUri: "+networkRouteUri+"relationship: "+relationship) + try { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(coreNssi)).relationshipAPI() + logger.debug("uri: "+uri) + client.create(uri, relationship) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in createRelationShipInAAI. " + ex.getMessage() + logger.debug(msg+": "+ex) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in createEndPointsInAai " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + private void setResourceOperationStatus(DelegateExecution execution) { logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: 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") + String nssiId = execution.getVariable("nssiServiceInstanceId") + String operationType = "ALLOCATE" ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() resourceOperationStatus.setServiceId(serviceId) resourceOperationStatus.setOperationId(jobId) resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setResourceInstanceID(nssiId) resourceOperationStatus.setOperType(operationType) resourceOperationStatus.setStatus(execution.getVariable("status")) resourceOperationStatus.setProgress(execution.getVariable("progress")) @@ -484,17 +491,23 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { void prepareFailedOperationStatusUpdate(DelegateExecution execution){ logger.debug(Prefix + " **** Enter DoAllocateCoreNonSharedSlice ::: prepareFailedOperationStatusUpdate ****") - 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") - + String nssiId = execution.getVariable("nssiServiceInstanceId") + String operationType = "ALLOCATE" + //modelUuid + String modelUuid= execution.getVariable("modelUuid") + logger.debug("serviceId: "+serviceId +" "+ "jobId: "+jobId +" "+ "nsiId: "+nsiId +" "+ "nssiId: "+nssiId +" "+ "operationType: "+operationType) ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setJobId(jobId) resourceOperationStatus.setOperationId(jobId) resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setResourceInstanceID(nssiId) + resourceOperationStatus.setResourceTemplateUUID(modelUuid) resourceOperationStatus.setOperType(operationType) - resourceOperationStatus.setProgress(0) + resourceOperationStatus.setProgress("0") resourceOperationStatus.setStatus("failed") resourceOperationStatus.setStatusDescription("Core NSSI Allocate Failed") requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) 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 5ecfc9a872..b3c99c6e9a 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 @@ -115,7 +115,7 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: getNetworkInstanceAssociatedWithNssiId ****") //NSSI Id as service Instance Id to get from Request - String serviceInstanceId = execution.getVariable("serviceInstanceID") + String serviceInstanceId = execution.getVariable("nssiId") String errorMsg = "query Network Service Instance from AAI failed" AAIResultWrapper wrapper = queryAAI(execution, Types.SERVICE_INSTANCE, serviceInstanceId, errorMsg) @@ -304,14 +304,6 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { 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") @@ -368,6 +360,8 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { 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 @@ -380,6 +374,8 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { //Traverse VFModules List and add in vfModelInfoList for (vfModule in vfModuleList) { ModelInfo vfModelInfo = vfModule.get("modelInfo") + vfModelInfo.setModelCustomizationId(vfModelInfo.getModelCustomizationUuid()) + vfModelInfo.setModelVersionId(vfModelInfo.getModelId()) logger.debug("vfModelInfo "+vfModelInfo) vfModelInfoList.add(vfModelInfo) } @@ -410,25 +406,31 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { //Individual VFModule List Map<String, Object> vfModuleValues = new LinkedHashMap<>() vfModuleValues.put("modelInfo", vfModuleModelInfo) - vfModuleValues.put("instanceName", vfModuleModelInfo.getModelInstanceName()) + vfModuleValues.put("instanceName", vfModuleModelInfo.getModelName()) //VFModule InstanceParams should be empty or this field should not be there? List<Map<String, Object>> vfModuleInstanceParams = new ArrayList<>() vfModuleValues.put("instanceParams", vfModuleInstanceParams) + vfModules.add(vfModuleValues) } //Vnf intsanceParams Map<String, Object> sliceProfile = mapper.readValue(execution.getVariable("sliceProfile"), Map.class); - List vnfInstanceParamsList = new ArrayList<>() + List<Map<String, Object>> vnfInstanceParamsList = new ArrayList<>() String supportedsNssaiJson= prepareVnfInstanceParamsJson(execution) - vnfInstanceParamsList.add(supportedsNssaiJson) + + Map<String, Object> supportedNssai= new LinkedHashMap<>() + supportedNssai.put("supportedsNssai", supportedsNssaiJson) + vnfInstanceParamsList.add(supportedNssai) Platform platform = new Platform() - platform.setPlatformName(execution.getVariable("platform")) + String platformName = execution.getVariable("platformName") + platform.setPlatformName(platformName) LineOfBusiness lineOfbusiness = new LineOfBusiness() - lineOfbusiness.setLineOfBusinessName(execution.getVariable("lineOfBusiness")) + String lineOfBusinessName = execution.getVariable("lineOfBusinessName") + lineOfbusiness.setLineOfBusinessName(lineOfBusinessName) //Vnf Values Map<String, Object> vnfValues = new LinkedHashMap<>() @@ -438,7 +440,7 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { vnfValues.put("cloudConfiguration", cloudConfiguration) vnfValues.put("vfModules", vfModules) vnfValues.put("modelInfo", vnfModelInfo) - vnfValues.put("instanceName", execution.getVariable("vnfInstanceName")) + vnfValues.put("instanceName", vnfModelInfo.getModelInstanceName()) vnfValues.put("instanceParams",vnfInstanceParamsList) vnfModelInfoList.add(vnfValues) @@ -496,10 +498,8 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { Map<String, Object> requestDetailsMap = new LinkedHashMap<>() requestDetailsMap.put("requestDetails", requestDetails) String requestPayload = mapper.writeValueAsString(requestDetailsMap) - logger.debug("requestDetails "+requestPayload) execution.setVariable("requestPayload", requestPayload) - logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: prepareSOMacroRequestPayLoad ****") } @@ -508,14 +508,11 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { List instanceParamsvalues = execution.getVariable("snssaiAndOrchStatusList") Map<String, Object> nSsai= new LinkedHashMap<>() nSsai.put("sNssai", instanceParamsvalues) - String supportedsNssaiJson = mapper.writeValueAsString(nSsai) //SupportedNssai - Map<String, Object> supportedNssai= new LinkedHashMap<>() - supportedNssai.put("supportedNssai", supportedsNssaiJson) - logger.debug("**** supportedsNssaiJson**** "+supportedNssai) + logger.debug("**** supportedsNssaiJson**** "+supportedsNssaiJson) logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: prepareVnfInstanceParamsJson ****") - return supportedNssai + return supportedsNssaiJson } public void sendPutRequestToSOMacro(DelegateExecution execution) { @@ -523,14 +520,9 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { 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) - + String encodeString = "Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==" + logger.debug("msoEndpoint: "+msoEndpoint +" "+ "url: "+url +" requestBody: "+requestBody +" "+ "encodeString: "+encodeString) HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) httpClient.addAdditionalHeader("Authorization", encodeString) httpClient.addAdditionalHeader("Accept", "application/json") @@ -546,84 +538,93 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { 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) - String operationId = execution.getVariable("operationId") - def macroOperationId = jsonUtil.getJsonValue(soResponse, "operationId") + 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") execution.setVariable("macroOperationId", macroOperationId) + execution.setVariable("requestSelfLink", requestSelfLink) execution.setVariable("isSOTimeOut", "no") execution.setVariable("isSOResponseSucceed","yes") } else { - String serviceName = execution.getVariable("serviceInstanceName") execution.setVariable("isSOResponseSucceed","no") prepareFailedOperationStatusUpdate(execution) } logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: handleSOResponse ****") } - /** - * prepare to call sub process CheckProcessStatus - * @param execution - */ - void prepareCallCheckProcessStatus(DelegateExecution execution){ - logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: 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 DoAllocateCoreSharedSlice ::: prepareCallCheckProcessStatus ****") + 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==") + httpClient.addAdditionalHeader("Accept", "application/json") + Response httpResponse = httpClient.get() + logger.debug("httpResponse "+httpResponse) + 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) + String requestState= jsonUtil.getJsonValue(soResponse, "request.requestStatus.requestState") + logger.debug("requestState: "+requestState) + execution.setVariable("requestState", requestState) + } else { + execution.setVariable("isSOResponseSucceed","no") + prepareFailedOperationStatusUpdate(execution) + } + logger.debug(Prefix+ " **** Exit DoAllocateCoreSharedSlice ::: getSOPUTProgress ****") + } + + public void timeDelay(DelegateExecution execution) { + try { + logger.debug(Prefix+ " **** DoAllocateCoreSharedSlice ::: timeDelay going to sleep for 5 sec") + Thread.sleep(5000) + logger.debug("**** DoAllocateCoreNonSharedSlice ::: 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(execution.getVariable("isTimeOut").equals("YES")) { - logger.debug("TIMEOUT - SO PUT Failure") - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "SO PUT Failure") - } else { + if("COMPLETED".equals(execution.getVariable("requestState"))) { execution.setVariable("progress", "100") execution.setVariable("status", "finished") execution.setVariable("operationContent", "AllocteCoreNSSI successful.") - logger.debug("prepareFailureStatus,result:${execution.getVariable("result")}, reason: ${execution.getVariable("reason")}") + logger.debug("Success ,result:${execution.getVariable("result")}, reason: ${execution.getVariable("reason")}") + } else { + logger.debug("SO PUT Failure") + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "SO PUT Failure") } 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 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) ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() resourceOperationStatus.setServiceId(serviceId) resourceOperationStatus.setOperationId(jobId) resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setResourceInstanceID(nssiId) resourceOperationStatus.setOperType(operationType) resourceOperationStatus.setStatus("finished") resourceOperationStatus.setProgress("100") @@ -634,17 +635,19 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { void prepareFailedOperationStatusUpdate(DelegateExecution execution){ logger.debug(Prefix + " **** Enter DoAllocateCoreSharedSlice ::: prepareFailedOperationStatusUpdate ****") - 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") - + String operationType = "ALLOCATE" + logger.debug("serviceId: "+serviceId +" "+ " jobId: "+jobId +" "+ " nsiId: "+nsiId+" operationType: "+operationType) + String modelUuid= execution.getVariable("modelUuid") ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setJobId(jobId) resourceOperationStatus.setOperationId(jobId) - resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setResourceTemplateUUID(modelUuid) resourceOperationStatus.setOperType(operationType) - resourceOperationStatus.setProgress(0) + resourceOperationStatus.setProgress("0") resourceOperationStatus.setStatus("failed") resourceOperationStatus.setStatusDescription("Core NSSI Allocate Failed") requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy index 159f4c48ef..059a209336 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy @@ -20,8 +20,12 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.aai.domain.yang.NetworkRoute +import org.onap.so.beans.nsmf.ConnectionLink +import org.onap.so.beans.nsmf.EndPoint import org.onap.so.beans.nsmf.NsiInfo import org.onap.so.beans.nsmf.SliceProfileAdapter +import org.onap.so.beans.nsmf.TransportSliceNetwork import org.onap.so.beans.nsmf.oof.SubnetType import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import javax.ws.rs.NotFoundException @@ -122,7 +126,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ String sliceInstanceName = "nsi_"+execution.getVariable("sliceServiceInstanceName") - String serviceType = execution.getVariable("serviceType") + String serviceType = sliceParams.serviceProfile.get("sST") String serviceStatus = "deactivated" String modelInvariantUuid = sliceParams.getNSTInfo().invariantUUID String modelUuid = sliceParams.getNSTInfo().UUID @@ -296,7 +300,24 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ SliceProfile sliceProfile = new SliceProfile() sliceProfile.setProfileId(profileId) sliceProfile.setCoverageAreaTAList(anSliceProfile.coverageAreaTAList) - //todo:... + sliceProfile.setMaxNumberOfUEs(anSliceProfile.maxNumberOfUEs) + sliceProfile.setLatency(anSliceProfile.latency) + sliceProfile.setMaxNumberOfPDUSession(anSliceProfile.maxNumberOfPDUSession) + sliceProfile.setExpDataRateDL(anSliceProfile.expDataRateDL) + sliceProfile.setExpDataRateUL(anSliceProfile.expDataRateUL) + sliceProfile.setAreaTrafficCapDL(anSliceProfile.areaTrafficCapDL) + sliceProfile.setAreaTrafficCapUL(anSliceProfile.areaTrafficCapUL) + sliceProfile.setOverallUserDensity(anSliceProfile.overallUserDensity) + sliceProfile.setActivityFactor(anSliceProfile.activityFactor) + sliceProfile.setUeMobilityLevel(anSliceProfile.ueMobilityLevel) + sliceProfile.setResourceSharingLevel(anSliceProfile.resourceSharingLevel) + sliceProfile.setCsAvailabilityTarget(anSliceProfile.csAvailabilityTarget) + sliceProfile.setCsReliabilityMeanTime(anSliceProfile.csReliabilityMeanTime) + sliceProfile.setExpDataRate(anSliceProfile.expDataRate) + sliceProfile.setMsgSizeByte(anSliceProfile.msgSizeByte) + sliceProfile.setTransferIntervalTarget(anSliceProfile.transferIntervalTarget) + sliceProfile.setSurvivalTime(anSliceProfile.survivalTime) + AAIResourceUri uri = AAIUriFactory.createResourceUri( AAIFluentTypeBuilder.business().customer(globalSubscriberId) .serviceSubscription(subscriptionServiceType) @@ -307,6 +328,57 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ execution.setVariable("sliceTaskParams", sliceParams) } + void createANEndpoint(DelegateExecution execution){ + logger.debug("Enter createANEndpoint in DoAllocateNSIandNSSI()") + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter + SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.anSliceTaskInfo + + NetworkRoute route = new NetworkRoute() + String routeId = UUID.randomUUID().toString() + route.setRouteId(routeId) + route.setType("endpoint") + route.setRole("an") + route.setFunction("3gppTransportEP") + route.setIpAddress( sliceTaskInfo.sliceProfile.ipAddress) + route.setNextHop(sliceTaskInfo.sliceProfile.nextHopInfo) + route.setAddressFamily("ipv4") + route.setPrefixLength(24) + sliceTaskInfo.setEndPointId(routeId) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkRoute(routeId)) + client.create(uri, route) + execution.setVariable("sliceTaskParams", sliceParams) + logger.info("an endpointId:" + sliceParams.anSliceTaskInfo.endPointId) + } + + + void createCNEndpoint(DelegateExecution execution){ + logger.debug("Enter createCNNetworkRoute in DoAllocateNSIandNSSI()") + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter + SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.cnSliceTaskInfo + + NetworkRoute route = new NetworkRoute() + String routeId = UUID.randomUUID().toString() + route.setRouteId(routeId) + route.setType("endpoint") + route.setRole("cn") + route.setFunction("3gppTransportEP") + route.setIpAddress( sliceTaskInfo.sliceProfile.ipAddress) + route.setNextHop(sliceTaskInfo.sliceProfile.nextHopInfo) + route.setAddressFamily("ipv4") + route.setPrefixLength(24) + + sliceTaskInfo.setEndPointId(routeId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkRoute(routeId)) + client.create(uri, route) + + execution.setVariable("cnEndpointId", routeId) + execution.setVariable("sliceTaskParams", sliceParams) + logger.info("cn endpointId:" + sliceParams.cnSliceTaskInfo.endPointId) + } + /** * prepare AllocateAnNssi * @param execution @@ -322,12 +394,20 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ AllocateAnNssi allocateAnNssi = new AllocateAnNssi() allocateAnNssi.sliceProfile = sliceTaskInfo.sliceProfile.trans2AnProfile() + allocateAnNssi.sliceProfile.sliceProfileId = sliceTaskInfo.sliceInstanceId allocateAnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID allocateAnNssi.nssiId = sliceTaskInfo.suggestNssiId - allocateAnNssi.nssiName = sliceTaskInfo.NSSTInfo.name + allocateAnNssi.nssiName = "nssi_an" + execution.getVariable("sliceServiceInstanceName") NsiInfo nsiInfo = new NsiInfo() nsiInfo.nsiId = sliceParams.suggestNsiId + nsiInfo.nsiName = sliceParams.suggestNsiName allocateAnNssi.nsiInfo = nsiInfo + //endPoint + EndPoint endPoint = new EndPoint() + endPoint.setIpAddress(sliceTaskInfo.sliceProfile.ipAddress) + endPoint.setLogicInterfaceId(sliceTaskInfo.sliceProfile.logicInterfaceId) + endPoint.setNextHopInfo(sliceTaskInfo.sliceProfile.nextHopInfo) + allocateAnNssi.setEndPoint(endPoint) EsrInfo esrInfo = new EsrInfo() //todo: vendor and network @@ -344,6 +424,8 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ serviceInfo.nsiId = sliceParams.suggestNsiId serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID + serviceInfo.sST = sliceTaskInfo.sliceProfile.sST ?: sliceParams.serviceProfile.get("sST") + serviceInfo.nssiName = allocateAnNssi.nssiName nbiRequest.setServiceInfo(serviceInfo) nbiRequest.setEsrInfo(esrInfo) @@ -411,7 +493,24 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ SliceProfile sliceProfile = new SliceProfile() sliceProfile.setProfileId(profileId) sliceProfile.setCoverageAreaTAList(cnSliceProfile.coverageAreaTAList as String) - //todo:... + sliceProfile.setMaxNumberOfUEs(cnSliceProfile.maxNumberOfUEs) + sliceProfile.setLatency(cnSliceProfile.latency) + sliceProfile.setMaxNumberOfPDUSession(cnSliceProfile.maxNumberOfPDUSession) + sliceProfile.setExpDataRateDL(cnSliceProfile.expDataRateDL) + sliceProfile.setExpDataRateUL(cnSliceProfile.expDataRateUL) + sliceProfile.setAreaTrafficCapDL(cnSliceProfile.areaTrafficCapDL) + sliceProfile.setAreaTrafficCapUL(cnSliceProfile.areaTrafficCapUL) + sliceProfile.setOverallUserDensity(cnSliceProfile.overallUserDensity) + sliceProfile.setActivityFactor(cnSliceProfile.activityFactor) + sliceProfile.setUeMobilityLevel(cnSliceProfile.ueMobilityLevel) + sliceProfile.setResourceSharingLevel(cnSliceProfile.resourceSharingLevel) + sliceProfile.setCsAvailabilityTarget(cnSliceProfile.csAvailabilityTarget) + sliceProfile.setCsReliabilityMeanTime(cnSliceProfile.csReliabilityMeanTime) + sliceProfile.setExpDataRate(cnSliceProfile.expDataRate) + sliceProfile.setMsgSizeByte(cnSliceProfile.msgSizeByte) + sliceProfile.setTransferIntervalTarget(cnSliceProfile.transferIntervalTarget) + sliceProfile.setSurvivalTime(cnSliceProfile.survivalTime) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() .customer(globalSubscriberId) .serviceSubscription(subscriptionServiceType) @@ -437,11 +536,20 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ AllocateCnNssi allocateCnNssi = new AllocateCnNssi() allocateCnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID allocateCnNssi.nssiId = sliceTaskInfo.suggestNssiId - allocateCnNssi.nssiName = sliceTaskInfo.NSSTInfo.name + allocateCnNssi.nssiName = "nssi_cn" + execution.getVariable("sliceServiceInstanceName") allocateCnNssi.sliceProfile = sliceTaskInfo.sliceProfile.trans2CnProfile() + allocateCnNssi.sliceProfile.sliceProfileId = sliceTaskInfo.sliceInstanceId + NsiInfo nsiInfo = new NsiInfo() nsiInfo.nsiId = sliceParams.suggestNsiId + nsiInfo.nsiName = sliceParams.suggestNsiName allocateCnNssi.nsiInfo = nsiInfo + // endPoint + EndPoint endPoint = new EndPoint() + endPoint.setIpAddress(sliceTaskInfo.sliceProfile.ipAddress) + endPoint.setLogicInterfaceId(sliceTaskInfo.sliceProfile.logicInterfaceId) + endPoint.setNextHopInfo(sliceTaskInfo.sliceProfile.nextHopInfo) + allocateCnNssi.setEndPoint(endPoint) EsrInfo esrInfo = new EsrInfo() //todo: vendor and network @@ -459,6 +567,8 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID serviceInfo.nssiId = sliceTaskInfo.suggestNssiId //if shared + serviceInfo.sST = sliceTaskInfo.sliceProfile.sST ?: sliceParams.serviceProfile.get("sST") + serviceInfo.nssiName = allocateCnNssi.nssiName nbiRequest.setServiceInfo(serviceInfo) nbiRequest.setEsrInfo(esrInfo) @@ -526,7 +636,10 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ SliceProfile sliceProfile = new SliceProfile() sliceProfile.setProfileId(profileId) - //todo:... + sliceProfile.setLatency(tnSliceProfile.latency) + sliceProfile.setMaxBandwidth(tnSliceProfile.maxBandwidth) + sliceProfile.setJitter(tnSliceProfile.jitter) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() .customer(globalSubscriberId) .serviceSubscription(subscriptionServiceType) @@ -552,11 +665,24 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ AllocateTnNssi allocateTnNssi = new AllocateTnNssi() //todo: AllocateTnNssi - //todo: endpointId -> set into tn - allocateTnNssi.setTransportSliceNetworks() - allocateTnNssi.setNetworkSliceInfos() - + //todo: endPointId -> set into tn + List<TransportSliceNetwork> transportSliceNetworks = new ArrayList<>() + TransportSliceNetwork transportSliceNetwork = new TransportSliceNetwork() + List<ConnectionLink> connectionLinks = new ArrayList<>() + ConnectionLink connectionLink = new ConnectionLink() + connectionLink.setTransportEndpointA(sliceParams.anSliceTaskInfo.endPointId) + connectionLink.setTransportEndpointB(sliceParams.cnSliceTaskInfo.endPointId) + connectionLinks.add(connectionLink) + transportSliceNetwork.setConnectionLinks(connectionLinks) + transportSliceNetworks.add(transportSliceNetwork) + allocateTnNssi.setTransportSliceNetworks(transportSliceNetworks) + allocateTnNssi.setNetworkSliceInfos() + allocateTnNssi.setSliceProfile(sliceTaskInfo.sliceProfile.trans2TnProfile()) + NsiInfo nsiInfo = new NsiInfo() + nsiInfo.setNsiId(sliceParams.suggestNsiId) + nsiInfo.setNsiName(sliceParams.suggestNsiName) + allocateTnNssi.setNsiInfo(nsiInfo) //allocateTnNssi.networkSliceInfos @@ -574,6 +700,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID serviceInfo.nssiId = sliceTaskInfo.suggestNssiId + serviceInfo.sST = sliceTaskInfo.sliceProfile.sST ?: sliceParams.serviceProfile.get("sST") nbiRequest.setServiceInfo(serviceInfo) nbiRequest.setEsrInfo(esrInfo) @@ -603,17 +730,21 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ String nsiId = sliceParams.getSuggestNsiId() String sliceProfileInstanceId = sliceParams.anSliceTaskInfo.sliceInstanceId String serviceProfileInstanceId = sliceParams.serviceId + String epId = sliceParams.anSliceTaskInfo.endPointId //nsi id - //todo: aai -> nssi -> relationship -> endpointId -> set into tn - String endPointId = getEndpointIdFromAAI(execution, nssiId) - execution.setVariable("endPointIdAn", endPointId) - + //todo: aai -> nssi -> relationship -> endPointId -> set into tn + //String endPointId = getEndpointIdFromAAI(execution, nssiId) + //execution.setVariable("endPointIdAn", endPointId) updateRelationship(execution, nsiId, nssiId) updateRelationship(execution, serviceProfileInstanceId, sliceProfileInstanceId) updateRelationship(execution, sliceProfileInstanceId, nssiId) + updateEPRelationship(execution, nssiId, epId) + + updateEPRelationship(execution, sliceProfileInstanceId, epId) + sliceParams.anSliceTaskInfo.suggestNssiId = nssiId execution.setVariable("sliceTaskParams", sliceParams) } @@ -637,16 +768,21 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ String nsiId = sliceParams.getSuggestNsiId() String sliceProfileInstanceId = sliceParams.cnSliceTaskInfo.sliceInstanceId String serviceProfileInstanceId = sliceParams.serviceId + String epId = sliceParams.cnSliceTaskInfo.endPointId //nsi id - //todo: aai -> nssi -> relationship -> endpointId -> set into tn - String endPointId = getEndpointIdFromAAI(execution, nssiId) - execution.setVariable("endPointIdCn", endPointId) + //todo: aai -> nssi -> relationship -> endPointId -> set into tn +// String endPointId = getEndpointIdFromAAI(execution, nssiId) +// execution.setVariable("endPointIdCn", endPointId) updateRelationship(execution, nsiId, nssiId) updateRelationship(execution, serviceProfileInstanceId, sliceProfileInstanceId) - updateRelationship(execution,sliceProfileInstanceId, nssiId) + updateRelationship(execution, sliceProfileInstanceId, nssiId) + + updateEPRelationship(execution, nssiId, epId) + + updateEPRelationship(execution, sliceProfileInstanceId, epId) sliceParams.cnSliceTaskInfo.suggestNssiId = nssiId execution.setVariable("sliceTaskParams", sliceParams) @@ -682,7 +818,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } else { ServiceInstance nssiInstance = si.get() - //todo: handle relationship and return endpointId + //todo: handle relationship and return endPointId if (nssiInstance.relationshipList == null) { String msg = "relationshipList of " + nssiId + " is null" logger.debug(msg) @@ -751,7 +887,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ .serviceSubscription(execution.getVariable("subscriptionServiceType")) .serviceInstance(targetId)) - logger.info("Creating relationship, targetInstanceUri: " + targetInstanceUri) + logger.debug("Creating relationship, targetInstanceUri: " + targetInstanceUri) relationship.setRelatedLink(targetInstanceUri.build().toString()) @@ -763,12 +899,36 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ client.create(sourceInstanceUri, relationship) } + /** + * update endpoint relationship + * @param execution + * @param sourceId + * @param targetId + */ + void updateEPRelationship(DelegateExecution execution, String sourceId, String endpointId) { + //relation ship + Relationship relationship = new Relationship() + + AAIResourceUri endpointUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkRoute(endpointId)) + + logger.debug("Creating relationship, endpoint Uri: " + endpointUri + ",endpointId: " + endpointId) + + relationship.setRelatedLink(endpointUri.build().toString()) + + AAIResourceUri sourceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(sourceId)) + .relationshipAPI() + client.create(sourceInstanceUri, relationship) + } + static def createSliceProfileInstance(SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo, String oStatus) { // create slice profile ServiceInstance rspi = new ServiceInstance() rspi.setServiceInstanceName(sliceTaskInfo.NSSTInfo.name) rspi.setServiceType(sliceTaskInfo.sliceProfile.getSST()) - rspi.setServiceRole("slice-profile-instance") + rspi.setServiceRole("slice-profile") rspi.setOrchestrationStatus(oStatus) rspi.setServiceInstanceLocationId(sliceTaskInfo.sliceProfile.getPLMNIdList()) rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy index 896d7ff4b1..e88b1c747f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy @@ -62,8 +62,10 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { */ void sendCreateRequestNSSMF(DelegateExecution execution) { NssmfAdapterNBIRequest nbiRequest = execution.getVariable("nbiRequest") as NssmfAdapterNBIRequest - String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, NSSMF_ALLOCATE_URL, - objectMapper.writeValueAsString(nbiRequest)) + String nssmfRequest = objectMapper.writeValueAsString(nbiRequest) + logger.debug("sendCreateRequestNSSMF: " + nssmfRequest) + + String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, NSSMF_ALLOCATE_URL, nssmfRequest) if (response != null) { NssiResponse nssiResponse = objectMapper.readValue(response, NssiResponse.class) @@ -97,10 +99,16 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, endpoint, objectMapper.writeValueAsString(nbiRequest)) + logger.debug("nssmf response nssiAllocateStatus:" + response) + if (response != null) { JobStatusResponse jobStatusResponse = objectMapper.readValue(response, JobStatusResponse.class) - execution.setVariable("nssiAllocateStatus", jobStatusResponse) + if (StringUtils.isBlank(nssiId)) { + nssiAllocateResult.setNssiId(jobStatusResponse.getResponseDescriptor().getNssiId()) + execution.setVariable("nssiAllocateResult", nssiAllocateResult) + } + execution.setVariable("nssiAllocateStatus", jobStatusResponse) if (jobStatusResponse.getResponseDescriptor().getProgress() == 100) { execution.setVariable("jobFinished", true) } @@ -119,7 +127,7 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { SliceTaskInfo sliceTaskInfo = execution.getVariable("sliceTaskInfo") as SliceTaskInfo sliceTaskInfo.progress = response.getProgress() - sliceTaskInfo.status = response.getStatus() + sliceTaskInfo.status = response.getStatus().toLowerCase() sliceTaskInfo.statusDescription = response.getStatusDescription() updateNssiResult(sliceParams, subnetType, sliceTaskInfo) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy index ec70bd3780..ccb04d9440 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy @@ -100,7 +100,6 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{ * todo: role */ String serviceRole = "service-profile" - String serviceType = execution.getVariable("serviceType") String globalSubscriberId = execution.getVariable("globalSubscriberId") String subscriptionServiceType = execution.getVariable("subscriptionServiceType") @@ -111,7 +110,7 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{ ss.setServiceInstanceId(ssInstanceId) String sliceInstanceName = execution.getVariable("serviceInstanceName") ss.setServiceInstanceName(sliceInstanceName) - ss.setServiceType(serviceType) + ss.setServiceType(serviceProfile.get("sST")) String serviceStatus = "deactivated" ss.setOrchestrationStatus(serviceStatus) String modelInvariantUuid = modelInfo.getModelInvariantUuid() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy index 9450227467..25a7159264 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy @@ -416,10 +416,10 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ sliceProfile.remove("domainType") SliceProfileAdapter adapter = objectMapper.readValue(objectMapper.writeValueAsString(sliceProfile), SliceProfileAdapter.class) switch (domainType.toLowerCase()) { - case "tn-bh": + case "tn_bh": sliceParams.tnBHSliceTaskInfo.sliceProfile = adapter break - case "an-nf": + case "an_nf": case "an": sliceParams.anSliceTaskInfo.sliceProfile = adapter break diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy index f20bca9837..04f07b66d4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy @@ -34,6 +34,8 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.slf4j.Logger import org.slf4j.LoggerFactory +import static org.apache.commons.lang3.StringUtils.isBlank + class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger(DoCreateTnNssiInstance.class); @@ -61,6 +63,8 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { }""" execution.setVariable("serviceModelInfo", serviceModelInfo) + tnNssmfUtils.setEnableSdncConfig(execution) + logger.trace("Exit preProcessRequest") } @@ -101,7 +105,7 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { void createServiceInstance(DelegateExecution execution) { - String serviceRole = "TN" + String serviceRole = "nssi" String serviceType = execution.getVariable("subscriptionServiceType") String ssInstanceId = execution.getVariable("sliceServiceInstanceId") String sliceProfileStr = execution.getVariable("sliceProfile") @@ -109,19 +113,23 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { org.onap.aai.domain.yang.ServiceInstance ss = new org.onap.aai.domain.yang.ServiceInstance() ss.setServiceInstanceId(ssInstanceId) String sliceInstanceName = execution.getVariable("sliceServiceInstanceName") + if (isBlank(sliceInstanceName)) { + logger.error("ERROR: createServiceInstance: sliceInstanceName is null") + sliceInstanceName = ssInstanceId + } ss.setServiceInstanceName(sliceInstanceName) ss.setServiceType(serviceType) - String serviceStatus = "allocated" + String serviceStatus = "deactivated" ss.setOrchestrationStatus(serviceStatus) String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("modelUuid") - //TODO: need valid model ID from the caller, as AAI does not accept invalid IDs - //ss.setModelInvariantId(modelInvariantUuid) - //ss.setModelVersionId(modelUuid) + ss.setModelInvariantId(modelInvariantUuid) + ss.setModelVersionId(modelUuid) String serviceInstanceLocationid = tnNssmfUtils.getFirstPlmnIdFromSliceProfile(sliceProfileStr) ss.setServiceInstanceLocationId(serviceInstanceLocationid) String snssai = tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr) - ss.setEnvironmentContext(snssai) + //ss.setEnvironmentContext(snssai) + ss.setEnvironmentContext("tn") ss.setServiceRole(serviceRole) AAIResourcesClient client = getAAIClient() AAIResourceUri uri = diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy index f3bc47e7cf..147e623ece 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy @@ -21,25 +21,26 @@ package org.onap.so.bpmn.infrastructure.scripts import com.fasterxml.jackson.databind.ObjectMapper import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.SliceProfiles +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAISimpleUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder -import org.onap.so.beans.nsmf.DeAllocateNssi -import org.onap.so.beans.nsmf.EsrInfo -import org.onap.so.beans.nsmf.NetworkType -import org.onap.so.beans.nsmf.NssiResponse -import org.onap.so.beans.nsmf.ServiceInfo +import org.onap.so.beans.nsmf.* +import org.onap.so.beans.nsmf.oof.SubnetType import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils import org.onap.so.bpmn.common.scripts.RequestDBUtil -import org.onap.so.bpmn.core.domain.ServiceArtifact import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.db.request.beans.OperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory +import javax.ws.rs.NotFoundException class DoDeallocateNSSI extends AbstractServiceTaskProcessor { @@ -103,15 +104,13 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor try { ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") as ServiceDecomposition - ServiceArtifact serviceArtifact = serviceDecomposition ?.getServiceInfo()?.getServiceArtifact()?.get(0) - String content = serviceArtifact.getContent() - String vendor = jsonUtil.getJsonValue(content, "metadata.vendor") - String domainType = jsonUtil.getJsonValue(content, "metadata.domainType") + String vendor = serviceDecomposition ?.getServiceRole() + NetworkType domainType = convertServiceCategory(serviceDecomposition.getServiceCategory()) def currentNSSI = execution.getVariable("currentNSSI") currentNSSI['vendor'] = vendor currentNSSI['domainType'] = domainType - LOGGER.info("processDecomposition, current vendor-domainType:" +String.join("-", vendor, domainType)) + LOGGER.info("processDecomposition, current vendor-domainType:" +String.join("-", vendor, domainType.toString())) } catch (any) { String exceptionMessage = "Bpmn error encountered in deallocate nssi. processDecomposition() - " + any.getMessage() @@ -120,6 +119,27 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor } LOGGER.debug("*****${PREFIX} Exit processDecomposition *****") } + + + /** + * get subnetType from serviceCategory + * @return + */ + private NetworkType convertServiceCategory(String serviceCategory){ + if(serviceCategory ==~ /CN.*/){ + return SubnetType.CN.getNetworkType() + } + if (serviceCategory ==~ /AN.*NF.*/){ + return SubnetType.AN.getNetworkType() + } + if (serviceCategory ==~ /TN.*BH.*/){ + return SubnetType.TN_BH.getNetworkType() + } + if(serviceCategory ==~ /TN.*MH.*/){ + return SubnetType.TN_MH.getNetworkType() + } + return null + } /** * send deallocate request to nssmf @@ -136,9 +156,9 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor String scriptName = execution.getVariable("scriptName") String serviceInvariantUuid = currentNSSI['modelInvariantId'] - String serviceUuid = currentNSSI['modelId'] + String serviceUuid = currentNSSI['modelVersionId'] String globalSubscriberId = currentNSSI['globalSubscriberId'] - String subscriptionServiceType = execution.getVariable("serviceType") + String subscriptionServiceType = currentNSSI['serviceType'] DeAllocateNssi deAllocateNssi = new DeAllocateNssi() deAllocateNssi.setNsiId(nsiId) @@ -191,8 +211,6 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor { def currentNSSI = execution.getVariable("currentNSSI") String jobId = currentNSSI['jobId'] - - execution.setVariable("responseId", "3") execution.setVariable("jobId", jobId) } @@ -245,11 +263,11 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor private EsrInfo getEsrInfo(def currentNSSI) { - String domaintype = currentNSSI['domainType'] + NetworkType domainType = currentNSSI['domainType'] String vendor = currentNSSI['vendor'] EsrInfo info = new EsrInfo() - info.setNetworkType(NetworkType.fromString(domaintype)) + info.setNetworkType(domainType) info.setVendor(vendor) return info } @@ -264,17 +282,17 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor def currentNSSI = execution.getVariable("currentNSSI") int currentProgress = currentNSSI["jobProgress"] def proportion = currentNSSI['proportion'] - def statusDes = currentNSSI["statusDescription"] int progress = (currentProgress as int) == 0 ? 0 : (currentProgress as int) / 100 * (proportion as int) def status = currentNSSI['status'] - + + OperationStatus operationStatus = new OperationStatus() operationStatus.setServiceId(currentNSSI['e2eServiceInstanceId'] as String) operationStatus.setOperationId(currentNSSI['operationId'] as String) operationStatus.setOperation("DELETE") - operationStatus.setResult(status as String) + operationStatus.setResult("processing") operationStatus.setProgress(progress as String) - operationStatus.setOperationContent(statusDes as String) + operationStatus.setOperationContent(currentNSSI['domainType'].toString() + " " + status.toString()) requestDBUtil.prepareUpdateOperationStatus(execution, operationStatus) LOGGER.debug("update operation, currentProgress=${currentProgress}, proportion=${proportion}, progress = ${progress}" ) } @@ -283,20 +301,20 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * delete slice profile from aai * @param execution */ - void delSliceProfileFromAAI(DelegateExecution execution) + void delSliceProfileServiceFromAAI(DelegateExecution execution) { LOGGER.debug("*****${PREFIX} start delSliceProfileFromAAI *****") def currentNSSI = execution.getVariable("currentNSSI") String nssiServiceInstanceId = currentNSSI['nssiServiceInstanceId'] String profileId = currentNSSI['profileId'] String globalSubscriberId = currentNSSI["globalSubscriberId"] - String serviceType = execution.getVariable("serviceType") + String serviceType = currentNSSI['serviceType'] try { LOGGER.debug("delete nssiServiceInstanceId:${nssiServiceInstanceId}, profileId:${profileId}") AAIResourceUri resourceUri = AAIUriFactory.createResourceUri( - AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiServiceInstanceId).sliceProfile(profileId)) + AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(profileId)) if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } @@ -310,4 +328,41 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor } LOGGER.debug("*****${PREFIX} Exist delSliceProfileFromAAI *****") } + + void delSliceProfileFromAAI(DelegateExecution execution){ + + LOGGER.debug("*****${PREFIX} start delSliceProfileFromAAI *****") + def currentNSSI = execution.getVariable("currentNSSI") + String globalSubscriberId = currentNSSI["globalSubscriberId"] + String serviceType = currentNSSI['serviceType'] + String sliceProfileInstId = currentNSSI['profileId'] + + try + { + AAIPluralResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(sliceProfileInstId).sliceProfiles()) + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) + Optional<SliceProfiles> sliceProfilesOpt =wrapper.asBean(SliceProfiles.class) + SliceProfiles sliceProfiles + String profileId + if(sliceProfilesOpt.isPresent()){ + sliceProfiles = sliceProfilesOpt.get() + org.onap.aai.domain.yang.SliceProfile sliceProfile = sliceProfiles.getSliceProfile().get(0) + profileId = sliceProfile ? sliceProfile.getProfileId() : "" + } + if (profileId){ + AAISimpleUri profileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(sliceProfileInstId).sliceProfile(profileId)) + if (!getAAIClient().exists(profileUri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") + } + getAAIClient().delete(profileUri) + } + + } + catch (any) + { + String msg = "delete service profile from aai failed! cause-"+any.getCause() + LOGGER.error(any.printStackTrace()) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); + } + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy index c817eaad61..a715e7799d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy @@ -25,7 +25,6 @@ import groovy.json.JsonSlurper import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.ServiceInstance -import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory @@ -81,6 +80,9 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { "modelVersion":"" }""" execution.setVariable("serviceModelInfo", serviceModelInfo) + + tnNssmfUtils.setEnableSdncConfig(execution) + logger.debug("Finish preProcessRequest") } @@ -150,18 +152,15 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { String status, String progress, String statusDescription) { - String serviceId = execution.getVariable("sliceServiceInstanceId") + String ssInstanceId = execution.getVariable("sliceServiceInstanceId") + String modelUuid = execution.getVariable("modelUuid") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") - ResourceOperationStatus roStatus = new ResourceOperationStatus() - roStatus.setServiceId(serviceId) - roStatus.setOperationId(jobId) - roStatus.setResourceTemplateUUID(nsiId) - roStatus.setOperType("Deallocate") - roStatus.setProgress(progress) - roStatus.setStatus(status) - roStatus.setStatusDescription(statusDescription) + ResourceOperationStatus roStatus = tnNssmfUtils.buildRoStatus(modelUuid, ssInstanceId, + jobId, nsiId, "DEALLOCATE", status, progress, statusDescription) + + logger.debug("DoDeallocateTnNssi: roStatus={}", roStatus) requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy index c4321220fd..5fd06fd8d4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy @@ -19,19 +19,15 @@ */ package org.onap.so.bpmn.infrastructure.scripts -import static org.apache.commons.lang3.StringUtils.isBlank -import javax.ws.rs.NotFoundException -import javax.ws.rs.core.Response import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.AllottedResource import org.onap.aai.domain.yang.AllottedResources import org.onap.aai.domain.yang.Relationship import org.onap.aai.domain.yang.ServiceInstance -import org.onap.aai.domain.yang.ServiceProfile -import org.onap.aai.domain.yang.ServiceProfiles import org.onap.aaiclient.client.aai.AAIObjectName import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types @@ -45,6 +41,11 @@ import org.onap.so.client.HttpClientFactory import org.slf4j.Logger import org.slf4j.LoggerFactory +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response + +import static org.apache.commons.lang3.StringUtils.isBlank + /** * This groovy class supports the <class>DoDeleteSliceService.bpmn</class> process. * @@ -99,7 +100,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { * save snssai * @param execution */ - void queryE2ESliceSeriveFromAAI(DelegateExecution execution) + void queryServiceProfileFromAAI(DelegateExecution execution) { LOGGER.trace(" *****${PREFIX} Start queryE2ESliceSeriveFromAAI *****") String serviceInstanceId = execution.getVariable("serviceInstanceId") @@ -111,11 +112,11 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { if(si.isPresent()) { String snssai = si.get()?.getEnvironmentContext() - ServiceProfiles serviceProfiles = si.get()?.getServiceProfiles() - ServiceProfile serviceProfile = serviceProfiles.getServiceProfile().get(0) - String serviceProfileId = serviceProfile ? serviceProfile.getProfileId() : "" execution.setVariable("snssai", snssai ?: "") - execution.setVariable("serviceProfileId",serviceProfileId) +// ServiceProfiles serviceProfiles = si.get()?.getServiceProfiles() +// ServiceProfile serviceProfile = serviceProfiles.getServiceProfile().get(0) +// String serviceProfileId = serviceProfile ? serviceProfile.getProfileId() : "" +// execution.setVariable("serviceProfileId", serviceProfileId) List<ServiceInstance> sliceProfileList = [] List<Relationship> relationshipList = si.get().getRelationshipList().getRelationship() for (Relationship relationship : relationshipList) { @@ -127,7 +128,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { Optional<ServiceInstance> serviceInstance = wrapper1.asBean(ServiceInstance.class) if (serviceInstance.isPresent()) { ServiceInstance instance = serviceInstance.get() - if ("slice-profile-instance".equalsIgnoreCase(instance.getServiceRole())) { + if ("slice-profile".equalsIgnoreCase(instance.getServiceRole())) { sliceProfileList.add(instance) } } @@ -158,7 +159,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { try { String errorMsg = "query allotted resource from aai failed." - AAIResultWrapper wrapper = queryAAI(execution, Types.ALLOTTED_RESOURCES, serviceInstanceId, errorMsg) + AAIResultWrapper wrapper = queryAAI(execution, Types.ALLOTTED_RESOURCE, serviceInstanceId, errorMsg) Optional<AllottedResources> ars = wrapper?.asBean(AllottedResources.class) if(ars.isPresent() && ars.get().getAllottedResource()) { @@ -190,13 +191,27 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { { LOGGER.trace(" *****${PREFIX} Start getNSIFromAAI *****") String nsiId = execution.getVariable("nsiId") + List<String> nssiIdList = getNSSIIdList(execution, nsiId) + String msg = "nsiId: ${nsiId}, nssiIdList:" + msg+= nssiIdList.join(",") + LOGGER.info(msg) + execution.setVariable("nssiIdList", nssiIdList) + LOGGER.trace(" *****${PREFIX} Exit getNSIFromAAI *****") + } + /** + * Get NSSI Id from AAI + * @param execution + * @param nsiId + * @return + */ + private List<String> getNSSIIdList(DelegateExecution execution, String nsiId){ + List<String> nssiIdList = [] + try { - String errorMsg = "query nsi from aai failed." + String errorMsg = "query nssi from aai failed." AAIResultWrapper wrapper = queryAAI(execution, Types.SERVICE_INSTANCE, nsiId, errorMsg) - Optional<ServiceInstance> si =wrapper.asBean(ServiceInstance.class) - List<String> nssiIdList = [] - String msg = "nsiId:${nsiId},nssiIdList:" + Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) if(si.isPresent()) { List<Relationship> relationshipList = si.get().getRelationshipList()?.getRelationship() @@ -209,19 +224,17 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { String instanceId = relatedLink ? relatedLink.substring(relatedLink.lastIndexOf("/") + 1,relatedLink.length()) : "" AAIResultWrapper wrapper1 = queryAAI(execution, Types.SERVICE_INSTANCE, instanceId, errorMsg) Optional<ServiceInstance> serviceInstance = wrapper1.asBean(ServiceInstance.class) + def nssiId if (serviceInstance.isPresent()) { ServiceInstance instance = serviceInstance.get() if ("nssi".equalsIgnoreCase(instance.getServiceRole())) { nssiId = instance.getServiceInstanceId() + nssiIdList.add(nssiId) } } - nssiIdList.add(nssiId) - msg+="${nssiId}, " } } } - LOGGER.info(msg) - execution.setVariable("nssiIdList", nssiIdList) } catch(BpmnError e){ throw e @@ -231,7 +244,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { LOGGER.error(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - LOGGER.trace(" *****${PREFIX} Exit getNSIFromAAI *****") + return nssiIdList } /** @@ -274,14 +287,39 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { List<ServiceInstance> nssiInstanceList = execution.getVariable("nssiInstanceList") List<ServiceInstance> sliceProfileList = execution.getVariable("sliceProfileList") int currentIndex = execution.getVariable("currentNSSIIndex") as int - String profileId = "" + String profileInstId = "" ServiceInstance nssi = nssiInstanceList?.get(currentIndex) + List<Relationship> relationshipList = nssi.getRelationshipList()?.getRelationship() for(ServiceInstance sliceProfileInstance : sliceProfileList) { - if(sliceProfileInstance.getWorkloadContext().equalsIgnoreCase(nssi.getWorkloadContext())) - { - profileId = sliceProfileInstance.getServiceInstanceId() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo == "service-instance"){ + String relatedLink = relationship.getRelatedLink()?:"" + String instanceId = relatedLink ? relatedLink.substring(relatedLink.lastIndexOf("/") + 1,relatedLink.length()) : "" + if(instanceId.equals(sliceProfileInstance.getServiceInstanceId())){ + profileInstId = sliceProfileInstance.getServiceInstanceId() + break + } + } + } + if(profileInstId){ + break } } + + //@TODO Temp begin******************* +// AAIPluralResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("serviceType")).serviceInstance(profileInstId).sliceProfiles()) +// AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) +// Optional<SliceProfiles> sliceProfilesOpt =wrapper.asBean(SliceProfiles.class) +// SliceProfiles sliceProfiles +// String sliceProfileId +// if(sliceProfilesOpt.isPresent()){ +// sliceProfiles = sliceProfilesOpt.get() +// org.onap.aai.domain.yang.SliceProfile sliceProfile = sliceProfiles.getSliceProfile().get(0) +// sliceProfileId = sliceProfile ? sliceProfile.getProfileId() : "" +// } + //@TODO Temp end******************* + def currentNSSI = [:] currentNSSI['nssiServiceInstanceId'] = nssi?.getServiceInstanceId() currentNSSI['modelInvariantId'] = nssi?.getModelInvariantId() @@ -289,7 +327,10 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { currentNSSI['nssiName'] = nssi?.getServiceInstanceName() currentNSSI['sST'] = nssi?.getServiceType() currentNSSI['PLMNIdList'] = nssi?.getServiceInstanceLocationId() - currentNSSI['profileId'] = profileId + //@TODO Temp + + currentNSSI['profileId'] = profileInstId +// currentNSSI['profileId'] = sliceProfileId currentNSSI['snssai'] = execution.getVariable("snssai") ?: "" currentNSSI['nsiServiceInstanceId'] = execution.getVariable("nsiId") ?: "" currentNSSI['operationId'] = execution.getVariable("operationId") ?: "" @@ -343,7 +384,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { org.onap.aaiclient.client.generated.fluentbuilders.ServiceInstance serviceInstanceType = AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(instanceId) def type - if (aaiObjectName == Types.ALLOTTED_RESOURCES) { + if (aaiObjectName == Types.ALLOTTED_RESOURCE) { type = serviceInstanceType.allottedResources() } else if (aaiObjectName == Types.SLICE_PROFILES) { type = serviceInstanceType.sliceProfiles() @@ -361,8 +402,11 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { void terminateNSIQuery(DelegateExecution execution) { - logger.debug("Start terminateNSIQuery") - + LOGGER.debug("Start terminateNSIQuery") + + return + + //To test String requestId = execution.getVariable("msoRequestId") String nxlId = currentNSSI['nsiServiceInstanceId'] String nxlType = "NSI" @@ -375,17 +419,17 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { String basicAuthValue = utils.encrypt(basicAuth, msokey) if (basicAuthValue != null) { - logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue) + LOGGER.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue) try { authHeader = utils.getBasicAuth(basicAuthValue, msokey) execution.setVariable("BasicAuthHeaderValue", authHeader) } catch (Exception ex) { - logger.debug( "Unable to encode username and password string: " + ex) + LOGGER.debug( "Unable to encode username and password string: " + ex) exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " + "encode username and password string") } } else { - logger.debug( "Unable to obtain BasicAuth - BasicAuth value null") + LOGGER.debug( "Unable to obtain BasicAuth - BasicAuth value null") exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " + "value null") } @@ -397,7 +441,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { Response httpResponse = httpClient.post(oofRequest) int responseCode = httpResponse.getStatus() - logger.debug("OOF sync response code is: " + responseCode) + LOGGER.debug("OOF sync response code is: " + responseCode) if(responseCode != 200){ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") @@ -407,9 +451,31 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { boolean terminateResponse = resMap.get("terminateResponse") execution.setVariable("terminateNSI", terminateResponse) } catch (Exception ex) { - logger.debug( "Failed to get terminate Response suggested by OOF.") + LOGGER.debug( "Failed to get terminate Response suggested by OOF.") exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Failed to get terminate Response suggested by OOF.") } - logger.debug("Finish terminateNSIQuery") + LOGGER.debug("Finish terminateNSIQuery") + } + + + /** + * If no nssi,delete NSI from AAI + * @param execution + */ + void deleteNSIInstance(DelegateExecution execution){ + def currentNSSI = execution.getVariable("currentNSSI") + def nsiId = currentNSSI['nsiServiceInstanceId'] + List<String> nssiIdList = getNSSIIdList(execution, nsiId) + try + { + if(0 == nssiIdList.size()){ + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("serviceType")).serviceInstance(nsiId)) + getAAIClient().delete(serviceInstanceUri) + } + } catch (Exception ex) { + LOGGER.debug( "Failed to delete NSI instance.") + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Failed to delete NSI instance.") + } + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy index f591855b5c..982771f681 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy @@ -549,7 +549,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { updateStatus.setResourceTemplateUUID(nsiId) updateStatus.setResourceInstanceID(nssiId) updateStatus.setOperType("Modify") - updateStatus.setProgress(100) + updateStatus.setProgress("100") updateStatus.setStatus("finished") requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus) @@ -571,7 +571,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { updateStatus.setResourceTemplateUUID(nsiId) updateStatus.setResourceInstanceID(nssiId) updateStatus.setOperType("Modify") - updateStatus.setProgress(0) + updateStatus.setProgress("0") updateStatus.setStatus("failed") requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus) } @@ -652,4 +652,4 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { logger.debug("Error occured within deleteServiceInstance method: " + e) } } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy index 6fdfbe3218..e0df9ea64b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy @@ -29,7 +29,8 @@ import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils import com.fasterxml.jackson.databind.ObjectMapper import com.google.gson.JsonObject -import java.sql.Timestamp +import com.google.gson.JsonParser +import java.time.Instant import static org.apache.commons.lang3.StringUtils.isBlank import org.onap.so.bpmn.core.UrnPropertiesReader @@ -75,7 +76,7 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { execution.setVariable("sliceProfile", sliceProfile) break case "reconfigure": - String resourceConfig = execution.getVariable("additionalProperties") + String resourceConfig = execution.getVariable("additionalProperties") execution.setVariable("resourceConfig", resourceConfig) break default: @@ -83,7 +84,7 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Invalid modify Action : "+modifyAction) } } - List<String> snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class) + List<String> snssaiList = execution.getVariable("snssaiList") String sliceProfileId = execution.getVariable("sliceProfileId") if (isBlank(sliceProfileId) || (snssaiList.empty)) { msg = "Mandatory fields are empty" @@ -109,7 +110,7 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { logger.debug(Prefix+"createSdnrRequest method start") String callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.message.endpoint") + "/AsyncSdnrResponse/"+execution.getVariable("msoRequestId") String modifyAction = execution.getVariable("modifyAction") - String sdnrRequest = buildSdnrAllocateRequest(execution, modifyAction, "InstantiateRANSlice", callbackUrl) + String sdnrRequest = buildSdnrAllocateRequest(execution, modifyAction, "instantiateRANSlice", callbackUrl) execution.setVariable("createNSSI_sdnrRequest", sdnrRequest) execution.setVariable("createNSSI_timeout", "PT10M") execution.setVariable("createNSSI_correlator", execution.getVariable("msoRequestId")) @@ -123,6 +124,7 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { if(status.equalsIgnoreCase("success")) { String nfIds = jsonUtil.getJsonValue(SDNRResponse, "nfIds") execution.setVariable("ranNfIdsJson", nfIds) + execution.setVariable("ranNfStatus", status) }else { String reason = jsonUtil.getJsonValue(SDNRResponse, "reason") logger.error("received failed status from SDNR "+ reason) @@ -134,53 +136,47 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { private String buildSdnrAllocateRequest(DelegateExecution execution, String action, String rpcName, String callbackUrl) { String requestId = execution.getVariable("msoRequestId") - Date date = new Date().getTime() - Timestamp time = new Timestamp(date) - String sliceProfileString + Instant time = Instant.now() + Map<String,Object> sliceProfile = new HashMap<>() JsonObject response = new JsonObject() JsonObject body = new JsonObject() JsonObject input = new JsonObject() JsonObject commonHeader = new JsonObject() JsonObject payload = new JsonObject() JsonObject payloadInput = new JsonObject() + JsonParser parser = new JsonParser() if(action.equals("allocate")) { - Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class) + sliceProfile = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class) sliceProfile.put("sliceProfileId", execution.getVariable("sliceProfileId")) sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSessions")) sliceProfile.put("uLThptPerSlice", sliceProfile.get("expDataRateUL")) sliceProfile.put("dLThptPerSlice", sliceProfile.get("expDataRateDL")) - sliceProfileString = objectMapper.writeValueAsString(sliceProfile) action = "modify-"+action payloadInput.add("additionalproperties", new JsonObject()) }else if(action.equals("deallocate")) { action = "modify-"+action - Map<String,Object> sliceProfile = new HashMap<>() sliceProfile.put("sliceProfileId", execution.getVariable("sliceProfileId")) sliceProfile.put("sNSSAI", execution.getVariable("snssai")) - sliceProfileString = objectMapper.writeValueAsString(sliceProfile) payloadInput.add("additionalproperties", new JsonObject()) }else if(action.equals("reconfigure")) { - Map<String,Object> sliceProfile = new HashMap<>() sliceProfile.put("sliceProfileId", execution.getVariable("sliceProfileId")) sliceProfile.put("sNSSAI", execution.getVariable("snssai")) - sliceProfileString = objectMapper.writeValueAsString(sliceProfile) JsonObject resourceconfig = new JsonObject() - resourceconfig.addProperty("resourceConfig", execution.getVariable("resourceConfig")) + resourceconfig.add("resourceConfig", (JsonObject) parser.parse(execution.getVariable("resourceConfig"))) payloadInput.add("additionalproperties", resourceconfig) } - commonHeader.addProperty("TimeStamp", time.toString()) - commonHeader.addProperty("APIver", "1.0") - commonHeader.addProperty("RequestID", requestId) - commonHeader.addProperty("SubRequestID", "1") - commonHeader.add("RequestTrack", new JsonObject()) - commonHeader.add("Flags", new JsonObject()) - payloadInput.addProperty("sliceProfile", sliceProfileString) + commonHeader.addProperty("timestamp", time.toString()) + commonHeader.addProperty("api-ver", "1.0") + commonHeader.addProperty("request-id", requestId) + commonHeader.addProperty("sub-request-id", "1") + commonHeader.add("flags", new JsonObject()) + payloadInput.addProperty("sliceProfile", sliceProfile.toString()) payloadInput.addProperty("RANNFNSSIId", execution.getVariable("serviceInstanceID")) payloadInput.addProperty("callbackURL", callbackUrl) payload.add("input", payloadInput) - input.add("CommonHeader", commonHeader) - input.addProperty("Action", action) - input.add("Payload", payload) + input.add("common-header", commonHeader) + input.addProperty("action", action) + input.addProperty("payload", payload.toString()) body.add("input", input) response.add("body", body) response.addProperty("version", "1.0") @@ -190,4 +186,4 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { return response.toString() } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy deleted file mode 100644 index a85f5d8ab3..0000000000 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy +++ /dev/null @@ -1,423 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2019, CMCC Technologies Co., Ltd. - # - # 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 com.fasterxml.jackson.databind.ObjectMapper -import com.google.gson.Gson -import com.google.gson.reflect.TypeToken -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.beans.nsmf.* -import org.onap.so.bpmn.common.scripts.* -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.core.domain.ServiceArtifact -import org.onap.so.bpmn.core.domain.ServiceDecomposition -import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.logging.filter.base.ErrorCode -import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.MessageEnum -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import org.springframework.web.util.UriUtils - -import java.lang.reflect.Type - -/** - * This class supports the DoCreateVnf building block subflow - * with the creation of a generic vnf for - * infrastructure. - * - */ -class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { - - private static final Logger logger = LoggerFactory.getLogger( DoSendCommandToNSSMF.class); - String Prefix="DoCNSSMF_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils(this) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - - private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) - - /** - * This method gets and validates the incoming - * request. - * - * @param - execution - * - */ - public void preProcessRequest(DelegateExecution execution) { - - execution.setVariable("prefix",Prefix) - logger.debug("STARTED Do sendcommandtoNssmf PreProcessRequest Process") - - /*******************/ - try{ - // Get Variables - String e2eserviceInstanceId = execution.getVariable("e2eserviceInstanceId") - String serviceInstanceId = execution.getVariable("e2eserviceInstanceId") - execution.setVariable("e2eserviceInstanceId", e2eserviceInstanceId) - execution.setVariable("serviceInstanceId", serviceInstanceId) - logger.debug("Incoming e2eserviceInstanceId is: " + e2eserviceInstanceId) - - String NSIserviceid = execution.getVariable("NSIserviceid") - execution.setVariable("NSIserviceid", NSIserviceid) - logger.debug("Incoming NSI id is: " + NSIserviceid) - - - String nssiMap = execution.getVariable("nssiMap") - Type type = new TypeToken<HashMap<String, NSSI>>(){}.getType() - Map<String, NSSI> DonssiMap = new Gson().fromJson(nssiMap,type) - String strDonssiMap = mapToJsonStr(DonssiMap) - execution.setVariable("DonssiMap",strDonssiMap) - logger.debug("Incoming DonssiMap is: " + strDonssiMap) - - String requestId = execution.getVariable("msoRequestId") - execution.setVariable("msoRequestId", requestId) - - String operationType = execution.getVariable("operationType") - execution.setVariable("operationType", operationType.toLowerCase()) - logger.debug("Incoming operationType is: " + operationType) - - if (operationType == "activation") { - execution.setVariable("activationSequence","an,tn,cn") - }else { - execution.setVariable("activationSequence","cn,tn,an") - } - execution.setVariable("activationIndex",0) - execution.setVariable("miniute", "0") - execution.setVariable("activateNumberSlice",0) - - logger.info("the end !!") - }catch(BpmnError b){ - logger.debug("Rethrowing MSOWorkflowException") - throw b - }catch(Exception e){ - logger.info("the end of catch !!") - logger.debug(" Error Occured in DoSendCommandToNSSMF PreProcessRequest method!" + e.getMessage()) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoSendCommandToNSSMF PreProcessRequest") - - } - logger.trace("COMPLETED DoSendCommandToNSSMF PreProcessRequest Process") - } - - private String mapToJsonStr(Map<String, NSSI> stringNSSIHashMap) { - HashMap<String, NSSI> map = new HashMap<String, NSSI>() - for(Map.Entry<String, NSSI> child:stringNSSIHashMap.entrySet()) - { - map.put(child.getKey(), child.getValue()) - } - return new Gson().toJson(map) - } - - public void getNSSIformlist(DelegateExecution execution) { - - String nssiMap = execution.getVariable("DonssiMap") - Type type = new TypeToken<HashMap<String, NSSI>>(){}.getType() - Map<String, NSSI> DonssiMap = new Gson().fromJson(nssiMap,type) - String isNSSIActivate = execution.getVariable("isNSSIActivate") - - String activationSequence01 = execution.getVariable("activationSequence") - String[] strlist = activationSequence01.split(",") - - int activationIndex = execution.getVariable("activationIndex") - int indexcurrent = 0 - if (isNSSIActivate == "true") - { - execution.setVariable("isGetSuccessfull", "false") - }else{for (int index = activationIndex; index < 3;index++) { - String domaintype01 = strlist[index] - if (DonssiMap.containsKey(domaintype01)) { - NSSI nssiobject = DonssiMap.get(domaintype01) - execution.setVariable("domainType", domaintype01) - execution.setVariable("nssiId", nssiobject.getNssiId()) - execution.setVariable("modelInvariantUuid", nssiobject.getModelInvariantId()) - execution.setVariable("modelUuid", nssiobject.getModelVersionId()) - execution.setVariable("isGetSuccessfull", "true") - String modelInvariantUuid = execution.getVariable("modelInvariantUuid") - String modelUuid = execution.getVariable("modelUuid") - //here modelVersion is not set, we use modelUuid to decompose the service. - String serviceModelInfo = """{ - "modelInvariantUuid":"${modelInvariantUuid}", - "modelUuid":"${modelUuid}", - "modelVersion":"" - }""" - execution.setVariable("serviceModelInfo", serviceModelInfo) - indexcurrent = index - execution.setVariable("activationIndex", indexcurrent) - break - }else - { - indexcurrent = index + 1 - - } - } - if ( activationIndex > 2) { - execution.setVariable("isGetSuccessfull", "false") - } - execution.setVariable("activationIndex", indexcurrent)} - - } - - /** - * get vendor Info - * @param execution - */ - private void processDecomposition(DelegateExecution execution) { - logger.debug("***** processDecomposition *****") - - try { - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") as ServiceDecomposition - ServiceArtifact serviceArtifact = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0) - String content = serviceArtifact.getContent() - String vendor = jsonUtil.getJsonValue(content, "metadata.vendor") - //String domainType = jsonUtil.getJsonValue(content, "metadata.domainType") - - execution.setVariable("vendor", vendor) - // currentNSSI['domainType'] = domainType - logger.info("processDecomposition, current vendor-domainType:" + vendor) - - } catch (any) { - String exceptionMessage = "Bpmn error encountered in deallocate nssi. processDecomposition() - " + any.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - logger.debug("***** Exit processDecomposition *****") - } - - public void UpdateIndex(DelegateExecution execution) { - def activationIndex = execution.getVariable("activationIndex") - int activateNumberSlice = execution.getVariable("activateNumberSlice") as Integer - def activationCount= execution.getVariable("activationCount") - //DecimalFormat df1 = new DecimalFormat("##%") - int rate = (activateNumberSlice / activationCount) * 100 - if (rate == 100) - { - execution.setVariable("isNSSIActivate","true") - } - else{ - execution.setVariable("isNSSIActivate","false") - } - activationIndex = activationIndex + 1 - execution.setVariable("activationIndex",activationIndex) - logger.trace("the Progress of activation is " + rate.toString() + "%" ) - try{ - String serviceId = execution.getVariable("serviceInstanceId") - String operationId = UUID.randomUUID().toString() - String operationType = execution.getVariable("operationType") - String userId = "" - String result = (operationType.equalsIgnoreCase("activation"))? "ACTIVATING": "DEACTIVATING" - int progress = rate - String reason = "" - String operationContent = "Service activation in progress" - logger.debug("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId) - serviceId = UriUtils.encode(serviceId,"UTF-8") - execution.setVariable("e2eserviceInstanceId", serviceId) - execution.setVariable("operationId", operationId) - execution.setVariable("operationType", operationType) - - def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint",execution) - execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) - logger.debug("DB Adapter Endpoint is: " + dbAdapterEndpoint) - - String payload = - """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:ns="http://org.onap.so/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <ns:initServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb"> - <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId> - <operationId>${MsoUtils.xmlEscape(operationId)}</operationId> - <operationType>${MsoUtils.xmlEscape(operationType)}</operationType> - <userId>${MsoUtils.xmlEscape(userId)}</userId> - <result>${MsoUtils.xmlEscape(result)}</result> - <operationContent>${MsoUtils.xmlEscape(operationContent)}</operationContent> - <progress>${MsoUtils.xmlEscape(progress)}</progress> - <reason>${MsoUtils.xmlEscape(reason)}</reason> - </ns:initServiceOperationStatus> - </soapenv:Body> - </soapenv:Envelope>""" - - payload = utils.formatXml(payload) - execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload) - logger.debug("Outgoing CVFMI_updateServiceOperStatusRequest: \n" + payload) - - }catch(Exception e){ - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - "Exception Occured Processing Activate Slice .", "BPMN", - ErrorCode.UnknownError.getValue(), "Exception is:\n" + e) - execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during Activate Slice Method:\n" + e.getMessage()) - } - logger.trace("finished Activate Slice") - } - - public void WaitForReturn(DelegateExecution execution) { - //logger.debug("Query : "+ Jobid) - String miniute = execution.getVariable("miniute") - Thread.sleep(10000) - int miniute01 = Integer.parseInt(miniute) + 1 - logger.debug("waiting for : "+ miniute + "miniutes") - execution.setVariable("miniute", String.valueOf(miniute01)) - } - - public void GetTheStatusOfActivation(DelegateExecution execution) { - - String domaintype = execution.getVariable("domainType") - String NSIserviceid=execution.getVariable("NSIserviceid") - String nssiId = execution.getVariable("nssiId") - String Jobid=execution.getVariable("JobId") - String miniute=execution.getVariable("miniute") - String vendor = execution.getVariable("vendor") - String jobstatus - - - logger.debug("Query the jobid activation of SNSSAI: "+ Jobid) - logger.debug("the domain is : "+ domaintype) - logger.debug("the NSSID is : "+nssiId) - logger.debug("the NSIserviceid is : "+NSIserviceid) - - JobStatusRequest jobStatusRequest = new JobStatusRequest() - - EsrInfo info = new EsrInfo() - info.setNetworkType(NetworkType.fromString(domaintype)) - info.setVendor(vendor) - - jobStatusRequest.setNsiId(NSIserviceid) - jobStatusRequest.setNssiId(nssiId) - jobStatusRequest.setEsrInfo(info) - - - ObjectMapper mapper = new ObjectMapper() - String nssmfRequest = mapper.writeValueAsString(jobStatusRequest) - String isActivateSuccessfull - - String urlString = "/api/rest/provMns/v1/NSS/jobs/" +Jobid - - JobStatusResponse jobStatusResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest, JobStatusResponse.class) - - if (jobStatusResponse != null) { - execution.setVariable("statusDescription", jobStatusResponse.getResponseDescriptor().getStatusDescription()) - jobstatus = jobStatusResponse.getResponseDescriptor().getStatus() - switch(jobstatus) { - case "started": - case "processing": - isActivateSuccessfull = "waitting" - execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) - break - case "finished": - isActivateSuccessfull = "true" - execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) - execution.setVariable("activateNumberSlice",execution.getVariable("activateNumberSlice")+ 1) - break - case "error": - default: - isActivateSuccessfull = "false" - execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) - - } - if(Integer.parseInt(miniute) > 6 ) - { - isActivateSuccessfull = "false" - execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a timeout job status Response from NSSMF.") - } - } else { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad job status Response from NSSMF.") - isActivateSuccessfull = false - execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) - } - } - - public void SendCommandToNssmf(DelegateExecution execution) { - - String snssai= execution.getVariable("snssai") - String domaintype = execution.getVariable("domainType") - String NSIserviceid=execution.getVariable("NSIserviceid") - String nssiId = execution.getVariable("nssiId") - String vendor = execution.getVariable("vendor") - - - logger.debug("the domain is : "+domaintype) - logger.debug("SNSSAI: "+snssai +" will be activated") - logger.debug("the NSSID is : "+nssiId) - logger.debug("the NSIserviceid is : "+NSIserviceid) - - EsrInfo esr = new EsrInfo(); - esr.setNetworkType(NetworkType.fromString(domaintype)) - esr.setVendor(vendor) - - ActDeActNssi actNssi = new ActDeActNssi(); - actNssi.setNsiId(NSIserviceid); - actNssi.setNssiId(nssiId); - NssiActDeActRequest actRequest = new NssiActDeActRequest(); - actRequest.setActDeActNssi(actNssi); - actRequest.setEsrInfo(esr) - - ObjectMapper mapper = new ObjectMapper() - String nssmfRequest = mapper.writeValueAsString(actRequest) - - String operationType = execution.getVariable("operationType") - - String urlString = "/api/rest/provMns/v1/NSS/" + snssai + "/" + operationType.toLowerCase() - - NssiResponse nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest, NssiResponse.class) - - if (nssmfResponse != null) { - String isNSSIActivated = "true" - execution.setVariable("isNSSIActivated", isNSSIActivated) - String jobId = nssmfResponse.getJobId() ?: "" - execution.setVariable("JobId", jobId) - } else { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.") - String isNSSIActivated = "false" - execution.setVariable("isNSSIActivated", isNSSIActivated) - execution.setVariable("isNSSIActivate","false") - } - - } - - void sendSyncError (DelegateExecution execution) { - logger.trace("start sendSyncError") - try { - String errorMessage = "" - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - WorkflowException wfe = execution.getVariable("WorkflowException") - errorMessage = wfe.getErrorMessage() - } else { - errorMessage = "Sending Sync Error." - } - - String buildworkflowException = - """<aetgt:WorkflowException xmlns:aetgt="http://org.onap/so/workflow/schema/v1"> - <aetgt:ErrorMessage>${MsoUtils.xmlEscape(errorMessage)}</aetgt:ErrorMessage> - <aetgt:ErrorCode>7000</aetgt:ErrorCode> - </aetgt:WorkflowException>""" - - logger.debug(buildworkflowException) - sendWorkflowResponse(execution, 500, buildworkflowException) - - } catch (Exception ex) { - logger.debug("Sending Sync Error Activity Failed. " + "\n" + ex.getMessage()) - } - logger.trace("finished sendSyncError") - } -} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/QueryJobStatus.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/QueryJobStatus.groovy index 5cdf540173..74c9a49911 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/QueryJobStatus.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/QueryJobStatus.groovy @@ -20,9 +20,11 @@ package org.onap.so.bpmn.infrastructure.scripts +import com.fasterxml.jackson.databind.ObjectMapper import groovy.json.JsonSlurper import org.json.JSONObject import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.beans.nsmf.JobStatusRequest import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils @@ -43,16 +45,15 @@ public class QueryJobStatus extends AbstractServiceTaskProcessor{ try{ String requestId = execution.getVariable("msoRequestId") logger.debug("RequestId :" + requestId) - String responseId = execution.getVariable("responseId") - String jobId = execution.getVariable("jobId") + String jobId = execution.getVariable("jobId") def jsonSlurper = new JsonSlurper() - HashMap<String,?> esrInfo=jsonSlurper.parseText(execution.getVariable("esrInfo")) + HashMap<String,?> esrInfo = jsonSlurper.parseText(execution.getVariable("esrInfo")) logger.debug("esrInfo" + esrInfo.toString()) - HashMap<String,?> serviceInfo=jsonSlurper.parseText(execution.getVariable("serviceInfo")) + HashMap<String,?> serviceInfo = jsonSlurper.parseText(execution.getVariable("serviceInfo")) logger.debug("serviceInfo" + serviceInfo.toString()) - + execution.setVariable("esrInfo", esrInfo) execution.setVariable("serviceInfo", serviceInfo) @@ -60,10 +61,9 @@ public class QueryJobStatus extends AbstractServiceTaskProcessor{ String endPoint = String.format("/api/rest/provMns/v1/NSS/jobs/%s", jobId) String url = nssmfEndpoint + endPoint execution.setVariable("NSSMF_AdapterEndpoint", url) - + String payload = """ { - "responseId": "${responseId}", "esrInfo": ${execution.getVariable("esrInfo") as JSONObject}, "serviceInfo": ${execution.getVariable("serviceInfo") as JSONObject} } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ServiceLevelUpgrade.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ServiceLevelUpgrade.groovy new file mode 100644 index 0000000000..15f44ce03c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ServiceLevelUpgrade.groovy @@ -0,0 +1,126 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * 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.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.workflow.context.WorkflowContext +import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder +import org.onap.so.bpmn.core.WorkflowException +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_ID + +class ServiceLevelUpgrade extends AbstractServiceTaskProcessor { + private static final Logger logger = LoggerFactory.getLogger(ServiceLevelUpgrade.class) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + String prefix = "ServiceLevelUpgrade_" + + @Override + void preProcessRequest(DelegateExecution execution) { + } + + void sendResponse(DelegateExecution execution) { + def requestId = execution.getVariable(REQUEST_ID) + def instanceId = execution.getVariable(PNF_CORRELATION_ID) + logger.debug("Send response for requestId: {}, instanceId: {}", requestId, instanceId) + + String response = """{"requestReferences":{"requestId":"${requestId}", "instanceId":"${instanceId}"}}""".trim() + sendWorkflowResponse(execution, 200, response) + } + + static WorkflowContext getWorkflowContext(DelegateExecution execution) { + String requestId = execution.getVariable(REQUEST_ID) + return WorkflowContextHolder.getInstance().getWorkflowContext(requestId) + } + + void prepareCompletion(DelegateExecution execution) { + try { + String requestId = execution.getVariable(REQUEST_ID) + logger.debug("Prepare Completion of Service Level Upgrade for requestId: {}", requestId) + + String msoCompletionRequest = + """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" + xmlns:ns="http://org.onap/so/request/types/v1"> + <request-info xmlns="http://org.onap/so/infra/vnf-request/v1"> + <request-id>${MsoUtils.xmlEscape(requestId)}</request-id> + <action>UPDATE</action> + <source>VID</source> + </request-info> + <aetgt:status-message>Service Level Upgrade successful.</aetgt:status-message> + <aetgt:mso-bpel-name>SERVICE_LEVEL_UPGRADE</aetgt:mso-bpel-name> + </aetgt:MsoCompletionRequest>""" + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + execution.setVariable(prefix + "CompleteMsoProcessRequest", xmlMsoCompletionRequest) + + logger.debug("CompleteMsoProcessRequest of Service Level Upgrade - " + "\n" + xmlMsoCompletionRequest) + } catch (Exception e) { + String msg = "Prepare Completion error for Service Level Upgrade - " + e.getMessage() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + } + + void prepareFalloutHandler(DelegateExecution execution) { + WorkflowContext workflowContext = getWorkflowContext(execution) + if (workflowContext == null) { + logger.debug("Error occurred before sending response to API handler, and send it now") + sendResponse(execution) + } + + try { + String requestId = execution.getVariable(REQUEST_ID) + logger.debug("Prepare FalloutHandler of Service Level Upgrade for requestId: {}", requestId) + + WorkflowException workflowException = (WorkflowException)execution.getVariable("WorkflowException") + String errorCode = String.valueOf(workflowException.getErrorCode()) + String errorMessage = workflowException.getErrorMessage() + String falloutHandlerRequest = + """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" + xmlns:ns="http://org.onap/so/request/types/v1"> + <request-info xmlns="http://org.onap/so/infra/vnf-request/v1"> + <request-id>${MsoUtils.xmlEscape(requestId)}</request-id> + <action>UPDATE</action> + <source>VID</source> + </request-info> + <aetgt:WorkflowException xmlns:aetgt="http://org.onap/so/workflow/schema/v1"> + <aetgt:ErrorMessage>${MsoUtils.xmlEscape(errorMessage)}</aetgt:ErrorMessage> + <aetgt:ErrorCode>${MsoUtils.xmlEscape(errorCode)}</aetgt:ErrorCode> + </aetgt:WorkflowException> + </aetgt:FalloutHandlerRequest>""" + String xmlFalloutHandlerRequest = utils.formatXml(falloutHandlerRequest) + + execution.setVariable(prefix + "FalloutHandlerRequest", xmlFalloutHandlerRequest) + + logger.debug("FalloutHandlerRequest of Service Level Upgrade - " + "\n" + xmlFalloutHandlerRequest) + } catch (Exception e) { + String msg = "Prepare FalloutHandler error for Service Level upgrade - " + e.getMessage() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy index 8a276ed330..deeec94b74 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy @@ -72,7 +72,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { String additionalPropJsonStr = execution.getVariable("sliceParams") - String tnNssiId = execution.getVariable("serviceInstanceID") + String tnNssiId = jsonUtil.getJsonValue(additionalPropJsonStr, "serviceInstanceID") //for debug if (isBlank(tnNssiId)) { tnNssiId = UUID.randomUUID().toString() } @@ -321,17 +321,17 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { String status, String progress, String statusDescription) { - String serviceId = execution.getVariable("dummyServiceId") + String modelUuid = execution.getVariable("modelUuid") String ssInstanceId = execution.getVariable("sliceServiceInstanceId") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") ResourceOperationStatus roStatus = new ResourceOperationStatus() - roStatus.setServiceId(serviceId) + roStatus.setServiceId(nsiId) roStatus.setOperationId(jobId) - roStatus.setResourceTemplateUUID(nsiId) + roStatus.setResourceTemplateUUID(modelUuid) roStatus.setResourceInstanceID(ssInstanceId) - roStatus.setOperType("Allocate") + roStatus.setOperType("ALLOCATE") roStatus.setProgress(progress) roStatus.setStatus(status) roStatus.setStatusDescription(statusDescription) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy index d97f416db9..009b0a1941 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy @@ -32,6 +32,7 @@ import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -122,7 +123,7 @@ class TnNssmfUtils { } String sdncRequest = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1" + """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1"> <sdncadapter:RequestHeader> @@ -332,4 +333,39 @@ class TnNssmfUtils { createRelationShipInAAI(execution, aaiResourceUri, relationship) } + + ResourceOperationStatus buildRoStatus(String nsstId, + String nssiId, + String jobId, + String nsiId, + String action, + String status, + String progress, + String statusDescription) { + ResourceOperationStatus roStatus = new ResourceOperationStatus() + roStatus.setResourceTemplateUUID(nsstId) + roStatus.setResourceInstanceID(nssiId) + roStatus.setServiceId(nsiId) + roStatus.setOperationId(jobId) + roStatus.setOperType(action) + roStatus.setProgress(progress) + roStatus.setStatus(status) + roStatus.setStatusDescription(statusDescription) + + return roStatus + } + + + void setEnableSdncConfig(DelegateExecution execution) { + String enableSdnc = UrnPropertiesReader.getVariable( + "mso.workflow.TnNssmf.enableSDNCNetworkConfig") + if (isBlank(enableSdnc)) { + logger.debug("mso.workflow.TnNssmf.enableSDNCNetworkConfig is undefined, so use default value (true)") + enableSdnc = "true" + } + + logger.debug("setEnableSdncConfig: enableSdnc=" + enableSdnc) + + execution.setVariable("enableSdnc", enableSdnc) + } } 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 6b15407dd0..fa1cef291e 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 @@ -20,7 +20,8 @@ package org.onap.so.bpmn.infrastructure.scripts -import static org.junit.Assert.* +import static org.junit.Assert.assertNotNull +import static org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test @@ -49,14 +50,19 @@ class DoAllocateCoreNonSharedSliceTest extends MsoGroovyTest { @Test public void testPreProcessRequest() { - String networkServiceModelInfo=""" { - "modelName" : "5GC-eMBB Service Proxy", - "modelUuid" : "b666119e-4400-47c6-a0c1-bbe050a33b47", - "modelInvariantUuid" : "a26327e1-4a9b-4883-b7a5-5f37dcb7405a", + String networkServiceModelInfo="""{ + "modelInfo" : { + "modelName" : "vfw_cnf_service_2310 Service Proxy", + "modelUuid" : "35386eb0-b673-48c5-9757-45ecfc506bf8", + "modelInvariantUuid" : "b048d7bc-8bfd-4950-aea5-22b1aaf5d76b", "modelVersion" : "1.0", - "modelCustomizationUuid" : "cbc12c2a-67e6-4336-9236-eaf51eacdc75", - "modelInstanceName" : "5gcembb_proxy 0" - }""" + "modelCustomizationUuid" : "82f4db76-e7ad-47eb-b5e3-661683f14de6", + "modelInstanceName" : "vfw_cnf_service_2310_proxy 0" + }, + "toscaNodeType" : "org.openecomp.nodes.vfw_cnf_service_2310_proxy", + "description" : "A Proxy for Service vfw_cnf_service_2310", + "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}""" @@ -70,10 +76,10 @@ class DoAllocateCoreNonSharedSliceTest extends MsoGroovyTest { Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceModelUuid"), captor.capture()) captor.getValue() - assertEquals("b666119e-4400-47c6-a0c1-bbe050a33b47", captor.getValue()) + assertEquals("f3666c56-744e-4055-9f4a-0726460898e0", captor.getValue()) Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceName"), captor.capture()) - assertEquals("5GC-eMBB", captor.getValue()) + assertEquals("vfw_cnf_service_2310", captor.getValue()) Mockito.verify(mockExecution, times(1)).setVariable(eq("orchestrationStatus"), captor.capture()) assertEquals("created", captor.getValue()) @@ -90,6 +96,7 @@ class DoAllocateCoreNonSharedSliceTest extends MsoGroovyTest { when(mockExecution.getVariable("networkServiceName")).thenReturn("5g_embb") when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") when(mockExecution.getVariable("networkServiceModelUuid")).thenReturn("12345") + when(mockExecution.getVariable("vnfInstanceName")).thenReturn("vf00") DoAllocateCoreNonSharedSlice allocateNssi = new DoAllocateCoreNonSharedSlice() allocateNssi.prepareServiceOrderRequest(mockExecution) @@ -106,7 +113,7 @@ class DoAllocateCoreNonSharedSliceTest extends MsoGroovyTest { Map<String, Object> ServiceCharacteristicValue = new LinkedHashMap<>() Map<String, Object> ServiceCharacteristicValueObject = new LinkedHashMap<>() ServiceCharacteristicValueObject.put("serviceCharacteristicValue","001-100001") - ServiceCharacteristicValue.put("name", "snssai") + ServiceCharacteristicValue.put("name", "vf00_snssai") ServiceCharacteristicValue.put("value", ServiceCharacteristicValueObject) List expectedList= new ArrayList() @@ -116,8 +123,7 @@ class DoAllocateCoreNonSharedSliceTest extends MsoGroovyTest { Map<String, Object> serviceCharacteristic = objectMapper.readValue(sliceProfile, Map.class); DoAllocateCoreNonSharedSlice allocateNssi = new DoAllocateCoreNonSharedSlice() - List characteristicList=allocateNssi.retrieveServiceCharacteristicsAsKeyValue(serviceCharacteristic) - + List characteristicList=allocateNssi.retrieveServiceCharacteristicsAsKeyValue(mockExecution, serviceCharacteristic) assertEquals(expectedList, characteristicList) } }
\ No newline at end of file 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 0ac48ad189..9068692e30 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 @@ -20,6 +20,9 @@ package org.onap.so.bpmn.infrastructure.scripts +import static org.junit.Assert.assertNotNull +import static org.junit.Assert.assertEquals + import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.junit.Before import org.junit.Test @@ -32,7 +35,6 @@ import org.onap.aaiclient.client.aai.entities.AAIResultWrapper import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder -import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import static org.mockito.Mockito.spy import static org.mockito.Mockito.times @@ -91,7 +93,7 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { } @Test - public void tesPrepareSOMacroRequestPayload() { + public void testPrepareSOMacroRequestPayload() { String json ="{ \"serviceResources\" : {\r\n\t\"modelInfo\" : {\r\n\t\t\"modelName\" : \"MSOTADevInfra_vSAMP10a_Service\",\r\n\t\t\"modelUuid\" : \"5df8b6de-2083-11e7-93ae-92361f002671\",\r\n\t\t\"modelInvariantUuid\" : \"9647dfc4-2083-11e7-93ae-92361f002671\",\r\n\t\t\"modelVersion\" : \"1.0\"\r\n\t},\r\n\t\"serviceType\" : \"PortMirroring\",\r\n\t\"serviceRole\" : \"InfraRole\",\r\n\t\"environmentContext\" : \"Luna\",\r\n\t\"workloadContext\" : \"Oxygen\",\r\n\t\"serviceVnfs\": [\r\n\t\r\n\t\t{ \"modelInfo\" : {\r\n\t\t\t\"modelName\" : \"vSAMP10a\",\r\n\t\t\t\"modelUuid\" : \"ff2ae348-214a-11e7-93ae-92361f002671\",\r\n\t\t\t\"modelInvariantUuid\" : \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\t\t\t\"modelVersion\" : \"1.0\",\r\n\t\t\t\"modelCustomizationUuid\" : \"68dc9a92-214c-11e7-93ae-92361f002671\",\r\n\t\t\t\"modelInstanceName\" : \"vSAMP10a 1\"\r\n\t\t\t},\r\n\t\t\"toscaNodeType\" : \"VF\",\r\n\t\t\"nfFunction\" \t: null,\r\n\t\t\"nfType\" \t\t: null,\r\n\t\t\"nfRole\" \t\t: null,\r\n\t\t\"nfNamingCode\" \t: null,\r\n\t\t\"multiStageDesign\"\t\t: null,\r\n\t\t\t\"vfModules\": [\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"NetworkFqdnTest4\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"025606c1-4223-11e7-9252-005056850d2e\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : \"06bd0a18-65c0-4418-83c7-5b0d13cba01a\",\r\n\t\t\t\t\t\t\"modelVersion\" : \"2.0\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"06bd0a18-65c0-4418-83c7-5b0d13cba01a\"\r\n\t\t\t\t\t},\t\t\"isBase\" : true,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"label\",\r\n\t\t\t\t\t\"initialCount\" : 0,\r\n\t\t\t\t\t\"hasVolumeGroup\" : true\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"NetworkFqdnTest3\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"02560575-4223-11e7-9252-005056850d2e\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : \"06bd0a18-65c0-4418-83c7-5b0d13cba0bb\",\r\n\t\t\t\t\t\t\"modelVersion\" : \"1.0\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"06bd0a18-65c0-4418-83c7-5b0d13cba0bb\"\r\n\t\t\t\t\t},\t\t\"isBase\" : true,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"label\",\r\n\t\t\t\t\t\"initialCount\" : 0,\r\n\t\t\t\t\t\"hasVolumeGroup\" : false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"NetworkFqdnTest5\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"025607e4-4223-11e7-9252-005056850d2e\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : \"06bd0a18-65c0-4418-83c7-5b0d14cba01a\",\r\n\t\t\t\t\t\t\"modelVersion\" : \"1.0\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"06bd0a18-65c0-4418-83c7-5b0d14cba01a\"\r\n\t\t\t\t\t},\t\t\"isBase\" : false,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"label\",\r\n\t\t\t\t\t\"initialCount\" : 0,\r\n\t\t\t\t\t\"hasVolumeGroup\" : false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"vSAMP10aDEV::PCM::module-2\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"7774b4e4-7d37-11e7-bb31-be2e44b06b34\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : \"93e9c1d2-7d37-11e7-bb31-be2e44b06b34\",\r\n\t\t\t\t\t\t\"modelVersion\" : \"2\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"6728bee8-7d3a-11e7-bb31-be2e44b06b34\"\r\n\t\t\t\t\t},\t\t\"isBase\" : false,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"PCM\",\r\n\t\t\t\t\t\"initialCount\" : 0,\r\n\t\t\t\t\t\"hasVolumeGroup\" : true\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"vSAMP10aDEV::PCM::module-1\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"066de97e-253e-11e7-93ae-92361f002671\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\t\t\t\t\t\t\"modelVersion\" : \"2\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"b4ea86b4-253f-11e7-93ae-92361f002671\"\r\n\t\t\t\t\t},\t\t\"isBase\" : false,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"PCM\",\r\n\t\t\t\t\t\"initialCount\" : 0,\r\n\t\t\t\t\t\"hasVolumeGroup\" : true\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"vSAMP10aDEV::base::module-0\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\t\t\t\t\t\t\"modelVersion\" : \"2\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n\t\t\t\t\t},\t\t\"isBase\" : true,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"base\",\r\n\t\t\t\t\t\"initialCount\" : 1,\r\n\t\t\t\t\t\"hasVolumeGroup\" : true\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"vSAMP10a::base::module-0\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"02560de2-4223-11e7-9252-005056850d2e\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : null,\r\n\t\t\t\t\t\t\"modelVersion\" : \"2\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"MIGRATED_36e76920-ef30-4793-9979-cbd7d4b2bfc4\"\r\n\t\t\t\t\t},\t\t\"isBase\" : true,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"base\",\r\n\t\t\t\t\t\"initialCount\" : 1,\r\n\t\t\t\t\t\"hasVolumeGroup\" : true\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"base::module-0\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"02561381-4223-11e7-9252-005056850d2e\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : null,\r\n\t\t\t\t\t\t\"modelVersion\" : \"1\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"MIGRATED_51baae4c-b7c7-4f57-b77e-6e01acca89e5\"\r\n\t\t\t\t\t},\t\t\"isBase\" : true,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"module-0\",\r\n\t\t\t\t\t\"initialCount\" : 1,\r\n\t\t\t\t\t\"hasVolumeGroup\" : false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"vSAMP10a::PCM::module-1\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"02560f1b-4223-11e7-9252-005056850d2e\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : null,\r\n\t\t\t\t\t\t\"modelVersion\" : \"1\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"MIGRATED_e9be2ed7-45b6-479c-b06e-9093899f8ce8\"\r\n\t\t\t\t\t},\t\t\"isBase\" : true,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"PCM\",\r\n\t\t\t\t\t\"initialCount\" : 1,\r\n\t\t\t\t\t\"hasVolumeGroup\" : true\r\n\t\t\t\t}\r\n\t\t\t]\r\n\t\t}\r\n\t],\r\n\t\"serviceNetworks\": [],\r\n\t\"serviceAllottedResources\": [\r\n\t\t{\r\n\t\t\t\"modelInfo\" : {\r\n\t\t\t\t\"modelName\" : \"Tunnel_Xconn\",\r\n\t\t\t\t\"modelUuid\" : \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\t\t\t\t\"modelInvariantUuid\" : \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\t\t\t\t\"modelVersion\" : \"1.0\",\r\n\t\t\t\t\"modelCustomizationUuid\" : \"5b9bee43-f537-4fb3-9e8b-4de9f714d28a\",\r\n\t\t\t\t\"modelInstanceName\" : \"Pri_Tunnel_Xconn 9\"\r\n\t\t\t},\r\n\t\t\t\"toscaNodeType\" : null,\r\n\t\t\t\"allottedResourceType\" : null,\r\n\t\t\t\"allottedResourceRole\" : null,\r\n\t\t\t\"providingServiceModelInvariantUuid\" : null,\r\n\t\t\t\"nfFunction\" : null,\r\n\t\t\t\"nfType\" : null,\r\n\t\t\t\"nfRole\" : null,\r\n\t\t\t\"nfNamingCode\" : null\r\n\t\t}\r\n\t],\r\n\t\"serviceConfigs\": [\r\n\t\t{\r\n\t\t\t\"modelInfo\" : {\r\n\t\t\t\t\"modelName\" : \"Mulder\",\r\n\t\t\t\t\"modelUuid\" : \"025606c1-4fff-11e7-9252-005056850d2e\",\r\n\t\t\t\t\"modelInvariantUuid\" : \"025606c1-4eee-11e7-9252-005056850d2e\",\r\n\t\t\t\t\"modelVersion\" : \"1.0\",\r\n\t\t\t\t\"modelCustomizationUuid\" : \"025606c1-4ddd-11e7-9252-005056850d2e\",\r\n\t\t\t\t\"modelInstanceName\" : \"X_FILES_001\"\r\n\t\t\t},\r\n\t\t\t\"toscaNodeType\" : \"Scully\"\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"modelInfo\" : {\r\n\t\t\t\t\"modelName\" : \"Krychuk\",\r\n\t\t\t\t\"modelUuid\" : \"025606c1-5fff-11e7-9252-005056850d2e\",\r\n\t\t\t\t\"modelInvariantUuid\" : \"025606c1-5eee-11e7-9252-005056850d2e\",\r\n\t\t\t\t\"modelVersion\" : \"1.0\",\r\n\t\t\t\t\"modelCustomizationUuid\" : \"025606c1-5ddd-11e7-9252-005056850d2e\",\r\n\t\t\t\t\"modelInstanceName\" : \"X_FILES_002\"\r\n\t\t\t},\r\n\t\t\t\"toscaNodeType\" : \"Skinner\"\r\n\t\t}\r\n\t]\r\n\t}}\r\n\r\n" 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 }" @@ -125,7 +127,7 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { when(mockExecution.getVariable("snssaiAndOrchStatusList")).thenReturn(snssaiList) String returnedJsonAsString= allocate.prepareVnfInstanceParamsJson(mockExecution) - String expectedJsonAsString = """{supportedNssai={"sNssai":[{"snssai":"01-5C83F071","status":"activated"},{"snssai":"01-5B179BD4","status":"activated"}]}}""" + String expectedJsonAsString = """{"sNssai":[{"snssai":"01-5C83F071","status":"activated"},{"snssai":"01-5B179BD4","status":"activated"}]}""" assertEquals(expectedJsonAsString, returnedJsonAsString) } @@ -137,6 +139,7 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { DoAllocateCoreSharedSlice obj = spy(DoAllocateCoreSharedSlice.class) when(obj.getAAIClient()).thenReturn(client) + AAIResourceUri resourceUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX")) when(client.exists(resourceUri1)).thenReturn(true) AAIResultWrapper wrapper1 = new AAIResultWrapper(mockQuerySliceServiceReturn()) @@ -149,15 +152,14 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { 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(AAIFluentTypeBuilder.network().genericVnf("eeb66c6f-36bd-47ad-8294-48f46b1aa912")) + + AAIResourceUri resourceUri3 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(mockExecution.getVariable("vnfId"))) when(client.exists(resourceUri3)).thenReturn(true) AAIResultWrapper wrapper3 = new AAIResultWrapper(mockQueryVnf()) when(client.get(resourceUri3, NotFoundException.class)).thenReturn(wrapper3) - //Allotted Resources-1 AAIResourceUri resourceUri4 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("0d3d3cce-46a8-486d-816a-954e71697c4e")) when(client.exists(resourceUri4)).thenReturn(true) @@ -185,22 +187,19 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { Mockito.verify(mockExecution, times(1)).setVariable(eq("owningEntityId"), captor.capture()) assertEquals("OE-generic", captor.getValue()) - //assertEquals("206535e7-77c9-4036-9387-3f1cf57b4379", 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<Map<String, Object>> snssaiList = new ArrayList<>() Map<String, Object> snssaiMap = new LinkedHashMap<>() snssaiMap.put("snssai", "01-5C83F071") - snssaiMap.put("orchestrationStatus", "activated") + snssaiMap.put("status", "activated") snssaiList.add(snssaiMap) Map<String, Object> snssaiMap1 = new LinkedHashMap<>() snssaiMap1.put("snssai", "01-5B179BD4") - snssaiMap1.put("orchestrationStatus", "activated") + snssaiMap1.put("status", "activated") snssaiList.add(snssaiMap1) assertEquals(snssaiList, captor.getValue()) @@ -237,6 +236,7 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { 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("nssiId")).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") |