diff options
50 files changed, 8302 insertions, 360 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java index c7f4509237..ab0239057a 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java @@ -90,4 +90,31 @@ public final class AuthenticationMethodFactory { return v3Auth; } + public final com.woorea.openstack.keystone.v3.model.Authentication getAuthenticationForV3ByName( + CloudIdentity cloudIdentity, String name) { + Identity identity = new Identity(); + Password password = new Password(); + User user = new User(); + Domain userDomain = new Domain(); + Scope scope = new Scope(); + Project project = new Project(); + Project.Domain projectDomain = new Project.Domain(); + userDomain.setName(cloudIdentity.getUserDomainName()); + projectDomain.setName(cloudIdentity.getProjectDomainName()); + user.setName(cloudIdentity.getMsoId()); + user.setPassword(CryptoUtils.decryptCloudConfigPassword(cloudIdentity.getMsoPass())); + user.setDomain(userDomain); + password.setUser(user); + project.setDomain(projectDomain); + project.setName(name); + scope.setProject(project); + identity.setPassword(password); + identity.setMethods(Collections.singletonList("password")); + com.woorea.openstack.keystone.v3.model.Authentication v3Auth = + new com.woorea.openstack.keystone.v3.model.Authentication(); + v3Auth.setIdentity(identity); + v3Auth.setScope(scope); + return v3Auth; + } + } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java index 305d52a997..89fd9a0147 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java @@ -37,10 +37,11 @@ public class QueryServiceMacroHolder extends CatalogQuery { + "\t\t\"modelUuid\" : <SERVICE_MODEL_UUID>,\n" + "\t\t\"modelInvariantUuid\" : <SERVICE_MODEL_INVARIANT_ID>,\n" + "\t\t\"modelVersion\" : <SERVICE_MODEL_VERSION>\n" + "\t},\n" - + "\t\"serviceType\" : <SERVICE_TYPE>,\n" + "\t\"serviceRole\" : <SERVICE_ROLE>,\n" - + "\t\"environmentContext\" : <ENVIRONMENT_CONTEXT>,\n" + "\t\"resourceOrder\" : <RESOURCE_ORDER>,\n" - + "\t\"workloadContext\" : <WORKLOAD_CONTEXT>,\n" + "<_SERVICEVNFS_>,\n" + "<_SERVICENETWORKS_>,\n" - + "<_SERVICEINFO_>,\n" + "<_SERVICEPROXY_>,\n" + "<_SERVICEALLOTTEDRESOURCES_>\n" + "\t}}"; + + "\t\"serviceCategory\" : <SERVICE_CATEGORY>,\n" + "\t\"serviceType\" : <SERVICE_TYPE>,\n" + + "\t\"serviceRole\" : <SERVICE_ROLE>,\n" + "\t\"environmentContext\" : <ENVIRONMENT_CONTEXT>,\n" + + "\t\"resourceOrder\" : <RESOURCE_ORDER>,\n" + "\t\"workloadContext\" : <WORKLOAD_CONTEXT>,\n" + + "<_SERVICEVNFS_>,\n" + "<_SERVICENETWORKS_>,\n" + "<_SERVICEINFO_>,\n" + "<_SERVICEPROXY_>,\n" + + "<_SERVICEALLOTTEDRESOURCES_>\n" + "\t}}"; public QueryServiceMacroHolder() { super(); @@ -80,6 +81,7 @@ public class QueryServiceMacroHolder extends CatalogQuery { put(valueMap, "SERVICE_MODEL_VERSION", service.getModelVersion()); put(valueMap, "SERVICE_TYPE", service.getServiceType()); put(valueMap, "SERVICE_ROLE", service.getServiceRole()); + put(valueMap, "SERVICE_CATEGORY", service.getCategory()); put(valueMap, "ENVIRONMENT_CONTEXT", service.getEnvironmentContext()); put(valueMap, "WORKLOAD_CONTEXT", service.getWorkloadContext()); put(valueMap, "RESOURCE_ORDER", service.getResourceOrder()); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java index 61c0cdbf2e..44ea2a25a2 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java @@ -971,8 +971,10 @@ public class ASDCController { private void processNsstNotification(INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) { Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata(); try { - if (serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY).equalsIgnoreCase("NSST")) { - + String category = serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY); + boolean isNeedInital = (category.contains("NSST") || category.equalsIgnoreCase("TN Network Requirement")) + && iNotif.getResources().isEmpty(); + if (isNeedInital) { String artifactContent = null; List<IArtifactInfo> serviceArtifacts = iNotif.getServiceArtifacts(); Optional<IArtifactInfo> artifactOpt = serviceArtifacts.stream() @@ -986,14 +988,18 @@ public class ASDCController { artifactContent = zipParserInstance.parseJsonForZip(filePath); logger.debug( "serviceArtifact parsing success! serviceArtifactUUID: " + artifactInfo.getArtifactUUID()); + + ResourceStructure resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance()); + resourceStructure.setResourceType(ResourceType.OTHER); + toscaInstaller.installNsstService(toscaResourceStructure, (VfResourceStructure) resourceStructure, + artifactContent); } else { logger.debug("serviceArtifact is null"); + toscaInstaller.installNsstService(toscaResourceStructure, null, null); } - ResourceStructure resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance()); - resourceStructure.setResourceType(ResourceType.OTHER); - toscaInstaller.installTheNsstService(toscaResourceStructure, (VfResourceStructure) resourceStructure, - artifactContent); + } + } catch (IOException e) { logger.error("serviceArtifact parse failure for service uuid: " + serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index d023df3b79..49fef1d3f0 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -2870,7 +2870,15 @@ public class ToscaResourceInstaller { List<Input> serviceInputs = sdcCsarHelper.getServiceInputs(); if (!serviceInputs.isEmpty()) { serviceInputList = new ArrayList<>(); - serviceInputs.forEach(input -> { + List<Input> filterList; + filterList = serviceInputs.stream() + .filter(input -> !SKIP_POST_INST_CONF.equals(input.getName()) + && !CDS_MODEL_NAME.equalsIgnoreCase(input.getName()) + && !CDS_MODEL_VERSION.equalsIgnoreCase(input.getName()) + && !CONTROLLER_ACTOR.equalsIgnoreCase(input.getName())) + .collect(Collectors.toList()); + + filterList.forEach(input -> { Map<String, Object> serviceInputMap = new HashMap<>(); serviceInputMap.put("name", input.getName()); serviceInputMap.put("type", input.getType()); @@ -2894,7 +2902,7 @@ public class ToscaResourceInstaller { } @Transactional(rollbackFor = {ArtifactInstallerException.class}) - public void installTheNsstService(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct, + public void installNsstService(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct, String artifactContent) { createToscaCsar(toscaResourceStruct); createService(toscaResourceStruct, vfResourceStruct); @@ -2925,6 +2933,10 @@ public class ToscaResourceInstaller { } private void createServiceInfo(ToscaResourceStructure toscaResourceStruct, Service service) { + if (!service.getServiceInfos().isEmpty()) { + return; + } + List<ServiceInfo> serviceInfos = new ArrayList<>(); ServiceInfo serviceInfo = new ServiceInfo(); @@ -2945,42 +2957,67 @@ public class ToscaResourceInstaller { ISdcCsarHelper helper = toscaResourceStruct.getSdcCsarHelper(); String typeName = helper.getServiceSubstitutionMappingsTypeName(); Optional<NodeTemplate> nodeTemplate = helper.getServiceNodeTemplates().stream().findAny(); - List<Object> serviceProperties = new ArrayList<>(); - Map<String, Object> servicePropertiesMap; + if (nodeTemplate.isPresent()) { + String serviceUUID = nodeTemplate.get().getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID); LinkedHashMap<String, Object> customDef = nodeTemplate.get().getCustomDef(); - Optional<String> machKey = - customDef.keySet().stream().filter(key -> key.equalsIgnoreCase(typeName)).findFirst(); - if (machKey.isPresent()) { - Object obj = customDef.get(machKey.get()); - try { - if (obj instanceof Map) { - Object properties = ((HashMap) obj).get("properties"); - if (null != properties) { - for (Object propertyName : ((Map) properties).keySet()) { - servicePropertiesMap = new HashMap<>(); - servicePropertiesMap.put("name", propertyName); - Object object = ((Map) properties).get(propertyName); - for (Object entry : ((Map) object).entrySet()) { - servicePropertiesMap.put((String) ((Map.Entry) entry).getKey(), - ((Map.Entry) entry).getValue()); - } - servicePropertiesMap.remove("description"); - serviceProperties.add(servicePropertiesMap); + List<Object> serviceProperties = getPropertiesFromCustomDef(customDef, typeName); + + try { + propertiesJson = objectMapper.writeValueAsString(serviceProperties); + propertiesJson = propertiesJson.replace("\"", "\\\""); + } catch (JsonProcessingException e) { + logger.error("serviceProperties could not be deserialized for service uuid: " + serviceUUID); + } catch (Exception ex) { + logger.error("service properties parsing failed. service uuid:" + serviceUUID); + } + + } else { + logger.debug("ServiceNodeTemplates is null"); + } + return propertiesJson; + } + + private static List<Object> getPropertiesFromCustomDef(LinkedHashMap<String, Object> customDef, + final String typeName) { + Optional<String> machKey = + customDef.keySet().stream().filter(key -> key.equalsIgnoreCase(typeName)).findFirst(); + Map<String, Object> servicePropertiesMap; + List<Object> serviceProperties = new ArrayList<>(); + + if (machKey.isPresent()) { + Object obj = customDef.get(machKey.get()); + if (obj instanceof Map) { + Object properties = ((HashMap) obj).get("properties"); + if (null != properties) { + for (Object propertyName : ((Map) properties).keySet()) { + if (propertyName.toString().split("_").length >= 2) { + continue; + } + + servicePropertiesMap = new HashMap<>(); + servicePropertiesMap.put("name", propertyName); + Object object = ((Map) properties).get(propertyName); + for (Object entry : ((Map) object).entrySet()) { + servicePropertiesMap.put((String) ((Map.Entry) entry).getKey(), + ((Map.Entry) entry).getValue()); + } + + String type = servicePropertiesMap.get("type").toString(); + if (type.split("\\.").length >= 2) { + List<Object> subProperties = getPropertiesFromCustomDef(customDef, type); + if (subProperties.size() > 0) { + serviceProperties.addAll(subProperties); } - propertiesJson = objectMapper.writeValueAsString(serviceProperties); - propertiesJson = propertiesJson.replace("\"", "\\\""); + continue; } + servicePropertiesMap.remove("description"); + serviceProperties.add(servicePropertiesMap); } - } catch (JsonProcessingException e) { - logger.error("serviceProperties could not be deserialized for service uuid: " - + nodeTemplate.get().getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); } } - } else { - logger.debug("ServiceNodeTemplates is null"); } - return propertiesJson; + return serviceProperties; } } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DoHandleOofRequest.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DoHandleOofRequest.groovy index ebc5f4ac58..644cf5e387 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DoHandleOofRequest.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DoHandleOofRequest.groovy @@ -79,7 +79,7 @@ class DoHandleOofRequest extends AbstractServiceTaskProcessor { oofRequestPayload.setApiPath(apiPath) oofRequestPayload.setRequestDetails(requestDetails) ObjectMapper objectMapper = new ObjectMapper() - String requestJson = objectMapper.writeValueAsString(oofRequestPayload) + String requestJson = objectMapper.writeValueAsString(oofRequestPayload) execution.setVariable("oofRequestPayload", requestJson) } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy index b35042e3c0..23dfdce753 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.db.request.beans.OperationStatus +import org.onap.so.db.request.beans.ResourceOperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.web.util.UriUtils @@ -116,4 +117,100 @@ class RequestDBUtil { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) } } + + /** + * init resource operation status in requestDB + * @param execution + * @param resourceoperationStatus + */ + void prepareInitResourceOperationStatus(DelegateExecution execution, final ResourceOperationStatus resourceoperationStatus){ + logger.debug("start prepareinitResourceOperationStatus") + try{ + def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution) + execution.setVariable("dbAdapterEndpoint", dbAdapterEndpoint) + logger.debug("DB Adapter Endpoint is: " + dbAdapterEndpoint) + + String serviceId = resourceoperationStatus.getServiceId() + serviceId = UriUtils.encode(serviceId,"UTF-8") + String operationId = resourceoperationStatus.getOperationId() + String resourceTemplateUUID = resourceoperationStatus.getResourceTemplateUUID() + String operType = resourceoperationStatus.getOperType() + + String payload = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:initResourceOperationStatus xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId> + <operationId>${MsoUtils.xmlEscape(operationId)}</operationId> + <operationType>${MsoUtils.xmlEscape(operType)}</operationType> + <resourceTemplateUUIDs>${MsoUtils.xmlEscape(resourceTemplateUUID)}</resourceTemplateUUIDs> + </ns:initResourceOperationStatus> + </soapenv:Body> + </soapenv:Envelope> + """ + execution.setVariable("initResourceOperationStatus", payload) + + }catch(any){ + String exceptionMessage = "Prepare init ResourceOperationStatus failed. cause - " + any.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + logger.trace("finished init ResourceOperationStatus") + } + + /** + * update resource operation status in requestDB + * @param execution + * @param resourceoperationStatus + */ + void prepareUpdateResourceOperationStatus(DelegateExecution execution, final ResourceOperationStatus resourceoperationStatus){ + logger.debug("start prepareUpdateResourceOperationStatus") + try{ + def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution) + execution.setVariable("dbAdapterEndpoint", dbAdapterEndpoint) + logger.debug("DB Adapter Endpoint is: " + dbAdapterEndpoint) + + String serviceId = resourceoperationStatus.getServiceId() + serviceId = UriUtils.encode(serviceId,"UTF-8") + String operationId = resourceoperationStatus.getOperationId() + String resourceTemplateUUID = resourceoperationStatus.getResourceTemplateUUID() + String operType = resourceoperationStatus.getOperType() + String resourceInstanceID = resourceoperationStatus.getResourceInstanceID() + String jobId = resourceoperationStatus.getJobId() + String status = resourceoperationStatus.getStatus() + String progress = resourceoperationStatus.getProgress() + String errorCode = resourceoperationStatus.getErrorCode()?: "" + String statusDescription = resourceoperationStatus.getStatusDescription()?: "" + + String payload = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:updateResourceOperationStatus xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId> + <operationId>${MsoUtils.xmlEscape(operationId)}</operationId> + <resourceTemplateUUIDs>${MsoUtils.xmlEscape(resourceTemplateUUID)}</resourceTemplateUUIDs> + <operationType>${MsoUtils.xmlEscape(operType)}</operationType> + <jobId>${MsoUtils.xmlEscape(jobId)}</jobId> + <status>${MsoUtils.xmlEscape(status)}</status> + <progress>${MsoUtils.xmlEscape(progress)}</progress> + <errorCode>${MsoUtils.xmlEscape(errorCode)}</errorCode> + <statusDescription>${MsoUtils.xmlEscape(statusDescription)}</statusDescription> + </ns:updateResourceOperationStatus> + </soapenv:Body> + </soapenv:Envelope> + """ + execution.setVariable("updateResourceOperationStatus", payload) + + }catch(any){ + String exceptionMessage = "Prepare update ResourceOperationStatus failed. cause - " + any.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + logger.trace("finished update ResourceOperationStatus") + } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy new file mode 100644 index 0000000000..c7fe7e36a6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy @@ -0,0 +1,181 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, Wipro Limited. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +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 static org.apache.commons.lang3.StringUtils.isBlank + +class ActivateSliceSubnet extends AbstractServiceTaskProcessor { + String Prefix="ActSS" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + + private static final Logger logger = LoggerFactory.getLogger(ActivateSliceSubnet.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //NSSI ID + String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") + if (isBlank(serviceInstanceID)) { + msg = "Input serviceInstanceID is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("serviceInstanceID", serviceInstanceID) + } + + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + + //requestParameters, subscriptionServiceType is 5G + String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + //operationType = deactivateInstance/activateInstance + String operationType = execution.getVariable("requestAction") + if (isBlank(operationType)) { + msg = "Input operationType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("operationType", operationType) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in ActivateSliceSubnet.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String serviceId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType(operationType) + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String activateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""" + .trim().replaceAll(" ", "") + + logger.debug("sendSyncResponse to APIH:" + "\n" + activateSyncResponse) + sendWorkflowResponse(execution, 202, activateSyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse 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 new file mode 100644 index 0000000000..5a7722d679 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy @@ -0,0 +1,190 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, Wipro Limited. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +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 static org.apache.commons.lang3.StringUtils.isBlank + +class AllocateSliceSubnet extends AbstractServiceTaskProcessor { + + String Prefix="ASS_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + RequestDBUtil requestDBUtil = new RequestDBUtil() + JsonUtils jsonUtil = new JsonUtils() + private static final Logger logger = LoggerFactory.getLogger(AllocateSliceSubnet.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) + + //modelInfo + String modelInvariantUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelInvariantUuid") + if (isBlank(modelInvariantUuid)) { + msg = "Input modelInvariantUuid is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("modelInvariantUuid", modelInvariantUuid) + } + + logger.debug("modelInvariantUuid: " + modelInvariantUuid) + + String modelUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelUuid") + if (isBlank(modelUuid)) { + msg = "Input modelUuid is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("modelUuid", modelUuid) + } + + logger.debug("modelUuid: " + modelUuid) + + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + String dummyServiceId = new UUID(0,0).toString(); + execution.setVariable("dummyServiceId", dummyServiceId) + logger.debug("dummyServiceId: " + dummyServiceId) + String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name") + execution.setVariable("servicename", servicename) + + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + + //requestParameters, subscriptionServiceType is 5G + String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in AllocateSliceSubnet.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String serviceId = execution.getVariable("dummyServiceId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType("Allocate") + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String allocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""" + .trim().replaceAll(" ", "").trim().replaceAll(" ", "") + + logger.debug("sendSyncResponse to APIH:" + "\n" + allocateSyncResponse) + sendWorkflowResponse(execution, 202, allocateSyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy index 12cd0dde0b..f8eafe7e98 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy @@ -184,7 +184,7 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { logger.debug(Prefix + "prepareInitOperationStatus Start") String serviceId = execution.getVariable("serviceInstanceId") - // 生成 operationId + //operationId is generated String operationId = execution.getVariable("operationId") logger.debug("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId) @@ -370,20 +370,23 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { for (String e2eInput in e2eInputs) { - if (jsonUtil.getJsonValue(e2eInput, "type") == "integer") { + key = jsonUtil.getJsonValue(e2eInput, "name") + String type = jsonUtil.getJsonValue(e2eInput, "type") + if (type == "integer") { def temp - key = jsonUtil.getJsonValue(e2eInput, "name") value = csInputMap.containsKey(key) ? csInputMap.getOrDefault(key, 0) : (isBlank(temp = jsonUtil.getJsonValue(e2eInput, "default")) ? 0 : temp) e2eInputMap.put(key, value as Integer) - } else { - e2eInputMap.put(key = jsonUtil.getJsonValue(e2eInput, "name"), csInputMap.containsKey(key) + } else if(type == "string") { + e2eInputMap.put(key, csInputMap.containsKey(key) ? csInputMap.getOrDefault(key, null) : (jsonUtil.getJsonValue(e2eInput, "default"))) + } } + //TODO e2eInputMap.put("sNSSAI", execution.getVariable("sNSSAI_id")) - e2eInputMap.put("sST", execution.getVariable("csServiceType")) + e2eInputMap.put("sST", execution.getVariable("csServiceType")) execution.setVariable("e2eInputMap", e2eInputMap) execution.setVariable("e2eServiceType", e2eServiceDecomposition.getServiceType()) execution.setVariable("e2eModelInvariantUuid", e2eServiceDecomposition.getModelInfo().getModelInvariantUuid()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy index 389f0a089c..dcbaf746ea 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy @@ -181,7 +181,7 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { public void prepareSelectNSTRequest(DelegateExecution execution) { logger.debug("Start prepareSelectNSTRequest") String requestId = execution.getVariable("msoRequestId") - String messageType = "NSTSelectionResponse" + String messageType = "NSTSelectionResponse" Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") execution.setVariable("nstSelectionUrl", "/api/oof/v1/selection/nst") execution.setVariable("nstSelection_messageType",messageType) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy new file mode 100644 index 0000000000..964baa7a9d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy @@ -0,0 +1,170 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, Wipro Limited. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +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 static org.apache.commons.lang3.StringUtils.isBlank + +class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { + String Prefix="DeASS_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + + private static final Logger logger = LoggerFactory.getLogger(DeAllocateSliceSubnet.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //NSSI ID + String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") + if (isBlank(serviceInstanceID)) { + msg = "Input serviceInstanceID is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("serviceInstanceID", serviceInstanceID) + } + + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + + //requestParameters, subscriptionServiceType is 5G + String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in DeAllocateSliceSubnet.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String serviceId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType("Deallocate") + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String deAllocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""".trim().replaceAll(" ", "") + + logger.debug("sendSyncResponse to APIH:" + "\n" + deAllocateSyncResponse) + sendWorkflowResponse(execution, 202, deAllocateSyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy new file mode 100644 index 0000000000..306c53a73c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy @@ -0,0 +1,685 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Tech Mahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONObject +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.serviceinstancebeans.CloudConfiguration +import org.onap.so.serviceinstancebeans.LineOfBusiness +import org.onap.so.serviceinstancebeans.ModelInfo +import org.onap.so.serviceinstancebeans.ModelType +import org.onap.so.serviceinstancebeans.OwningEntity +import org.onap.so.serviceinstancebeans.Platform +import org.onap.so.serviceinstancebeans.Project +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.rest.catalog.beans.Vnf +import org.onap.so.serviceinstancebeans.RequestDetails +import org.onap.so.serviceinstancebeans.RequestInfo +import org.onap.so.serviceinstancebeans.RequestParameters +import org.onap.so.serviceinstancebeans.SubscriberInfo +import org.onap.aai.domain.yang.GenericVnf +import org.onap.aai.domain.yang.RelatedToProperty +import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.RelationshipData +import org.onap.aai.domain.yang.RelationshipList +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aai.domain.yang.v19.SliceProfile +import org.onap.aai.domain.yang.v19.SliceProfiles +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.db.request.beans.OperationStatus +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import com.fasterxml.jackson.databind.ObjectMapper + +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response + +class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { + String Prefix="DACTCNSSI_" + private static final Logger logger = LoggerFactory.getLogger(DoActivateCoreNSSI.class); + CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() + private RequestDBUtil requestDBUtil = new RequestDBUtil() + ExceptionUtil exceptionUtil = new ExceptionUtil() + ObjectMapper mapper = new ObjectMapper(); + + JsonUtils jsonUtil = new JsonUtils() + + private final Long TIMEOUT = 60 * 60 * 1000 + + @Override + public void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: preProcessRequest ****") + + String operationType = execution.getVariable("operationType") + String oStatus= "" + + if(operationType.equals("activateInstance")) { + oStatus ="activated" + } else { + oStatus ="deactivated" + } + + execution.setVariable("oStatus", oStatus) + String sNssaiListAsString = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "snssaiList") + + logger.debug("sNssaiListAsString "+sNssaiListAsString) + + List<String> sNssaiList = jsonUtil.StringArrayToList(sNssaiListAsString) + + logger.debug("sNssaiList "+sNssaiList) + + + String sNssai = sNssaiList.get(0) + execution.setVariable("sNssai", sNssai) + + logger.debug("sNssai: "+sNssai) + + String serviceType = execution.getVariable("subscriptionServiceType") + execution.setVariable("serviceType", serviceType) + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: preProcessRequest ****") + } + + public void getNetworkInstanceWithSPInstanceAssociatedWithNssiId(DelegateExecution execution) { + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: getNetworkInstanceWithSPInstanceAssociatedWithNssiId ****") + //NSSI Id as service Instance Id to get from Request + String serviceInstanceId = execution.getVariable("serviceInstanceID") + String errorMsg = "query Network Service Instance from AAI failed" + AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg) + Optional<ServiceInstance> nsi = wrapper.asBean(ServiceInstance.class) + String networkServiceInstanceName = "" + String networkServiceInstanceId ="" + if(nsi.isPresent()) { + List<Relationship> relationshipList = nsi.get().getRelationshipList()?.getRelationship() + List spiWithsNssaiAndOrchStatusList = new ArrayList<>() + + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo == "service-instance") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToProperty() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "service-instance.service-instance-id") { + execution.setVariable("networkServiceInstanceId", relationshipData.getRelationshipValue()) + } + } + for (RelatedToProperty relatedToProperty : relatedToPropertyList) { + if (relatedToProperty.getPropertyKey() == "service-instance.service-instance-name") { + execution.setVariable("networkServiceInstanceName", relatedToProperty.getPropertyValue()) + } + } + } + + //If related to is allotted-Resource + if (relatedTo == "allotted-resource") { + //get slice Profile Instance Id from allotted resource in list by nssi + List<String> sliceProfileInstanceIdList = new ArrayList<>() + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "service-instance.service-instance-id") { + sliceProfileInstanceIdList.add(relationshipData.getRelationshipValue()) + } + } + for (String sliceProfileServiceInstanceId : sliceProfileInstanceIdList) { + String errorSliceProfileMsg = "Slice Profile Service Instance was not found in aai" + + //Query Slice Profile Service Instance From AAI by sliceProfileServiceInstanceId + AAIResultWrapper sliceProfileInstanceWrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, sliceProfileServiceInstanceId, errorSliceProfileMsg) + Optional<ServiceInstance> sliceProfileServiceInstance = sliceProfileInstanceWrapper.asBean(ServiceInstance.class) + if (sliceProfileServiceInstance.isPresent()) { + String orchestrationStatus= sliceProfileServiceInstance.get().getOrchestrationStatus() + String sNssai = sliceProfileServiceInstance.get().getSliceProfiles().getSliceProfile().get(0).getSNssai() + if(sNssai.equals(execution.getVariable("sNssai"))) { + orchestrationStatus = execution.getVariable("oStatus") + //Slice Profile Service Instance to be updated in AAI + execution.setVariable("sliceProfileServiceInstance", sliceProfileServiceInstance) + } + + Map<String, Object> spiWithsNssaiAndOrchStatus = new LinkedHashMap<>() + spiWithsNssaiAndOrchStatus.put("snssai", sNssai) + spiWithsNssaiAndOrchStatus.put("status", orchestrationStatus) + spiWithsNssaiAndOrchStatusList.add(spiWithsNssaiAndOrchStatus) + } + } + } + } + execution.setVariable("snssaiAndOrchStatusList", spiWithsNssaiAndOrchStatusList) + } + logger.debug("NSSI Id: ${serviceInstanceId}, network Service Instance Id: ${networkServiceInstanceId}, serviceName: ${networkServiceInstanceName}") + //Get ServiceInstance Relationships + getServiceInstanceRelationships(execution) + //Get Vnf Relationships + getVnfRelationships(execution) + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: getNetworkInstanceWithSPInstanceAssociatedWithNssiId ****") + } + + + private String prepareVnfInstanceParamsJson(DelegateExecution execution) { + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: prepareVnfInstanceParamsJson ****") + List instanceParamsvalues = execution.getVariable("snssaiAndOrchStatusList") + Map<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(Prefix +" **** Exit DoActivateCoreNSSI ::: prepareVnfInstanceParamsJson ****") + return supportedNssai + } + + private void getServiceInstanceRelationships(DelegateExecution execution) { + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: getServiceInstanceRelationships ****") + String serviceInstanceId = execution.getVariable("networkServiceInstanceId") + logger.debug("**** serviceInstanceId :: getServiceInstanceRelationships :: "+serviceInstanceId) + String errorMsg = "query Network Service Instance from AAI failed" + AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg) + Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) + + String networkServiceModelInvariantUuid = si.get().getModelInvariantId() + execution.setVariable("networkServiceModelInvariantUuid", networkServiceModelInvariantUuid) + if(si.isPresent()) { + List<Relationship> relationshipList = si.get().getRelationshipList()?.getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo == "owning-entity") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "owning-entity.owning-entity-id") { + execution.setVariable("owningEntityId", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "generic-vnf") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToProperty() + + //Get VnfId + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "generic-vnf.vnf-id") { + execution.setVariable("vnfId", relationshipData.getRelationshipValue()) + String vnfId = relationshipData.getRelationshipValue() + logger.debug("vnfId :"+vnfId) + } + } + } else if (relatedTo == "project") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "project.project-name") { + execution.setVariable("projectName", relationshipData.getRelationshipValue()) + } + } + } + } + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: getServiceInstanceRelationships ****") + } + } + + private void getVnfRelationships(DelegateExecution execution) { + + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: getVnfRelationships ****") + String msg = "query Generic Vnf from AAI failed" + try { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable('vnfId')) + if (!getAAIClient().exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + AAIResultWrapper wrapper = getAAIClient().get(uri, NotFoundException.class) + Optional<GenericVnf> vnf = wrapper.asBean(GenericVnf.class) + if(vnf.isPresent()) { + List<Relationship> relationshipList = vnf.get().getRelationshipList()?.getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo == "tenant") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "tenant.tenant-id") { + execution.setVariable("tenantId", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "cloud-region") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "cloud-region.cloud-owner") { + execution.setVariable("cloudOwner", relationshipData.getRelationshipValue()) + } else if (relationshipData.getRelationshipKey() == "cloud-region.cloud-region-id") { + execution.setVariable("lcpCloudRegionId", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "platform") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "platform.platform-name") { + execution.setVariable("platformName", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "line-of-business") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "line-of-business.line-of-business-name") { + execution.setVariable("lineOfBusinessName", relationshipData.getRelationshipValue()) + } + } + } + } + } + } catch(BpmnError e){ + throw e + } catch (Exception ex){ + msg = "Exception in getVnfRelationships " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: getVnfRelationships ****") + } + + + /** + * query AAI + * @param execution + * @param aaiObjectType + * @param instanceId + * @return AAIResultWrapper + */ + private AAIResultWrapper queryAAI(DelegateExecution execution, AAIObjectType aaiObjectType, String instanceId, String errorMsg) { + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: queryAAI ****") + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(aaiObjectType, globalSubscriberId, serviceType, instanceId) + if (!getAAIClient().exists(resourceUri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg) + } + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) + + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: queryAAI ****") + return wrapper + } + + public void getServiceVNFAndVFsFromCatalogDB(DelegateExecution execution) { + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: getServiceVNFAndVFsFromCatalogDB ****") + + String modelInvariantUuid = execution.getVariable("networkServiceModelInvariantUuid") + + try{ + CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() + String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution, modelInvariantUuid) + logger.debug("***** JSON IS: "+json) + + String serviceVnfs = jsonUtil.getJsonValue(json, "serviceResources.serviceVnfs") ?: "" + String serviceModelInfo = jsonUtil.getJsonValue(json, "serviceResources.modelInfo") ?: "" + + + execution.setVariable("serviceVnfs",serviceVnfs) + execution.setVariable("serviceModelInfo", serviceModelInfo) + logger.debug(Prefix +" ***** serviceVnfs is: "+ serviceVnfs) + }catch(BpmnError e){ + throw e + } catch (Exception ex){ + String msg = "Exception in getServiceVNFAndVFsFromCatalogDB " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: getServiceVNFAndVFsFromCatalogDB ****") + } + + public void prepareSOMacroRequestPayLoad(DelegateExecution execution) { + logger.debug("**** Enter DoActivateCoreNSSI ::: prepareSOMacroRequestPayLoad ****") + String json = execution.getVariable("serviceVnfs") + logger.debug(">>>> json "+json) + List<Object> vnfList = mapper.readValue(json, List.class); + logger.debug("vnfList: "+vnfList) + Map<String,Object> serviceMap = mapper.readValue(execution.getVariable("serviceModelInfo"), Map.class); + ModelInfo serviceModelInfo = new ModelInfo() + serviceModelInfo.setModelType(ModelType.service) + serviceModelInfo.setModelInvariantId(serviceMap.get("modelInvariantUuid")) + serviceModelInfo.setModelVersionId(serviceMap.get("modelUuid")) + serviceModelInfo.setModelName(serviceMap.get("modelName")) + serviceModelInfo.setModelVersion(serviceMap.get("modelVersion")) + + logger.debug("serviceModelInfo: "+serviceModelInfo) + //List of Vnfs + List<Object> vnfModelInfoList = new ArrayList<>() + + Map vnfMap = vnfList.get(0) + ModelInfo vnfModelInfo = vnfMap.get("modelInfo") + logger.debug("vnfModelInfo "+vnfModelInfo) + + //List of VFModules + List<Map<String, Object>> vfModuleList = vnfMap.get("vfModules") + logger.debug("vfModuleList "+vfModuleList) + + //List of VfModules + List<ModelInfo> vfModelInfoList = new ArrayList<>() + + //Traverse VFModules List and add in vfModelInfoList + for (vfModule in vfModuleList) { + ModelInfo vfModelInfo = vfModule.get("modelInfo") + logger.debug("vfModelInfo "+vfModelInfo) + vfModelInfoList.add(vfModelInfo) + } + + //RequestInfo + RequestInfo requestInfo = new RequestInfo() + + //Dummy Product FamilyId + requestInfo.setProductFamilyId("test1234") + requestInfo.setSource("VID") + requestInfo.setInstanceName(execution.getVariable("networkServiceInstanceName")) + requestInfo.setSuppressRollback(false) + requestInfo.setRequestorId("NBI") + + //Service Level InstanceParams + List<Map<String, Object>> serviceParams = new ArrayList<>() + Map<String, Object> serviceParamsValues = new LinkedHashMap<>() + serviceParams.add(serviceParamsValues) + + //Cloud Configuration + CloudConfiguration cloudConfiguration = new CloudConfiguration() + cloudConfiguration.setLcpCloudRegionId(execution.getVariable("lcpCloudRegionId")) + cloudConfiguration.setTenantId(execution.getVariable("tenantId")) + cloudConfiguration.setCloudOwner(execution.getVariable("cloudOwner")) + + //VFModules List + List<Map<String, Object>> vfModules = new ArrayList<>() + for (ModelInfo vfModuleModelInfo : vfModelInfoList) { + //Individual VFModule List + Map<String, Object> vfModuleValues = new LinkedHashMap<>() + vfModuleValues.put("modelInfo", vfModuleModelInfo) + vfModuleValues.put("instanceName", vfModuleModelInfo.getModelInstanceName()) + + //VFModule InstanceParams should be empty or this field should not be there? + List<Map<String, Object>> vfModuleInstanceParams = new ArrayList<>() + vfModuleValues.put("instanceParams", vfModuleInstanceParams) + } + + //Vnf intsanceParams + ObjectMapper objectMapper = new ObjectMapper(); + Map<String, Object> sliceProfile = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class); + + List vnfInstanceParamsList = new ArrayList<>() + String supportedsNssaiJson= prepareVnfInstanceParamsJson(execution) + vnfInstanceParamsList.add(supportedsNssaiJson) + + Platform platform = new Platform() + platform.setPlatformName(execution.getVariable("platform")) + + LineOfBusiness lineOfbusiness = new LineOfBusiness() + lineOfbusiness.setLineOfBusinessName(execution.getVariable("lineOfBusiness")) + + //Vnf Values + Map<String, Object> vnfValues = new LinkedHashMap<>() + vnfValues.put("lineOfBusiness", lineOfbusiness) + vnfValues.put("platform", platform) + vnfValues.put("productFamilyId", "test1234") + vnfValues.put("cloudConfiguration", cloudConfiguration) + vnfValues.put("vfModules", vfModules) + vnfValues.put("modelInfo", vnfModelInfo) + vnfValues.put("instanceName", execution.getVariable("vnfInstanceName")) + vnfValues.put("instanceParams",vnfInstanceParamsList) + + vnfModelInfoList.add(vnfValues) + //Service Level Resources + Map<String, Object> serviceResources = new LinkedHashMap<>() + serviceResources.put("vnfs", vnfModelInfoList) + + //Service Values + Map<String, Object> serviceValues = new LinkedHashMap<>() + serviceValues.put("modelInfo", serviceModelInfo) + serviceValues.put("instanceName", execution.getVariable("networkServiceInstanceName")) + serviceValues.put("resources", serviceResources) + serviceValues.put("instanceParams", serviceParams) + + //UserParams Values + Map<String, Object> userParamsValues = new LinkedHashMap<>() + + Map<String, Object> homingSolution = new LinkedHashMap<>() + homingSolution.put("Homing_Solution", "none") + + userParamsValues.put("service", serviceValues) + + //UserParams + List<Map<String, Object>> userParams = new ArrayList<>() + userParams.add(homingSolution) + userParams.add(userParamsValues) + + //Request Parameters + RequestParameters requestParameters = new RequestParameters() + requestParameters.setaLaCarte(false) + requestParameters.setSubscriptionServiceType(execution.getVariable("serviceType")) + requestParameters.setUserParams(userParams) + + //SubscriberInfo + SubscriberInfo subscriberInfo = new SubscriberInfo() + subscriberInfo.setGlobalSubscriberId(execution.getVariable("globalSubscriberId")) + + //Owning Entity + OwningEntity owningEntity = new OwningEntity() + owningEntity.setOwningEntityId(execution.getVariable("owningEntityId")) + + //Project + Project project = new Project() + project.setProjectName(execution.getVariable("projectName")) + + RequestDetails requestDetails = new RequestDetails() + requestDetails.setModelInfo(serviceModelInfo) + requestDetails.setSubscriberInfo(subscriberInfo) + requestDetails.setRequestInfo(requestInfo) + requestDetails.setRequestParameters(requestParameters) + requestDetails.setCloudConfiguration(cloudConfiguration) + requestDetails.setOwningEntity(owningEntity) + requestDetails.setProject(project) + + Map<String, Object> requestDetailsMap = new LinkedHashMap<>() + requestDetailsMap.put("requestDetails", requestDetails) + String requestPayload = objectMapper.writeValueAsString(requestDetailsMap) + + logger.debug("requestDetails "+requestPayload) + execution.setVariable("requestPayload", requestPayload) + + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: prepareSOMacroRequestPayLoad ****") + } + + public void sendPutRequestToSOMacro(DelegateExecution execution) { + + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: sendPutRequestToSOMacro ****") + try { + String msoEndpoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution) + String url = msoEndpoint+"/serviceInstantiation/v7/serviceInstances/"+execution.getVariable("networkServiceInstanceId")+"/vnfs/"+execution.getVariable("vnfId") + String requestBody = execution.getVariable("requestPayload") + String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution) + String basicAuthValue = utils.encrypt(basicAuth, msoKey) + String encodeString = utils.getBasicAuth(basicAuthValue, msoKey) + + HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) + httpClient.addAdditionalHeader("Authorization", encodeString) + httpClient.addAdditionalHeader("Accept", "application/json") + Response httpResponse = httpClient.put(requestBody) + handleSOResponse(httpResponse, execution) + + } catch (BpmnError e) { + throw e + } catch (any) { + String msg = "Exception in DoActivateCoreNSSSI " + any.getCause() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: sendPostRequestToSOMacro ****") + } + + /** + * Handle SO Response for PUT and prepare update operation status + * @param execution + */ + private void handleSOResponse(Response httpResponse, DelegateExecution execution){ + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: handleSOResponse ****") + + int soResponseCode = httpResponse.getStatus() + logger.debug("soResponseCode : "+soResponseCode) + + if (soResponseCode >= 200 && soResponseCode < 204 && httpResponse.hasEntity()) { + String soResponse = httpResponse.readEntity(String.class) + String operationId = execution.getVariable("operationId") + def macroOperationId = jsonUtil.getJsonValue(soResponse, "operationId") + execution.setVariable("macroOperationId", macroOperationId) + execution.setVariable("isSOTimeOut", "no") + execution.setVariable("isSOResponseSucceed","yes") + } + else + { + String serviceName = execution.getVariable("serviceInstanceName") + execution.setVariable("isSOResponseSucceed","no") + prepareFailedOperationStatusUpdate(execution) + } + + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: handleSOResponse ****") + } + + /** + * prepare to call sub process CheckProcessStatus + * @param execution + */ + void prepareCallCheckProcessStatus(DelegateExecution execution){ + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: prepareCallCheckProcessStatus ****") + def successConditions = new ArrayList<>() + successConditions.add("finished") + execution.setVariable("successConditions", successConditions) + def errorConditions = new ArrayList<>() + errorConditions.add("error") + execution.setVariable("errorConditions", errorConditions) + execution.setVariable("processServiceType", "Network service") + execution.setVariable("subOperationType", "PUT") + execution.setVariable("initProgress", 20) + execution.setVariable("endProgress",90) + execution.setVariable("timeOut", TIMEOUT) + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: prepareCallCheckProcessStatus ****") + } + + void prepareUpdateResourceOperationStatus(DelegateExecution execution) { + + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: prepareUpdateResourceOperationStatus ****") + + String nssiOperationId = execution.getVariable("nssiOperationId") + execution.setVariable("operationId", nssiOperationId) + //Prepare Update Status for PUT failure and success + if(execution.getVariable("isTimeOut").equals("YES")) { + logger.debug("TIMEOUT - SO PUT Failure") + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "SO PUT Failure") + } + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: prepareUpdateResourceOperationStatus ****") + } + + void updateSliceProfileOrchestrationStatus(DelegateExecution execution) { + + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: updateSliceProfileOrchestrationStatus ****") + + String globalCustId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + String oStatus = execution.getVariable("oStatus") + + ServiceInstance si = execution.getVariable("sliceProfileServiceInstance") + String sliceProfileInstanceId = si.getServiceInstanceId() + si.setOrchestrationStatus(oStatus) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalCustId, serviceType, sliceProfileInstanceId) + try { + + Response response = getAAIClient().update(uri, si) + + if(response.getStatus()!=200 || response.getStatus()!=201 || response.getStatus()!=202) { + exceptionUtil.buildAndThrowWorkflowException(execution, response.getStatus(), "AAI failed to update sliceProlie service Instance orchestration status") + } else { + setResourceOperationStatus(execution) + } + } catch (Exception e) { + logger.info("Update OrchestrationStatus in AAI failed") + String msg = "Update OrchestrationStatus in AAI failed, " + e.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: updateSliceProfileOrchestrationStatus ****") + } + + /** + * prepare ResourceOperation status + * @param execution + * @param operationType + */ + private void setResourceOperationStatus(DelegateExecution execution) { + + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: setResourceOperationStatus ****") + + String serviceId = execution.getVariable("nssiId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() + resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setOperType(operationType) + resourceOperationStatus.setStatus("finished") + resourceOperationStatus.setProgress("100") + resourceOperationStatus.setStatusDescription("Core Activation Successful") + requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) + + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: setResourceOperationStatus ****") + } + + void prepareFailedOperationStatusUpdate(DelegateExecution execution){ + logger.debug(Prefix + " **** Enter DoActivateCoreNSSI ::: prepareFailedOperationStatusUpdate ****") + + String serviceId = execution.getVariable("nssiId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() + resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setOperType(operationType) + resourceOperationStatus.setProgress(0) + resourceOperationStatus.setStatus("failed") + resourceOperationStatus.setStatusDescription("Core NSSI Activation Failed") + requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) + + logger.debug(Prefix + " **** Exit DoActivateCoreNSSI ::: prepareFailedOperationStatusUpdate ****") + } + +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/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 new file mode 100644 index 0000000000..64c36e7026 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy @@ -0,0 +1,157 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Tech Mahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts +import org.apache.commons.collections.map.HashedMap +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.beans.nsmf.SliceTaskParams +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceProxy +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.OperationStatus +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.onap.so.serviceinstancebeans.ModelInfo +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import static org.apache.commons.lang3.StringUtils.*; +import com.fasterxml.jackson.databind.ObjectMapper +import groovy.json.JsonSlurper +import javax.ws.rs.core.Response +import org.onap.so.bpmn.common.scripts.OofUtils +import org.onap.so.bpmn.common.scripts.RequestDBUtil + +class DoAllocateCoreNSSI extends AbstractServiceTaskProcessor { + String Prefix="DACNSSI_" + private static final Logger logger = LoggerFactory.getLogger( DoAllocateCoreNSSI.class); + ExceptionUtil exceptionUtil = new ExceptionUtil() + CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + ObjectMapper mapper = new ObjectMapper() + OofUtils oofUtils = new OofUtils() + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix+" **** Enter DoAllocateCoreNSSI ::: preProcessRequest ****") + execution.setVariable("prefix", Prefix) + String msg = "" + //Get SliceProfile from sliceParams JSON + String sliceProfile = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "sliceProfile") + if (isBlank(sliceProfile)) { + msg = "Slice Profile is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("sliceProfile", sliceProfile) + } + String coreServiceInstanceId = UUID.randomUUID().toString() + 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") + try{ + 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") ?: "" + + execution.setVariable("networkServiceModelInfo", networkServiceModelInfo) + logger.debug("***** nsstName is: "+ nsstName) + execution.setVariable("nsstName",nsstName) + }catch(BpmnError e){ + throw e + } catch (Exception ex){ + String msg = "Exception in preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix+" **** Exit DoAllocateCoreNSSI ::: getNSSTName ****") + } + void prepareOOFRequest(DelegateExecution execution){ + logger.debug(Prefix+" **** Enter DoAllocateCoreNSSI ::: prepareOOFRequest ****") + //API Path + String apiPath = "/api/oof/selection/nssi/v1" + logger.debug("API path for DoAllocateCoreNSSI: "+apiPath) + execution.setVariable("NSSI_apiPath", apiPath) + //Setting correlator as requestId + String requestId = execution.getVariable("msoRequestId") + execution.setVariable("NSSI_correlator", requestId) + //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) + String nsstModelUuid = execution.getVariable("modelUuid") + String nsstModelInvariantUuid = execution.getVariable("modelInvariantUuid") + String nsstName = execution.getVariable("nsstName") + String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, messageType, nsstModelUuid, nsstModelInvariantUuid, nsstName, profileInfo) + logger.debug("**** OOfRequest for Core Slice: "+oofRequest) + execution.setVariable("NSSI_oofRequest", oofRequest) + logger.debug(Prefix+" **** Exit DoAllocateCoreNSSI ::: prepareOOFRequest ****") + } + + void processOOFAsyncResponse(DelegateExecution execution) { + logger.debug(Prefix+ " **** Enter DoAllocateCoreNSSI ::: processOOFAsyncResponse ****") + String OOFResponse = execution.getVariable("NSSI_asyncCallbackResponse") + String requestStatus = jsonUtil.getJsonValue(OOFResponse, "requestStatus") + logger.debug("NSSI OOFResponse is: " + OOFResponse) + execution.setVariable("OOFResponse", OOFResponse) + String solutions ="" + if(requestStatus.equals("completed")) { + solutions = jsonUtil.getJsonValue(OOFResponse, "solutions") + } else { + String statusMessage = jsonUtil.getJsonValue(OOFResponse, "statusMessage") + logger.error("received failed status from oof "+ statusMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a failed Async Response from OOF : "+statusMessage) + } + execution.setVariable("solutions", solutions) + logger.debug(Prefix+" **** Exit DoAllocateCoreNSSI ::: processOOFAsyncResponse ****") + } + + void prepareFailedOperationStatusUpdate(DelegateExecution execution){ + logger.debug(Prefix + " **** Enter DoAllocateCoreNSSI ::: prepareFailedOperationStatusUpdate ****") + String serviceId = execution.getVariable("nssiId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() + resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setOperType(operationType) + resourceOperationStatus.setProgress(0) + resourceOperationStatus.setStatus("failed") + resourceOperationStatus.setStatusDescription("Core NSSI Allocate Failed") + requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) + logger.debug(Prefix + " **** Exit DoAllocateCoreNSSI ::: prepareFailedOperationStatusUpdate ****") + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..2a31997cd5 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy @@ -0,0 +1,432 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Tech Mahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.fasterxml.jackson.databind.ObjectMapper + +import groovy.json.JsonOutput + +import static org.hamcrest.CoreMatchers.instanceOf + +import javax.json.JsonArray +import javax.ws.rs.core.Response +import org.apache.commons.collections.map.HashedMap +import org.apache.commons.lang.StringEscapeUtils +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONArray +import org.json.JSONObject +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.ExternalAPIUtil +import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.db.request.beans.OperationStatus +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.aai.domain.yang.v19.ServiceInstance +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceProxy +import org.onap.so.bpmn.core.json.JsonUtils +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.springframework.http.HttpEntity + +import javax.ws.rs.NotFoundException + +class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { + String Prefix="DACNSNSSI_" + private static final Logger logger = LoggerFactory.getLogger( DoAllocateCoreNonSharedSlice.class); + private CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() + private RequestDBUtil requestDBUtil = new RequestDBUtil() + private ExceptionUtil exceptionUtil = new ExceptionUtil() + private JsonUtils jsonUtil = new JsonUtils() + + @Override + public void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix+ "**** Enter DoAllocateCoreNonSharedSlice::: preProcessRequest ****") + String nssiServiceInstanceId= execution.getVariable("serviceInstanceId") + execution.setVariable("nssiServiceInstanceId", nssiServiceInstanceId) + //Set orchestration-status as created + execution.setVariable("orchestrationStatus", "created") + //networkServiceName + String networkServiceName = jsonUtil.getJsonValue(execution.getVariable("networkServiceModelInfo"), "modelName") ?: "" + execution.setVariable("networkServiceName", networkServiceName.replaceAll(" Service Proxy", "")) + //networkServiceModelUuid + String networkServiceModelUuid = jsonUtil.getJsonValue(execution.getVariable("networkServiceModelInfo"), "modelUuid") ?: "" + execution.setVariable("networkServiceModelUuid", networkServiceModelUuid) + logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice::: preProcessRequest ****") + } + + void createNSSIinAAI(DelegateExecution execution) { + logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: Enter createNSSIinAAI ****") + String msg="" + String serviceInstanceId= execution.getVariable("nssiServiceInstanceId") + logger.debug("ServiceInstanceId: "+serviceInstanceId) + try { + String serviceType = execution.getVariable("subscriptionServiceType") + String oStatus = execution.getVariable("orchestrationStatus") + //Get workload context and environment context from DB + String environmentContext = "" + String workloadContext ="" + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + try{ + String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid ) + logger.debug("JSON Response from DB: "+json) + environmentContext = jsonUtil.getJsonValue(json, "serviceResources.environmentContext") ?: "" + workloadContext = jsonUtil.getJsonValue(json, "serviceResources.workloadContext") ?: "" + logger.debug("Env Context is: "+ environmentContext) + logger.debug("Workload Context is: "+ workloadContext) + } catch(BpmnError e){ + throw e + } catch (Exception ex){ + msg = "Exception in createNSSIinAAI ::: DoAllocateCoreNonSharedSlice " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + String serviceInstanceName = "nssi_"+execution.getVariable("nsstName") + ServiceInstance si = new ServiceInstance() + si.setServiceInstanceId(execution.getVariable("nssiServiceInstanceId")) + si.setServiceInstanceName(serviceInstanceName) + si.setServiceType(serviceType) + si.setServiceRole("nssi") + si.setOrchestrationStatus(oStatus) + si.setModelInvariantId(modelInvariantUuid) + si.setModelVersionId(execution.getVariable("modelUuid")) + si.setEnvironmentContext(environmentContext) + si.setWorkloadContext(workloadContext) + logger.debug("AAI service Instance Request Payload : "+si.toString()) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), serviceType, serviceInstanceId) + Response response = getAAIClient().create(uri, si) + if(response.getStatus()!=200) { + exceptionUtil.buildAndThrowWorkflowException(execution, response.getStatus(), "AAI instance creation failed") + } + execution.setVariable("nssiServiceInstance", si) + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in create AAI Instance" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + 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' + execution.setVariable("ExternalAPIURL", extAPIPath) + ObjectMapper objectMapper = new ObjectMapper(); + Map<String, Object> serviceOrder = new LinkedHashMap() + //ExternalId + serviceOrder.put("externalId", "ONAP001") + //Requested Start Date + String requestedStartDate = utils.generateCurrentTimeInUtc() + String requestedCompletionDate = utils.generateCurrentTimeInUtc() + serviceOrder.put("requestedStartDate", requestedStartDate) + serviceOrder.put("requestedCompletionDate", requestedCompletionDate) + //RelatedParty Fields + String relatedPartyId = execution.getVariable("globalSubscriberId") + String relatedPartyRole = "ONAPcustomer" + Map<String, String> relatedParty = new LinkedHashMap() + relatedParty.put("id", relatedPartyId) + relatedParty.put("role", relatedPartyRole) + List<Map<String, String>> relatedPartyList = new ArrayList() + relatedPartyList.add(relatedParty) + serviceOrder.put("relatedParty", relatedPartyList) + Map<String, Object> orderItem = new LinkedHashMap() + //orderItem id + String orderItemId = "1" + orderItem.put("id", orderItemId) + //order item action will always be add as we are triggering request for instantiation + String orderItemAction = "add" + orderItem.put("action", orderItemAction) + // service Details + Map<String, Object> service = new LinkedHashMap() + //ServiceName + String serviceName= "nsi_"+execution.getVariable("networkServiceName") + service.put("name", serviceName) + // Service Type + service.put("serviceType", execution.getVariable("serviceType")) + //Service State + service.put("serviceState", "active") + Map<String, String> serviceSpecification = new LinkedHashMap() + serviceSpecification.put("id", execution.getVariable("networkServiceModelUuid")) + service.put("serviceSpecification", serviceSpecification) + //serviceCharacteristic List + List serviceCharacteristicList = new ArrayList() + Map<String, Object> serviceCharacteristic = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class); + List serviceCharacteristicListMap = retrieveServiceCharacteristicsAsKeyValue(serviceCharacteristic) + logger.debug("serviceCharacteristicListMap "+serviceCharacteristicListMap) + serviceCharacteristicList.add(serviceCharacteristic) + //service.put("serviceCharacteristic", serviceCharacteristicList) + service.put("serviceCharacteristic", serviceCharacteristicListMap) + orderItem.put("service", service) + List<Map<String, String>> orderItemList = new ArrayList() + orderItemList.add(orderItem) + serviceOrder.put("orderItem", orderItemList) + String jsonServiceOrder = objectMapper.writeValueAsString(serviceOrder); + logger.debug("******* ServiceOrder :: "+jsonServiceOrder) + execution.setVariable("serviceOrderRequest", jsonServiceOrder) + logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: prepareServiceOrderRequest****") + } + + private List retrieveServiceCharacteristicsAsKeyValue(Map serviceCharacteristics) { + logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: retrieveServiceCharacteristicsAsKeyValue ****") + List serviceCharacteristicsList = new ArrayList() + ObjectMapper mapperObj = new ObjectMapper(); + Map<String, Object> serviceCharacteristicsObject = new LinkedHashMap() + for (Map.Entry<String, Integer> entry : serviceCharacteristics.entrySet()) { + Map<String, Object> ServiceCharacteristicValueObject = new LinkedHashMap<>() + System.out.println(entry.getKey() + ":" + entry.getValue()); + //For G Release we are sending single value from snssaiList + if(entry.getKey().equals("snssaiList")) { + List sNssaiValue = entry.getValue() + serviceCharacteristicsObject.put("name", "snssai") + ServiceCharacteristicValueObject.put("serviceCharacteristicValue", sNssaiValue.get(0)) + serviceCharacteristicsObject.put("value", ServiceCharacteristicValueObject) + } + } + serviceCharacteristicsList.add(serviceCharacteristicsObject) + logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: retrieveServiceCharacteristicsAsKeyValue ****") + return serviceCharacteristicsList + } + + public void postNBIServiceOrder(DelegateExecution execution) { + logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: postNBIServiceOrder ****") + String msg="" + try { + String extAPIPath = execution.getVariable("ExternalAPIURL") + String payload = execution.getVariable("serviceOrderRequest") + logger.debug("externalAPIURL is: " + extAPIPath) + logger.debug("ServiceOrder payload is: " + payload) + ExternalAPIUtil externalAPIUtil = new ExternalAPIUtilFactory().create() + execution.setVariable("ServiceOrderId", "") + Response response = externalAPIUtil.executeExternalAPIPostCall(execution, extAPIPath, payload) + int responseCode = response.getStatus() + execution.setVariable("PostServiceOrderResponseCode", responseCode) + logger.debug("Post ServiceOrder response code is: " + responseCode) + String extApiResponse = response.readEntity(String.class) + JSONObject responseObj = new JSONObject(extApiResponse) + execution.setVariable("PostServiceOrderResponse", extApiResponse) + logger.debug("ServiceOrder response body is: " + extApiResponse) + //Process Response + if(responseCode == 200 || responseCode == 201 || responseCode == 202 ) + //200 OK 201 CREATED 202 ACCEPTED + { + logger.debug("Post ServiceOrder Received a Good Response") + String serviceOrderId = responseObj.get("id") + execution.setVariable("ServiceOrderId", serviceOrderId) + logger.info("Post ServiceOrderid is: " + serviceOrderId) + } + else{ + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Post ServiceOrder Received a bad response from extAPI serviceOrder API") + } + }catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in ServiceOrder ExtAPI" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("**** Exit DoAllocateCoreNonSharedSlice ::: postNBIServiceOrder ****") + } + + public void getNBIServiceOrderProgress(DelegateExecution execution) { + logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: getNBIServiceOrderProgress ****") + String msg="" + try { + String extAPIPath = execution.getVariable("ExternalAPIURL") + extAPIPath += "/" + execution.getVariable("ServiceOrderId") + logger.debug("getNBIServiceOrderProgress externalAPIURL is: " + extAPIPath) + ExternalAPIUtil externalAPIUtil = new ExternalAPIUtilFactory().create() + Response response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath) + int responseCode = response.getStatus() + execution.setVariable("GetServiceOrderResponseCode", responseCode) + logger.debug("Get ServiceOrder response code is: " + responseCode) + String extApiResponse = response.readEntity(String.class) + JSONObject responseObj = new JSONObject(extApiResponse) + execution.setVariable("GetServiceOrderResponse", extApiResponse) + logger.debug("Create response body is: " + extApiResponse) + //Process Response //200 OK 201 CREATED 202 ACCEPTED + if(responseCode == 200 || responseCode == 201 || responseCode == 202 ) + { + logger.debug("Get Create ServiceOrder Received a Good Response") + String orderState = responseObj.get("state") + if("REJECTED".equalsIgnoreCase(orderState)) { + prepareFailedOperationStatusUpdate(execution) + return + } + JSONArray items = responseObj.getJSONArray("orderItem") + 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)) { + execution.setVariable("status", "processing") + } + else if("COMPLETED".equalsIgnoreCase(serviceOrderState)) { + execution.setVariable("status", "completed") + } + else if("FAILED".equalsIgnoreCase(serviceOrderState)) { + msg = "ServiceOrder failed" + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + else { + msg = "ServiceOrder failed" + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + else{ + msg = "Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode + prepareFailedOperationStatusUpdate(execution) + } + + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e.getMessage()) + } + 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") + Thread.sleep(5000) + logger.debug("**** DoAllocateCoreNonSharedSlice ::: timeDelay wakeup after 5 sec") + } catch(InterruptedException e) { + logger.error(Prefix+ " **** DoAllocateCoreNonSharedSlice ::: timeDelay exception" + e) + } + } + + + 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") + try{ + //Update NSSI orchestration status nssiServiceInstance + ServiceInstance si = execution.getVariable("nssiServiceInstance") + si.setOrchestrationStatus("activated") + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalCustId, serviceType, 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() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + //URI for NSSI + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId); + + //URI for Network Service Instance + AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, networkServiceInstanceId) + + // 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 { + 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) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: updateRelationship ****") + } + + /** + * prepare ResourceOperation status + * @param execution + * @param operationType + */ + private void setResourceOperationStatus(DelegateExecution execution) { + logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: setResourceOperationStatus ****") + String serviceId = execution.getVariable("nssiId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() + resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setOperType(operationType) + resourceOperationStatus.setStatus(execution.getVariable("status")) + resourceOperationStatus.setProgress(execution.getVariable("progress")) + resourceOperationStatus.setStatusDescription(execution.getVariable("statusDescription")) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) + logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: setResourceOperationStatus ****") + } + + void prepareFailedOperationStatusUpdate(DelegateExecution execution){ + logger.debug(Prefix + " **** Enter DoAllocateCoreNonSharedSlice ::: prepareFailedOperationStatusUpdate ****") + String serviceId = execution.getVariable("nssiId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() + resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setOperType(operationType) + resourceOperationStatus.setProgress(0) + resourceOperationStatus.setStatus("failed") + resourceOperationStatus.setStatusDescription("Core NSSI Allocate Failed") + requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) + logger.debug(Prefix + " **** Exit DoAllocateCoreNonSharedSlice ::: prepareFailedOperationStatusUpdate ****") + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..6367341228 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy @@ -0,0 +1,658 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Tech Mahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONObject +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.serviceinstancebeans.CloudConfiguration +import org.onap.so.serviceinstancebeans.LineOfBusiness +import org.onap.so.serviceinstancebeans.ModelInfo +import org.onap.so.serviceinstancebeans.ModelType +import org.onap.so.serviceinstancebeans.OwningEntity +import org.onap.so.serviceinstancebeans.Platform +import org.onap.so.serviceinstancebeans.Project +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.rest.catalog.beans.Vnf +import org.onap.so.serviceinstancebeans.RequestDetails +import org.onap.so.serviceinstancebeans.RequestInfo +import org.onap.so.serviceinstancebeans.RequestParameters +import org.onap.so.serviceinstancebeans.SubscriberInfo +import org.onap.aai.domain.yang.GenericVnf +import org.onap.aai.domain.yang.RelatedToProperty +import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.RelationshipData +import org.onap.aai.domain.yang.RelationshipList +import org.onap.aai.domain.yang.ServiceInstance +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.db.request.beans.OperationStatus +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import com.fasterxml.jackson.databind.ObjectMapper + +import static org.apache.commons.lang3.StringUtils.isBlank + +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response + +class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { + + String Prefix="DACSNSSI_" + private static final Logger logger = LoggerFactory.getLogger(DoAllocateCoreSharedSlice.class); + private CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() + private RequestDBUtil requestDBUtil = new RequestDBUtil() + private ExceptionUtil exceptionUtil = new ExceptionUtil() + private JsonUtils jsonUtil = new JsonUtils() + ObjectMapper mapper = new ObjectMapper(); + + private final Long TIMEOUT = 60 * 60 * 1000 + + @Override + public void preProcessRequest(DelegateExecution execution) { + + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: preProcessRequest ****") + //Get NSSI Solutions + String nssisolutions = execution.getVariable("solutions") + + //Get First Object + List<String> nssiSolutionList = jsonUtil.StringArrayToList(nssisolutions) + + logger.debug("nssiSolutionList : "+nssiSolutionList) + + String nssiId = jsonUtil.getJsonValue(nssiSolutionList.get(0), "NSSIId") + logger.debug("NSSIId : "+nssiId) + + if (isBlank(nssiId)) { + String msg = "solution nssiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("nssiId", nssiId) + } + + String sNssaiListAsString = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "snssaiList") + logger.debug("sNssaiListAsString "+sNssaiListAsString) + List<String> sNssaiList = jsonUtil.StringArrayToList(sNssaiListAsString) + logger.debug("sNssaiList "+sNssaiList) + String sNssai = sNssaiList.get(0) + execution.setVariable("sNssai", sNssai) + logger.debug("sNssai: "+sNssai) + + String serviceType = execution.getVariable("subscriptionServiceType") + execution.setVariable("serviceType", serviceType) + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: preProcessRequest ****") + } + + public void getNetworkInstanceAssociatedWithNssiId(DelegateExecution execution) { + + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: getNetworkInstanceAssociatedWithNssiId ****") + + //NSSI Id as service Instance Id to get from Request + String serviceInstanceId = execution.getVariable("serviceInstanceID") + + String errorMsg = "query Network Service Instance from AAI failed" + AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg) + Optional<ServiceInstance> nsi = wrapper.asBean(ServiceInstance.class) + + String networkServiceInstanceName = "" + String networkServiceInstanceId ="" + if(nsi.isPresent()) { + List<Relationship> relationshipList = nsi.get().getRelationshipList()?.getRelationship() + List spiWithsNssaiAndOrchStatusList = new ArrayList<>() + + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo == "service-instance") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToProperty() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "service-instance.service-instance-id") { + logger.debug("**** service-instance.service-instance-id 1 :: getServiceInstanceRelationships :: "+ relationshipData.getRelationshipValue()) + execution.setVariable("networkServiceInstanceId", relationshipData.getRelationshipValue()) + } + } + for (RelatedToProperty relatedToProperty : relatedToPropertyList) { + if (relatedToProperty.getPropertyKey() == "service-instance.service-instance-name") { + execution.setVariable("networkServiceInstanceName", relatedToProperty.getPropertyValue()) + } + } + } + //If related to is allotted-Resource + if (relatedTo == "allotted-resource") { + //get slice Profile Instance Id from allotted resource in list by nssi + List<String> sliceProfileInstanceIdList = new ArrayList<>() + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "service-instance.service-instance-id") { + sliceProfileInstanceIdList.add(relationshipData.getRelationshipValue()) + } + } + for (String sliceProfileServiceInstanceId : sliceProfileInstanceIdList) { + String errorSliceProfileMsg = "Slice Profile Service Instance was not found in aai" + + //Query Slice Profile Service Instance From AAI by sliceProfileServiceInstanceId + AAIResultWrapper sliceProfileInstanceWrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, sliceProfileServiceInstanceId, errorSliceProfileMsg) + Optional<ServiceInstance> sliceProfileServiceInstance = sliceProfileInstanceWrapper.asBean(ServiceInstance.class) + if (sliceProfileServiceInstance.isPresent()) { + String orchestrationStatus= sliceProfileServiceInstance.get().getOrchestrationStatus() + String sNssai = sliceProfileServiceInstance.get().getSliceProfiles().getSliceProfile().get(0).getSNssai() + if(sNssai.equals(execution.getVariable("sNssai"))) { + orchestrationStatus = execution.getVariable("oStatus") + //Slice Profile Service Instance to be updated in AAI + execution.setVariable("sliceProfileServiceInstance", sliceProfileServiceInstance) + } + + Map<String, Object> spiWithsNssaiAndOrchStatus = new LinkedHashMap<>() + spiWithsNssaiAndOrchStatus.put("snssai", sNssai) + spiWithsNssaiAndOrchStatus.put("status", orchestrationStatus) + spiWithsNssaiAndOrchStatusList.add(spiWithsNssaiAndOrchStatus) + logger.debug("service Profile's NSSAI And Orchestration Status: "+spiWithsNssaiAndOrchStatus) + } + } + } + } + execution.setVariable("snssaiAndOrchStatusList", spiWithsNssaiAndOrchStatusList) + } + + logger.debug("NSSI Id: ${serviceInstanceId}, network Service Instance Id: ${networkServiceInstanceId}, serviceName: ${networkServiceInstanceName}") + + //Get ServiceInstance Relationships + getServiceInstanceRelationships(execution) + + //Get Vnf Relationships + getVnfRelationships(execution) + + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: getNetworkInstanceAssociatedWithNssiId ****") + } + + private void getServiceInstanceRelationships(DelegateExecution execution) { + + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: getServiceInstanceRelationships ****") + + String serviceInstanceId = execution.getVariable("networkServiceInstanceId") + + String errorMsg = "query Network Service Instance from AAI failed" + AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg) + Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) + + String networkServiceModelInvariantUuid = si.get().getModelInvariantId() + execution.setVariable("networkServiceModelInvariantUuid", networkServiceModelInvariantUuid) + if(si.isPresent()) { + List<Relationship> relationshipList = si.get().getRelationshipList()?.getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo == "owning-entity") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "owning-entity.owning-entity-id") { + execution.setVariable("owningEntityId", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "generic-vnf") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToProperty() + + //Get VnfId + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "generic-vnf.vnf-id") { + execution.setVariable("vnfId", relationshipData.getRelationshipValue()) + } + } + + //Get Vnf Name Check If necessary + for (RelatedToProperty relatedToProperty : relatedToPropertyList) { + if (relatedToProperty.getPropertyKey() == "generic-vnf.vnf-name") { + execution.setVariable("vnfName", relatedToProperty.getPropertyValue()) + } + } + } else if (relatedTo == "project") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "project.project-name") { + execution.setVariable("projectName", relationshipData.getRelationshipValue()) + } + } + } + } + + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: getServiceInstanceRelationships ****") + } + } + + private void getVnfRelationships(DelegateExecution execution) { + + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: getVnfRelationships ****") + String msg = "query Generic Vnf from AAI failed" + try { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable('vnfId')) + if (!getAAIClient().exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + AAIResultWrapper wrapper = getAAIClient().get(uri, NotFoundException.class) + Optional<GenericVnf> vnf = wrapper.asBean(GenericVnf.class) + if(vnf.isPresent()) { + List<Relationship> relationshipList = vnf.get().getRelationshipList()?.getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo == "tenant") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "tenant.tenant-id") { + execution.setVariable("tenantId", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "cloud-region") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "cloud-region.cloud-owner") { + execution.setVariable("cloudOwner", relationshipData.getRelationshipValue()) + } else if (relationshipData.getRelationshipKey() == "cloud-region.cloud-region-id") { + execution.setVariable("lcpCloudRegionId", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "platform") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "platform.platform-name") { + execution.setVariable("platformName", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "line-of-business") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "line-of-business.line-of-business-name") { + execution.setVariable("lineOfBusinessName", relationshipData.getRelationshipValue()) + } + } + } + } + } + } catch(BpmnError e){ + throw e + } catch (Exception ex){ + msg = "Exception in getVnfRelationships " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: getVnfRelationships ****") + } + + + /** + * query AAI + * @param execution + * @param aaiObjectType + * @param instanceId + * @return AAIResultWrapper + */ + private AAIResultWrapper queryAAI(DelegateExecution execution, AAIObjectType aaiObjectType, String instanceId, String errorMsg) { + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: queryAAI ****") + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(aaiObjectType, globalSubscriberId, serviceType, instanceId) + if (!getAAIClient().exists(resourceUri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg) + } + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: queryAAI ****") + return wrapper + } + + public void getServiceVNFAndVFsFromCatalogDB(DelegateExecution execution) { + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: getServiceVNFAndVFsFromCatalogDB ****") + String serviceVnfs=""; + String msg="" + String modelInvariantUuid = execution.getVariable("networkServiceModelInvariantUuid") + try{ + CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() + String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution, modelInvariantUuid) + logger.debug("***** JSON IS: "+json) + serviceVnfs = jsonUtil.getJsonValue(json, "serviceResources.serviceVnfs") ?: "" + String serviceModelInfo = jsonUtil.getJsonValue(json, "serviceResources.modelInfo") ?: "" + execution.setVariable("serviceModelInfo", serviceModelInfo) + execution.setVariable("serviceVnfs",serviceVnfs) + logger.debug("***** serviceVnfs is: "+ serviceVnfs) + }catch(BpmnError e){ + throw e + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: getServiceVNFAndVFsFromCatalogDB ****") + } + + public void prepareSOMacroRequestPayload(DelegateExecution execution) { + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: prepareSOMacroRequestPayLoad ****") + String json = execution.getVariable("serviceVnfs") + logger.debug(">>>> json "+json) + List<Object> vnfList = mapper.readValue(json, List.class); + logger.debug("vnfList: "+vnfList) + Map<String,Object> serviceMap = mapper.readValue(execution.getVariable("serviceModelInfo"), Map.class); + ModelInfo serviceModelInfo = new ModelInfo() + serviceModelInfo.setModelType(ModelType.service) + serviceModelInfo.setModelInvariantId(serviceMap.get("modelInvariantUuid")) + serviceModelInfo.setModelVersionId(serviceMap.get("modelUuid")) + serviceModelInfo.setModelName(serviceMap.get("modelName")) + serviceModelInfo.setModelVersion(serviceMap.get("modelVersion")) + logger.debug("serviceModelInfo: "+serviceModelInfo) + //List of Vnfs + List<Object> vnfModelInfoList = new ArrayList<>() + + Map vnfMap = vnfList.get(0) + ModelInfo vnfModelInfo = vnfMap.get("modelInfo") + logger.debug("vnfModelInfo "+vnfModelInfo) + + //List of VFModules + List<Map<String, Object>> vfModuleList = vnfMap.get("vfModules") + logger.debug("vfModuleList "+vfModuleList) + + //List of VfModules + List<ModelInfo> vfModelInfoList = new ArrayList<>() + + //Traverse VFModules List and add in vfModelInfoList + for (vfModule in vfModuleList) { + ModelInfo vfModelInfo = vfModule.get("modelInfo") + logger.debug("vfModelInfo "+vfModelInfo) + vfModelInfoList.add(vfModelInfo) + } + //RequestInfo + RequestInfo requestInfo = new RequestInfo() + + //Dummy Product FamilyId + requestInfo.setProductFamilyId("test1234") + requestInfo.setSource("VID") + requestInfo.setInstanceName(execution.getVariable("networkServiceInstanceName")) + requestInfo.setSuppressRollback(false) + requestInfo.setRequestorId("NBI") + + //Service Level InstanceParams + List<Map<String, Object>> serviceParams = new ArrayList<>() + Map<String, Object> serviceParamsValues = new LinkedHashMap<>() + serviceParams.add(serviceParamsValues) + + //Cloud Configuration + CloudConfiguration cloudConfiguration = new CloudConfiguration() + cloudConfiguration.setLcpCloudRegionId(execution.getVariable("lcpCloudRegionId")) + cloudConfiguration.setTenantId(execution.getVariable("tenantId")) + cloudConfiguration.setCloudOwner(execution.getVariable("cloudOwner")) + + //VFModules List + List<Map<String, Object>> vfModules = new ArrayList<>() + for (ModelInfo vfModuleModelInfo : vfModelInfoList) { + //Individual VFModule List + Map<String, Object> vfModuleValues = new LinkedHashMap<>() + vfModuleValues.put("modelInfo", vfModuleModelInfo) + vfModuleValues.put("instanceName", vfModuleModelInfo.getModelInstanceName()) + + //VFModule InstanceParams should be empty or this field should not be there? + List<Map<String, Object>> vfModuleInstanceParams = new ArrayList<>() + vfModuleValues.put("instanceParams", vfModuleInstanceParams) + } + + //Vnf intsanceParams + Map<String, Object> sliceProfile = mapper.readValue(execution.getVariable("sliceProfile"), Map.class); + + List vnfInstanceParamsList = new ArrayList<>() + String supportedsNssaiJson= prepareVnfInstanceParamsJson(execution) + vnfInstanceParamsList.add(supportedsNssaiJson) + + Platform platform = new Platform() + platform.setPlatformName(execution.getVariable("platform")) + + LineOfBusiness lineOfbusiness = new LineOfBusiness() + lineOfbusiness.setLineOfBusinessName(execution.getVariable("lineOfBusiness")) + + //Vnf Values + Map<String, Object> vnfValues = new LinkedHashMap<>() + vnfValues.put("lineOfBusiness", lineOfbusiness) + vnfValues.put("platform", platform) + vnfValues.put("productFamilyId", "test1234") + vnfValues.put("cloudConfiguration", cloudConfiguration) + vnfValues.put("vfModules", vfModules) + vnfValues.put("modelInfo", vnfModelInfo) + vnfValues.put("instanceName", execution.getVariable("vnfInstanceName")) + vnfValues.put("instanceParams",vnfInstanceParamsList) + + vnfModelInfoList.add(vnfValues) + //Service Level Resources + Map<String, Object> serviceResources = new LinkedHashMap<>() + serviceResources.put("vnfs", vnfModelInfoList) + + //Service Values + Map<String, Object> serviceValues = new LinkedHashMap<>() + serviceValues.put("modelInfo", serviceModelInfo) + serviceValues.put("instanceName", execution.getVariable("networkServiceInstanceName")) + serviceValues.put("resources", serviceResources) + serviceValues.put("instanceParams", serviceParams) + + //UserParams Values + Map<String, Object> userParamsValues = new LinkedHashMap<>() + + Map<String, Object> homingSolution = new LinkedHashMap<>() + homingSolution.put("Homing_Solution", "none") + + userParamsValues.put("service", serviceValues) + + //UserParams + List<Map<String, Object>> userParams = new ArrayList<>() + userParams.add(homingSolution) + userParams.add(userParamsValues) + + //Request Parameters + RequestParameters requestParameters = new RequestParameters() + requestParameters.setaLaCarte(false) + requestParameters.setSubscriptionServiceType(execution.getVariable("serviceType")) + requestParameters.setUserParams(userParams) + + //SubscriberInfo + SubscriberInfo subscriberInfo = new SubscriberInfo() + subscriberInfo.setGlobalSubscriberId(execution.getVariable("globalSubscriberId")) + + //Owning Entity + OwningEntity owningEntity = new OwningEntity() + owningEntity.setOwningEntityId(execution.getVariable("owningEntityId")) + + //Project + Project project = new Project() + project.setProjectName(execution.getVariable("projectName")) + + RequestDetails requestDetails = new RequestDetails() + requestDetails.setModelInfo(serviceModelInfo) + requestDetails.setSubscriberInfo(subscriberInfo) + requestDetails.setRequestInfo(requestInfo) + requestDetails.setRequestParameters(requestParameters) + requestDetails.setCloudConfiguration(cloudConfiguration) + requestDetails.setOwningEntity(owningEntity) + requestDetails.setProject(project) + + Map<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 ****") + } + + private String prepareVnfInstanceParamsJson(DelegateExecution execution) { + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: prepareVnfInstanceParamsJson ****") + List instanceParamsvalues = execution.getVariable("snssaiAndOrchStatusList") + Map<String, Object> nSsai= new LinkedHashMap<>() + nSsai.put("sNssai", instanceParamsvalues) + + String supportedsNssaiJson = mapper.writeValueAsString(nSsai) + //SupportedNssai + Map<String, Object> supportedNssai= new LinkedHashMap<>() + supportedNssai.put("supportedNssai", supportedsNssaiJson) + logger.debug("**** supportedsNssaiJson**** "+supportedNssai) + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: prepareVnfInstanceParamsJson ****") + return supportedNssai + } + + public void sendPutRequestToSOMacro(DelegateExecution execution) { + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: sendPutRequestToSOMacro ****") + try { + String msoEndpoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution) + String url = msoEndpoint+"/serviceInstantiation/v7/serviceInstances/"+execution.getVariable("networkServiceInstanceId")+"/vnfs/"+execution.getVariable("vnfId") + + String requestBody = execution.getVariable("requestPayload") + + String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution) + String basicAuthValue = utils.encrypt(basicAuth, msoKey) + String encodeString = utils.getBasicAuth(basicAuthValue, msoKey) + + HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) + httpClient.addAdditionalHeader("Authorization", encodeString) + httpClient.addAdditionalHeader("Accept", "application/json") + Response httpResponse = httpClient.put(requestBody) + handleSOResponse(httpResponse, execution) + } catch (BpmnError e) { + throw e + } catch (any) { + String msg = Prefix+" Exception in DoAllocateCoreSharedSlice " + any.getCause() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: sendPostRequestToSOMacro ****") + } + + /** + * Handle SO Response for PUT and prepare update operation status + * @param execution + */ + private void handleSOResponse(Response httpResponse, DelegateExecution execution){ + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: handleSOResponse ****") + + int soResponseCode = httpResponse.getStatus() + logger.debug("soResponseCode : "+soResponseCode) + + if (soResponseCode >= 200 && soResponseCode < 204 && httpResponse.hasEntity()) { + String soResponse = httpResponse.readEntity(String.class) + String operationId = execution.getVariable("operationId") + def macroOperationId = jsonUtil.getJsonValue(soResponse, "operationId") + execution.setVariable("macroOperationId", macroOperationId) + execution.setVariable("isSOTimeOut", "no") + execution.setVariable("isSOResponseSucceed","yes") + } + else { + String serviceName = execution.getVariable("serviceInstanceName") + execution.setVariable("isSOResponseSucceed","no") + prepareFailedOperationStatusUpdate(execution) + } + logger.debug(Prefix+" **** Exit 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 ****") + } + + 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 { + execution.setVariable("progress", "100") + execution.setVariable("status", "finished") + execution.setVariable("operationContent", "AllocteCoreNSSI successful.") + logger.debug("prepareFailureStatus,result:${execution.getVariable("result")}, reason: ${execution.getVariable("reason")}") + } + setResourceOperationStatus(execution) + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: prepareUpdateResourceOperationStatus ****") + } + + /** + * prepare ResourceOperation status + * @param execution + * @param operationType + */ + private void setResourceOperationStatus(DelegateExecution execution) { + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: setResourceOperationStatus ****") + String serviceId = execution.getVariable("nssiId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() + resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setOperType(operationType) + resourceOperationStatus.setStatus("finished") + resourceOperationStatus.setProgress("100") + resourceOperationStatus.setStatusDescription("Core Allocate successful") + requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: setResourceOperationStatus ****") + } + + void prepareFailedOperationStatusUpdate(DelegateExecution execution){ + logger.debug(Prefix + " **** Enter DoAllocateCoreSharedSlice ::: prepareFailedOperationStatusUpdate ****") + String serviceId = execution.getVariable("nssiId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() + resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setOperType(operationType) + resourceOperationStatus.setProgress(0) + resourceOperationStatus.setStatus("failed") + resourceOperationStatus.setStatusDescription("Core NSSI Allocate Failed") + requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) + logger.debug(Prefix + " **** Exit DoAllocateCoreSharedSlice ::: prepareFailedOperationStatusUpdate ****") + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationService.groovy index 26dcaa7ac4..7cdb084b7f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationService.groovy @@ -158,11 +158,11 @@ class DoCreateCommunicationService extends AbstractServiceTaskProcessor{ String sNSSAI_id = generateNSSAI(serviceInstanceId) execution.setVariable("sNSSAI_id", sNSSAI_id) - // 创建service + // create communication service String serviceInstanceName = execution.getVariable("serviceInstanceName") String subscriptionServiceType = execution.getVariable("subscriptionServiceType") String csServiceType = execution.getVariable("csServiceType") - String aaiServiceRole = "communication-service" //待确定 + String aaiServiceRole = "communication-service" String oStatus = "processing" String uuiRequest = execution.getVariable("uuiRequest") 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 547cb6cad7..0c795b3bd1 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 @@ -23,6 +23,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.logging.filter.base.ONAPComponents import org.onap.so.beans.nsmf.DeAllocateNssi +import org.onap.so.beans.nsmf.ServiceInfo import org.onap.so.beans.nsmf.EsrInfo import org.onap.so.beans.nsmf.JobStatusRequest import org.onap.so.beans.nsmf.JobStatusResponse @@ -44,7 +45,7 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.db.request.beans.OperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory - +import org.json.JSONObject import javax.ws.rs.core.Response @@ -126,7 +127,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor } LOGGER.debug("*****${PREFIX} Exit processDecomposition *****") } - + /** * send deallocate request to nssmf * @param execution @@ -140,61 +141,106 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor String nssiId = currentNSSI['nssiServiceInstanceId'] String nsiId = currentNSSI['nsiServiceInstanceId'] String scriptName = execution.getVariable("scriptName") + boolean modifyAction = execution.getVariable("terminateNSI") + String serviceInvariantUuid = currentNSSI['modelInvariantId'] + String serviceUuid = currentNSSI['modelVersionId'] + String globalSubscriberId = currentNSSI['globalSubscriberId'] + String subscriptionServiceType = execution.getVariable("serviceType") + DeAllocateNssi deAllocateNssi = new DeAllocateNssi() deAllocateNssi.setNsiId(nsiId) deAllocateNssi.setNssiId(nssiId) deAllocateNssi.setTerminateNssiOption(0) deAllocateNssi.setSnssaiList(Arrays.asList(snssai)) deAllocateNssi.setScriptName(scriptName) - - NssiDeAllocateRequest deAllocateRequest = new NssiDeAllocateRequest() - deAllocateRequest.setDeAllocateNssi(deAllocateNssi) - deAllocateRequest.setEsrInfo(getEsrInfo(currentNSSI)) - - ObjectMapper mapper = new ObjectMapper() - String nssmfRequest = mapper.writeValueAsString(deAllocateRequest) - - String urlStr = String.format("/api/rest/provMns/v1/NSS/SliceProfiles/%s",profileId) + deAllocateNssi.setSliceProfileId(profileId) + deAllocateNssi.setModifyAction(modifyAction) + + ServiceInfo serviceInfo = new ServiceInfo() + serviceInfo.setServiceInvariantUuid(serviceInvariantUuid) + serviceInfo.setServiceUuid(serviceUuid) + serviceInfo.setGlobalSubscriberId(globalSubscriberId) + serviceInfo.setSubscriptionServiceType(subscriptionServiceType) + + EsrInfo esrInfo = getEsrInfo(currentNSSI) + + execution.setVariable("deAllocateNssi",deAllocateNssi) + execution.setVariable("esrInfo",esrInfo) + execution.setVariable("serviceInfo",serviceInfo) + String nssmfRequest = """ + { + "deAllocateNssi": "${execution.getVariable("deAllocateNssi") as JSONObject}", + "esrInfo": ${execution.getVariable("esrInfo") as JSONObject}, + "serviceInfo": ${execution.getVariable("serviceInfo") as JSONObject} + } + """ + + String urlStr = String.format("/api/rest/provMns/v1/NSS/nssi/%s",nssiId) NssiResponse nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlStr, nssmfRequest, NssiResponse.class) if (nssmfResponse != null) { - currentNSSI['jobId']= nssmfResponse.getJobId() ?: "" - currentNSSI['jobProgress'] = 0 - execution.setVariable("currentNSSI", currentNSSI) - - LOGGER.debug("*****${PREFIX} Exit sendRequestToNSSMF *****") - } else { + currentNSSI['jobId']= nssmfResponse.getJobId() ?: "" + currentNSSI['jobProgress'] = 0 + execution.setVariable("currentNSSI", currentNSSI) + } + else { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.") } - + LOGGER.debug("*****${PREFIX} Exit sendRequestToNSSMF *****") } - /** +/** * send to nssmf query progress * @param execution */ - void getJobStatus(DelegateExecution execution) + void prepareJobStatusRequest(DelegateExecution execution) { def currentNSSI = execution.getVariable("currentNSSI") String jobId = currentNSSI['jobId'] String nssiId = currentNSSI['nssiServiceInstanceId'] String nsiId = currentNSSI['nsiServiceInstanceId'] + String serviceInvariantUuid = currentNSSI['modelInvariantId'] + String serviceUuid = currentNSSI['modelVersionId'] + String globalSubscriberId = currentNSSI['globalSubscriberId'] + String subscriptionServiceType = execution.getVariable("serviceType") + String sST = currentNSSI['sST'] + String PLMNIdList = currentNSSI['PLMNIdList'] + String nssiName = currentNSSI['nssiName'] + + execution.setVariable("responseId", "3") + execution.setVariable("esrInfo", getEsrInfo(currentNSSI)) + execution.setVariable("jobId", jobId) + + Map<String, ?> serviceInfoMap = new HashMap<>() + serviceInfoMap.put("nssiId", nssiId) + serviceInfoMap.put("nsiId", nsiId) + serviceInfoMap.put("nssiName", nssiName) + serviceInfoMap.put("sST", sST) + serviceInfoMap.put("PLMNIdList", PLMNIdList) + serviceInfoMap.put("globalSubscriberId", globalSubscriberId) + serviceInfoMap.put("subscriptionServiceType", subscriptionServiceType) + serviceInfoMap.put("serviceInvariantUuid", serviceInvariantUuid) + serviceInfoMap.put("serviceUuid", serviceUuid) + + execution.setVariable("serviceInfo", serviceInfoMap) + } - JobStatusRequest jobStatusRequest = new JobStatusRequest() - jobStatusRequest.setNssiId(nssiId) - jobStatusRequest.setNsiId(nsiId) - jobStatusRequest.setEsrInfo(getEsrInfo(currentNSSI)) - - ObjectMapper mapper = new ObjectMapper() - String nssmfRequest = mapper.writeValueAsString(jobStatusRequest) - - String urlStr = String.format("/api/rest/provMns/v1/NSS/jobs/%s", jobId) - - JobStatusResponse jobStatusResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlStr, nssmfRequest, JobStatusResponse.class) - - if (jobStatusResponse != null) { - def progress = jobStatusResponse?.getResponseDescriptor()?.getProgress() + + /** + * send to nssmf query progress + * @param execution + */ + void handleJobStatus(DelegateExecution execution) + { + try + { + String jobStatusResponse = execution.getVariable("responseDescriptor") + String status = jsonUtil.getJsonValue(jobStatusResponse,"status") + def statusDescription = jsonUtil.getJsonValue(jobStatusResponse,"statusDescription") + def progress = jsonUtil.getJsonValue(jobStatusResponse,"progress") + if(!status.equalsIgnoreCase("failed")) + { if(!progress) { LOGGER.error("job progress is null or empty!") @@ -206,61 +252,60 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor execution.setVariable("isNSSIDeAllocated", (currentProgress == 100)) execution.setVariable("isNeedUpdateDB", (oldProgress != currentProgress)) currentNSSI['jobProgress'] = currentProgress - - def statusDescription = jobStatusResponse?.getResponseDescriptor()?.getStatusDescription() + currentNSSI['status'] = status currentNSSI['statusDescription'] = statusDescription LOGGER.debug("job status result: nsiId = ${nsiId}, nssiId=${nssiId}, oldProgress=${oldProgress}, progress = ${currentProgress}" ) - - } else { + } + else { + execution.setVariable("isNeedUpdateDB", "true") exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.") } - + } + catch (any) + { + String msg = "Received a Bad Response from NSSMF." cause-"+any.getCause()" + LOGGER.error(any.printStackTrace()) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } } private EsrInfo getEsrInfo(def currentNSSI) { String domaintype = currentNSSI['domainType'] String vendor = currentNSSI['vendor'] - + EsrInfo info = new EsrInfo() info.setNetworkType(NetworkType.fromString(domaintype)) info.setVendor(vendor) return info } - /** + /** * handle job status * prepare update requestdb * @param execution */ - void handleJobStatus(DelegateExecution execution) + void prepareUpdateOperationStatus(DelegateExecution execution) { 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("processing") + operationStatus.setResult(status as String) operationStatus.setProgress(progress as String) operationStatus.setOperationContent(statusDes as String) requestDBUtil.prepareUpdateOperationStatus(execution, operationStatus) LOGGER.debug("update operation, currentProgress=${currentProgress}, proportion=${proportion}, progress = ${progress}" ) } - - void timeDelay(DelegateExecution execution) { - try { - Thread.sleep(10000); - } catch(InterruptedException e) { - LOGGER.error("Time Delay exception" + e) - } - } - + /** * delete slice profile from aai * @param execution @@ -291,4 +336,4 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor } LOGGER.debug("*****${PREFIX} Exist delSliceProfileFromAAI *****") } -}
\ No newline at end of file +} 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 5354d52fce..2f78c3d551 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 @@ -25,16 +25,20 @@ 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.SliceProfiles +import org.onap.aai.domain.yang.ServiceProfile +import org.onap.aai.domain.yang.ServiceProfiles import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.OofUtils import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.entities.AAIResultWrapper import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.slf4j.Logger import org.slf4j.LoggerFactory - +import javax.ws.rs.core.Response import javax.ws.rs.NotFoundException import static org.apache.commons.lang3.StringUtils.isBlank @@ -52,6 +56,7 @@ import static org.apache.commons.lang3.StringUtils.isBlank class DoDeleteSliceService extends AbstractServiceTaskProcessor { private final String PREFIX ="DoDeleteSliceService" ExceptionUtil exceptionUtil = new ExceptionUtil() + OofUtils oofUtils = new OofUtils() private static final Logger LOGGER = LoggerFactory.getLogger( DoDeleteSliceService.class) @Override @@ -96,17 +101,47 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { { LOGGER.trace(" *****${PREFIX} Start queryE2ESliceSeriveFromAAI *****") String serviceInstanceId = execution.getVariable("serviceInstanceId") - + try + { String errorMsg = "query e2e slice service from aai failed" AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg) Optional<ServiceInstance> si =wrapper.asBean(ServiceInstance.class) 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 ?: "") - LOGGER.info("serviceInstanceId: ${serviceInstanceId}, snssai: ${snssai}") + execution.setVariable("serviceProfileId",serviceProfileId) + List<ServiceInstance> sliceProfileList = [] + List<Relationship> relationshipList = si.get().getRelationshipList().getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo.toLowerCase() == "service-instance") { + String relatioshipurl = relationship.getRelatedLink() + String instanceId = relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, relatioshipurl.length()) + AAIResultWrapper wrapper1 = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, instanceId, errorMsg) + Optional<ServiceInstance> serviceInstance = wrapper1.asBean(ServiceInstance.class) + if (serviceInstance.isPresent()) { + ServiceInstance instance = serviceInstance.get() + if ("slice-profile-instance".equalsIgnoreCase(instance.getServiceRole())) { + sliceProfileList.add(instance) + } + } + } + } + execution.setVariable("sliceProfileList",sliceProfileList) + LOGGER.info("serviceInstanceId: ${serviceInstanceId}, snssai: ${snssai}, sliceProfileList: ${sliceProfileList}") } LOGGER.trace(" *****${PREFIX} Exit queryE2ESliceSeriveFromAAI *****") + } + catch (any) + { + String msg = "query E2E slice service from aai failed! cause-"+any.getCause() + LOGGER.error(any.printStackTrace()) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); + } } /** @@ -169,7 +204,15 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { if (relatedTo == "service-instance") { String relatedLink = relationship.getRelatedLink()?:"" - String nssiId = relatedLink ? relatedLink.substring(relatedLink.lastIndexOf("/") + 1,relatedLink.length()) : "" + String instanceId = relatedLink ? relatedLink.substring(relatedLink.lastIndexOf("/") + 1,relatedLink.length()) : "" + AAIResultWrapper wrapper1 = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, instanceId, errorMsg) + Optional<ServiceInstance> serviceInstance = wrapper1.asBean(ServiceInstance.class) + if (serviceInstance.isPresent()) { + ServiceInstance instance = serviceInstance.get() + if ("nssi".equalsIgnoreCase(instance.getServiceRole())) { + nssiId = instance.getServiceInstanceId() + } + } nssiIdList.add(nssiId) msg+="${nssiId}, " } @@ -227,12 +270,24 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { { LOGGER.trace(" *****${PREFIX} Start getCurrentNSSI *****") List<ServiceInstance> nssiInstanceList = execution.getVariable("nssiInstanceList") + List<ServiceInstance> sliceProfileList = execution.getVariable("sliceProfileList") int currentIndex = execution.getVariable("currentNSSIIndex") as int + String profileId = "" ServiceInstance nssi = nssiInstanceList?.get(currentIndex) + for(ServiceInstance sliceProfileInstance : sliceProfileList) { + if(sliceProfileInstance.getWorkloadContext().equalsIgnoreCase(nssi.getWorkloadContext())) + { + profileId = sliceProfileInstance.getServiceInstanceId() + } + } def currentNSSI = [:] currentNSSI['nssiServiceInstanceId'] = nssi?.getServiceInstanceId() currentNSSI['modelInvariantId'] = nssi?.getModelInvariantId() currentNSSI['modelVersionId'] = nssi?.getModelVersionId() + currentNSSI['nssiName'] = nssi?.getServiceInstanceName() + currentNSSI['sST'] = nssi?.getServiceType() + currentNSSI['PLMNIdList'] = nssi?.getServiceInstanceLocationId() + currentNSSI['profileId'] = profileId currentNSSI['snssai'] = execution.getVariable("snssai") ?: "" currentNSSI['nsiServiceInstanceId'] = execution.getVariable("nsiId") ?: "" currentNSSI['operationId'] = execution.getVariable("operationId") ?: "" @@ -271,30 +326,6 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { LOGGER.trace(" *****${PREFIX} Exit parseNextNSSI *****") } - - /** - * query sliceProfile from AAI - * save profileId - * @param execution - */ - void querySliceProfileFromAAI(DelegateExecution execution) - { - LOGGER.trace(" *****${PREFIX} Start querySliceProfileFromAAI *****") - def currentNSSI = execution.getVariable("currentNSSI") - String nssiId = currentNSSI['nssiServiceInstanceId'] - String errorMsg = "query slice profile failed" - AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SLICE_PROFILE_ALL, nssiId, errorMsg) - Optional<SliceProfiles> sliceProfiles =wrapper.asBean(SliceProfiles.class) - if(sliceProfiles.isPresent()) - { - String profileId = sliceProfiles.get().getSliceProfile()?.get(0)?.getProfileId() - currentNSSI['profileId'] = profileId ?: "" - LOGGER.info("nssiId: ${nssiId}, profileId: ${profileId}") - } - execution.setVariable("currentNSSI", currentNSSI) - LOGGER.trace(" *****${PREFIX} Exit querySliceProfileFromAAI *****") - } - /** * query AAI * @param execution @@ -317,4 +348,57 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { return wrapper } + void terminateNSIQuery(DelegateExecution execution) + { + logger.debug("Start terminateNSIQuery") + + String requestId = execution.getVariable("msoRequestId") + String nxlId = currentNSSI['nsiServiceInstanceId'] + String nxlType = "NSI" + String messageType = "nsiTerminationResponse" + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + def authHeader = "" + String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution) + String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + + String basicAuthValue = utils.encrypt(basicAuth, msokey) + if (basicAuthValue != null) { + 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) + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " + + "encode username and password string") + } + } else { + logger.debug( "Unable to obtain BasicAuth - BasicAuth value null") + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " + + "value null") + } + + URL requestUrl = new URL(oofUrl + "/api/oof/terminate/nxi/v1") + String oofRequest = oofUtils.buildTerminateNxiRequest(requestId, nxlId, nxlType, messageType, serviceInstanceId) + HttpClient httpClient = new HttpClientFactory().newJsonClient(requestUrl, ONAPComponents.OOF) + httpClient.addAdditionalHeader("Authorization", authHeader) + Response httpResponse = httpClient.post(oofRequest) + + int responseCode = httpResponse.getStatus() + logger.debug("OOF sync response code is: " + responseCode) + + if(responseCode != 200){ + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") + } + try { + Map<String, String> resMap = httpResponse.readEntity(Map.class) + boolean terminateResponse = resMap.get("terminateResponse") + execution.setVariable("terminateNSI", terminateResponse) + } catch (Exception ex) { + 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") + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy new file mode 100644 index 0000000000..47489b7b84 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy @@ -0,0 +1,173 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, Wipro Limited. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +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 static org.apache.commons.lang3.StringUtils.isBlank + +class ModifySliceSubnet extends AbstractServiceTaskProcessor { + String Prefix="MSS_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + + private static final Logger logger = LoggerFactory.getLogger(ModifySliceSubnet.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //NSSI Info + String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") + if (isBlank(serviceInstanceID)) { + msg = "Input serviceInstanceID is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("serviceInstanceID", serviceInstanceID) + } + + String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name") + execution.setVariable("servicename", servicename) + + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + + //requestParameters, subscriptionServiceType is 5G + String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in ModifySliceSubnet.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String serviceId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + "jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType("Modify") + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String modifySyncResponse = """{"jobId": "${jobId}","status": "processing"}""" + .trim().replaceAll(" ", "") + logger.debug("sendSyncResponse to APIH:" + "\n" + modifySyncResponse) + sendWorkflowResponse(execution, 202, modifySyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } + +} 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 new file mode 100644 index 0000000000..5cdf540173 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/QueryJobStatus.groovy @@ -0,0 +1,141 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ================================================================================ + * 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 groovy.json.JsonSlurper +import org.json.JSONObject +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.core.json.JsonUtils +import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.onap.so.bpmn.core.UrnPropertiesReader + +public class QueryJobStatus extends AbstractServiceTaskProcessor{ + private static final Logger logger = LoggerFactory.getLogger(QueryJobStatus.class) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void preProcessRequest(DelegateExecution execution) { + logger.debug("Start preProcessRequest") + + try{ + String requestId = execution.getVariable("msoRequestId") + logger.debug("RequestId :" + requestId) + String responseId = execution.getVariable("responseId") + String jobId = execution.getVariable("jobId") + def jsonSlurper = new JsonSlurper() + + HashMap<String,?> esrInfo=jsonSlurper.parseText(execution.getVariable("esrInfo")) + logger.debug("esrInfo" + esrInfo.toString()) + + HashMap<String,?> serviceInfo=jsonSlurper.parseText(execution.getVariable("serviceInfo")) + logger.debug("serviceInfo" + serviceInfo.toString()) + + execution.setVariable("esrInfo", esrInfo) + execution.setVariable("serviceInfo", serviceInfo) + + String nssmfEndpoint = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint",execution) + 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} + } + """ + + execution.setVariable("NSSMF_AdapterRequest", payload.replaceAll("\\s+", "")) + execution.setVariable("startTime", System.currentTimeMillis()) + logger.debug("Outgoing NSSMF_AdapterRequest: \n" + payload) + }catch(Exception e){ + String msg = "Exception in QueryJobStatus.preProcessRequest " + ex.getMessage() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("exit preProcessRequest") + } + + public void checkJobStatus(DelegateExecution execution) { + logger.debug(" *** checkJobStatus *** ") + def NSSMF_ResponseCode = execution.getVariable("NSSMF_ResponseCode") as Integer + logger.debug("NSSMF_ResponseCode:" + NSSMF_ResponseCode) + def NSSMF_Response = execution.getVariable("NSSMF_Response") as String + def status = jsonUtil.getJsonValue(NSSMF_Response, "responseDescriptor.status") + logger.debug("NSSMF_Response" + NSSMF_Response) + + Long startTime = execution.getVariable("startTime") as Long + Long timeout = execution.getVariable("timeout") as Long + timeout = timeout == null ? 600000 : timeout * 60000 + + if(NSSMF_Response != null) { + if (status.equalsIgnoreCase("processing") && (System.currentTimeMillis() - startTime) > timeout) { + handleTimeOut(execution) + } + else if(status.equalsIgnoreCase("finished") || status.equalsIgnoreCase("failed")) { + execution.setVariable("JobStatusCompleted", "TRUE") + } else { + execution.setVariable("JobStatusCompleted", "FALSE") + } + } else { + Map<String, ?> responseDescriptorMap = new HashMap<>() + responseDescriptorMap.put("status","failed") + responseDescriptorMap.put("statusDescription","Exception while querying job status") + String responseDescriptor = """ + { + "responseDescriptor": "${responseDescriptorMap}", + } + """ + execution.setVariable("JobStatusCompleted", "TRUE") + execution.setVariable("NSSMF_Response",responseDescriptor.replaceAll("\\s+", "")) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.") + } + logger.debug("exit checkJobStatus") + } + + private handleTimeOut(DelegateExecution execution) { + Map<String, ?> responseDescriptorMap = new HashMap<>() + responseDescriptorMap.put("status","failed") + responseDescriptorMap.put("statusDescription","timeout") + String responseDescriptor = """ + { + "responseDescriptor": "${responseDescriptorMap}", + } + """ + execution.setVariable("JobStatusCompleted", "TRUE") + execution.setVariable("NSSMF_Response",responseDescriptor.replaceAll("\\s+", "")) + } + + public void updateJobStatusDetails(DelegateExecution execution) + { + logger.debug("**updateJobStatusDetails**") + def NSSMF_Response = execution.getVariable("NSSMF_Response") as String + def responseDescriptor = jsonUtil.getJsonValue(NSSMF_Response, "responseDescriptor") + execution.setVariable("responseDescriptor",responseDescriptor) + logger.debug("**exit updateJobStatusDetails") + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnetTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnetTest.groovy new file mode 100644 index 0000000000..adb83e7714 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnetTest.groovy @@ -0,0 +1,68 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import static org.junit.Assert.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor + +class ActivateSliceSubnetTest { + @Before + void init() throws IOException { + super.init("ActivateSliceSubnet") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testPreProcessRequest() { + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "serviceInstanceID": "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX ", + "networkType": "an/cn/tn", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "additionalProperties": { + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + } +} +""".replaceAll("\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("edb08d97-e0f9-4c71-840a-72080d7be42e") + when(mockExecution.getVariable("requestAction")).thenReturn("activateInstance") + ActivateSliceSubnet sliceSubnet = new ActivateSliceSubnet() + sliceSubnet.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testPrepareInitOperationStatus() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("54321") + when(mockExecution.getVariable("jobId")).thenReturn("54321") + when(mockExecution.getVariable("nsiId")).thenReturn("11111") + ActivateSliceSubnet sliceSubnet = new ActivateSliceSubnet() + sliceSubnet.prepareInitOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("initResourceOperationStatus"), captor.capture()) + String res = captor.getValue() + assertNotNull(res) + } + + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("jobId")).thenReturn("123456") + ActivateSliceSubnet sliceSubnet = new ActivateSliceSubnet() + sliceSubnet.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertEquals(updateVolumeGroupRequest, true) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnetTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnetTest.groovy new file mode 100644 index 0000000000..a9b4e095e7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnetTest.groovy @@ -0,0 +1,135 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, Wipro Limited. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import static org.junit.Assert.* +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.so.bpmn.common.scripts.MsoGroovyTest + + +class AllocateSliceSubnetTest extends MsoGroovyTest { + + @Before + void init() throws IOException { + super.init("AllocateSliceSubnet") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testPreProcessRequest() { + when(mockExecution.getVariable("serviceInstanceID")).thenReturn("12345") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "name": "eMBB-001", + "modelInvariantUuid": "NSST-C-001-HDBNJ-NSSMF-01-A-ZX", + "modelUuid": "NSST-C-001-HDBNJ-NSSMF-01-A-ZX-UUID", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "networkType": "an/cn/tn", + "additionalProperties": { + "sliceProfile": { + "snssaiList": [ + "001-100001" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098", + "plmnIdList": [ + "460-00", + "460-01" + ], + "perfReq": { + "perfReqEmbbList ": [ + { + "activityFactor": 50 + } + ] + }, + "maxNumberofUEs": 200, + "coverageAreaTAList": [ + "1", + "2", + "3", + "4" + ], + "latency": 2, + "resourceSharingLevel": "non-shared" + }, + "endPoints": [ + { + "nodeId": "", + "additionalInfo": { + "xxx": "xxx" + } + } + ], + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + "scriptName": "AN1" + } +} +""".replaceAll("\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("edb08d97-e0f9-4c71-840a-72080d7be42e") + AllocateSliceSubnet sliceSubnet = new AllocateSliceSubnet() + sliceSubnet.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testPrepareInitOperationStatus() { + + when(mockExecution.getVariable("dummyServiceId")).thenReturn("12345") + when(mockExecution.getVariable("jobId")).thenReturn("54321") + + when(mockExecution.getVariable("nsiId")).thenReturn("11111") + + AllocateSliceSubnet sliceSubnet = new AllocateSliceSubnet() + + sliceSubnet.prepareInitOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("initResourceOperationStatus"), captor.capture()) + String res = captor.getValue() + assertNotNull(res) + } + + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("jobId")).thenReturn("123456") + AllocateSliceSubnet sliceSubnet = new AllocateSliceSubnet() + sliceSubnet.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertEquals(updateVolumeGroupRequest, true) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnetTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnetTest.groovy new file mode 100644 index 0000000000..a254a90576 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnetTest.groovy @@ -0,0 +1,72 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import static org.junit.Assert.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor + +class DeAllocateSliceSubnetTest { + + @Before + void init() throws IOException { + super.init("DeAllocateSliceSubnet") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testPreProcessRequest() { + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "serviceInstanceID": "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX ", + "networkType": "an/cn/tn", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "additionalProperties": { + "snssaiList": [ + "001-100001" + ], + "scriptName": "AN1", + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + } +} +""".replaceAll("\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("edb08d97-e0f9-4c71-840a-72080d7be42e") + DeAllocateSliceSubnet sliceSubnet = new DeAllocateSliceSubnet() + sliceSubnet.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testPrepareInitOperationStatus() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("54321") + when(mockExecution.getVariable("jobId")).thenReturn("54321") + when(mockExecution.getVariable("nsiId")).thenReturn("11111") + DeAllocateSliceSubnet sliceSubnet = new DeAllocateSliceSubnet() + sliceSubnet.prepareInitOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("initResourceOperationStatus"), captor.capture()) + String res = captor.getValue() + assertNotNull(res) + } + + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("jobId")).thenReturn("123456") + DeAllocateSliceSubnet sliceSubnet = new DeAllocateSliceSubnet() + sliceSubnet.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertEquals(updateVolumeGroupRequest, true) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy new file mode 100644 index 0000000000..a39ca04d71 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy @@ -0,0 +1,631 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Tech Mahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import static org.junit.Assert.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.slf4j.Logger +import org.mockito.Mockito +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory + +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when +import static org.mockito.ArgumentMatchers.eq + +import javax.ws.rs.NotFoundException + +class DoActivateCoreNSSITest extends MsoGroovyTest { + + DoActivateCoreNSSI doActivate = new DoActivateCoreNSSI() + @Before + void init() throws IOException { + super.init("DoActivateCoreNSSI") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest(){ + + setUpMockdataFromCommonActivateSliceSubnet() + doActivate.preProcessRequest(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("oStatus"), captor.capture()) + def statusValue = captor.getValue() + assertEquals("deactivated", statusValue) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("sNssai"), captor.capture()) + def sNssai = captor.getValue() + assertEquals("01-5B179BD4", sNssai) + + Mockito.verify(mockExecution,times(3)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testGetNetworkInstanceWithSPInstanceAssociatedWithNssiId(){ + + setUpMockdataFromCommonActivateSliceSubnet() + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + DoActivateCoreNSSI obj = spy(DoActivateCoreNSSI.class) + when(obj.getAAIClient()).thenReturn(client) + AAIResourceUri resourceUri1 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX") + when(client.exists(resourceUri1)).thenReturn(true) + AAIResultWrapper wrapper1 = new AAIResultWrapper(mockQuerySliceServiceReturn()) + when(client.get(resourceUri1, NotFoundException.class)).thenReturn(wrapper1) + + //networkServiceInstanceId + when(mockExecution.getVariable("networkServiceInstanceId")).thenReturn("206535e7-77c9-4036-9387-3f1cf57b4379") + + AAIResourceUri resourceUri2 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "206535e7-77c9-4036-9387-3f1cf57b4379") + when(client.exists(resourceUri2)).thenReturn(true) + AAIResultWrapper wrapper2 = new AAIResultWrapper(mockQueryNS()) + when(client.get(resourceUri2, NotFoundException.class)).thenReturn(wrapper2) + + //Check Vnf + when(mockExecution.getVariable("vnfId")).thenReturn("eeb66c6f-36bd-47ad-8294-48f46b1aa912") + AAIResourceUri resourceUri3 = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "eeb66c6f-36bd-47ad-8294-48f46b1aa912") + when(client.exists(resourceUri3)).thenReturn(true) + AAIResultWrapper wrapper3 = new AAIResultWrapper(mockQueryVnf()) + when(client.get(resourceUri3, NotFoundException.class)).thenReturn(wrapper3) + + + //Allotted Resources-1 + //when(mockExecution.getVariable("vnfId")).thenReturn("eeb66c6f-36bd-47ad-8294-48f46b1aa912") + AAIResourceUri resourceUri4 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "0d3d3cce-46a8-486d-816a-954e71697c4e") + when(client.exists(resourceUri4)).thenReturn(true) + AAIResultWrapper wrapper4 = new AAIResultWrapper(mockServiceProfile1()) + when(client.get(resourceUri4, NotFoundException.class)).thenReturn(wrapper4) + + //Allotted Resources-2 + //when(mockExecution.getVariable("vnfId")).thenReturn("eeb66c6f-36bd-47ad-8294-48f46b1aa912") + AAIResourceUri resourceUri5 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "1c7046f2-a5a3-4d7f-9da8-388ee641a795") + when(client.exists(resourceUri5)).thenReturn(true) + AAIResultWrapper wrapper5 = new AAIResultWrapper(mockServiceProfile2()) + when(client.get(resourceUri5, NotFoundException.class)).thenReturn(wrapper5) + + obj.getNetworkInstanceWithSPInstanceAssociatedWithNssiId(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceInstanceId"), captor.capture()) + assertEquals("206535e7-77c9-4036-9387-3f1cf57b4379", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceInstanceName"), captor.capture()) + assertEquals("nsi_DemoEmbb", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceModelInvariantUuid"), captor.capture()) + assertEquals("848c5656-5594-4d41-84bb-7afc7c64765c", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("owningEntityId"), captor.capture()) + assertEquals("OE-generic", captor.getValue()) + + //VnfId + Mockito.verify(mockExecution, times(1)).setVariable(eq("vnfId"), captor.capture()) + assertEquals("eeb66c6f-36bd-47ad-8294-48f46b1aa912", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("snssaiAndOrchStatusList"), captor.capture()) + List<Map<String, Object>> snssaiList = new ArrayList<>() + Map<String, Object> snssaiMap = new LinkedHashMap<>() + snssaiMap.put("snssai", "01-5C83F071") + snssaiMap.put("status", "activated") + snssaiList.add(snssaiMap) + Map<String, Object> snssaiMap1 = new LinkedHashMap<>() + snssaiMap1.put("snssai", "01-5B179BD4") + snssaiMap1.put("status", "activated") + snssaiList.add(snssaiMap1) + assertEquals(snssaiList, captor.getValue()) + + //Verify Project + Mockito.verify(mockExecution, times(1)).setVariable(eq("projectName"), captor.capture()) + assertEquals("Project-generic", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("tenantId"), captor.capture()) + assertEquals("3d5819f1542e4ef9a4ccb0bcb278ca10", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("cloudOwner"), captor.capture()) + assertEquals("k8scloudowner", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("lcpCloudRegionId"), captor.capture()) + assertEquals("k8sregion", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("platformName"), captor.capture()) + assertEquals("test", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("lineOfBusinessName"), captor.capture()) + assertEquals("LOB-Demonstration", captor.getValue()) + + } + + @Test + void testPrepareVnfInstanceParamsJson() { + List<Map<String, Object>> snssaiList = new ArrayList<>() + Map<String, Object> snssaiMap = new LinkedHashMap<>() + snssaiMap.put("snssai", "01-5C83F071") + snssaiMap.put("status", "activated") + snssaiList.add(snssaiMap) + Map<String, Object> snssaiMap1 = new LinkedHashMap<>() + snssaiMap1.put("snssai", "01-5B179BD4") + snssaiMap1.put("status", "activated") + snssaiList.add(snssaiMap1) + + when(mockExecution.getVariable("snssaiAndOrchStatusList")).thenReturn(snssaiList) + + String returnedJsonAsString= doActivate.prepareVnfInstanceParamsJson(mockExecution) + + String expectedJsonAsString = """{supportedNssai={"sNssai":[{"snssai":"01-5C83F071","status":"activated"},{"snssai":"01-5B179BD4","status":"activated"}]}}""" + assertEquals(expectedJsonAsString, returnedJsonAsString) + } + + + String mockQueryNS() { + return """ + { + "service-instance-id": "206535e7-77c9-4036-9387-3f1cf57b4379", + "service-instance-name": "nsi_DemoEmbb", + "environment-context": "General_Revenue-Bearing", + "workload-context": "Production", + "model-invariant-id": "848c5656-5594-4d41-84bb-7afc7c64765c", + "model-version-id": "2de92587-3395-44e8-bb2c-b9529747e580", + "resource-version": "1599228110527", + "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/206535e7-77c9-4036-9387-3f1cf57b4379/service-data/service-topology/", + "orchestration-status": "Assigned", + "relationship-list": { + "relationship": [{ + "related-to": "owning-entity", + "relationship-label": "org.onap.relationships.inventory.BelongsTo", + "related-link": "/aai/v19/business/owning-entities/owning-entity/OE-generic", + "relationship-data": [{ + "relationship-key": "owning-entity.owning-entity-id", + "relationship-value": "OE-generic" + }] + }, { + "related-to": "generic-vnf", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/network/generic-vnfs/generic-vnf/eeb66c6f-36bd-47ad-8294-48f46b1aa912", + "relationship-data": [{ + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "eeb66c6f-36bd-47ad-8294-48f46b1aa912" + }], + "related-to-property": [{ + "property-key": "generic-vnf.vnf-name", + "property-value": "vfwuctest 0" + }] + }, { + "related-to": "project", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/projects/project/Project-generic", + "relationship-data": [{ + "relationship-key": "project.project-name", + "relationship-value": "Project-generic" + }] + }] + } +} + """ + } + + String mockQueryVnf() { + + return """ + { + "vnf-id": "eeb66c6f-36bd-47ad-8294-48f46b1aa912", + "vnf-name": "vfwuctest 0", + "vnf-type": "vfwuctest/null", + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "prov-status": "PREPROV", + "orchestration-status": "ConfigAssigned", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1599228155361", + "model-invariant-id": "1086e068-c932-4b61-ae3b-2d2eb0cbe3ec", + "model-version-id": "7fbb28cf-7dfc-447a-892c-4a3130b371d2", + "model-customization-id": "471b3188-e8f2-470b-9f4d-89e74d45445f", + "relationship-list": { + "relationship": [{ + "related-to": "tenant", + "relationship-label": "org.onap.relationships.inventory.BelongsTo", + "related-link": "/aai/v19/cloud-infrastructure/cloud-regions/cloud-region/k8scloudowner/k8sregion/tenants/tenant/3d5819f1542e4ef9a4ccb0bcb278ca10", + "relationship-data": [{ + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "k8scloudowner" + }, { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "k8sregion" + }, { + "relationship-key": "tenant.tenant-id", + "relationship-value": "3d5819f1542e4ef9a4ccb0bcb278ca10" + }], + "related-to-property": [{ + "property-key": "tenant.tenant-name", + "property-value": "onap-tm5g-dev" + }] + }, { + "related-to": "cloud-region", + "relationship-label": "org.onap.relationships.inventory.LocatedIn", + "related-link": "/aai/v19/cloud-infrastructure/cloud-regions/cloud-region/k8scloudowner/k8sregion", + "relationship-data": [{ + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "k8scloudowner" + }, { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "k8sregion" + }], + "related-to-property": [{ + "property-key": "cloud-region.owner-defined-type", + "property-value": "OwnerType" + }] + }, { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vfw-k8s/service-instances/service-instance/206535e7-77c9-4036-9387-3f1cf57b4379", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "Demonstration" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "vfw-k8s" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "206535e7-77c9-4036-9387-3f1cf57b4379" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "vfw-0201" + }] + }, { + "related-to": "platform", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/platforms/platform/test", + "relationship-data": [{ + "relationship-key": "platform.platform-name", + "relationship-value": "test" + }] + }, { + "related-to": "line-of-business", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/lines-of-business/line-of-business/LOB-Demonstration", + "relationship-data": [{ + "relationship-key": "line-of-business.line-of-business-name", + "relationship-value": "LOB-Demonstration" + }] + }] + } +} + """ + } + + String mockServiceProfile1() { + return """ + { + "service-instance-id": "0d3d3cce-46a8-486d-816a-954e71697c4e", + "service-instance-name": "DemoEmbb2", + "service-role": "e2esliceprofile-service", + "environment-context": "01-5C83F071", + "model-invariant-id": "040b1b40-3120-446b-b8e3-4f21d153d11e", + "model-version-id": "8b7dabb3-3f27-4555-a9fe-803e862b0292", + "service-instance-location-id": "39-00", + "resource-version": "1593511782269", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4b2bdbc0-cf7e-4c50-882a-f660e3ab8520", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "4b2bdbc0-cf7e-4c50-882a-f660e3ab8520" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "DemoEmbb" + }] + }] + }, + "allotted-resources": { + "allotted-resource": [{ + "id": "362e46c2-cd84-45e4-a6c1-77f4ef88328d", + "model-invariant-id": "e5941a50-ddb4-4f74-be03-25449ae02ddc", + "model-version-id": "ab171d60-c2cc-4903-ac1d-c451b647e461", + "resource-version": "1593511173712", + "type": "Allotted Resource", + "allotted-resource-name": "Allotted_DemoEmbb", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/ea107578-9854-4718-8145-7c7febf0de6c", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "ea107578-9854-4718-8145-7c7febf0de6c" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "nsi_DemoEmbb" + }] + }] + } + }] + }, + "slice-profiles": { + "slice-profile": [{ + "profile-id": "31a83df8-5bd0-4df7-a50f-7900476b81a2", + "latency": 3, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "Beijing;Beijing;HaidianDistrict;WanshouluStreet", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 500, + "exp-data-rate-DL": 2000, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "s-nssai": "01-5C83F071", + "resource-version": "1593525640617" + }] + } +} + + """ + } + + String mockServiceProfile2() { + return """ + { + "service-instance-id": "1c7046f2-a5a3-4d7f-9da8-388ee641a795", + "service-instance-name": "DemoEmbb", + "service-role": "e2esliceprofile-service", + "environment-context": "01-5B179BD4", + "model-invariant-id": "040b1b40-3120-446b-b8e3-4f21d153d12e", + "model-version-id": "8b7dabb3-3f27-4555-a9fe-803e862b0282", + "service-instance-location-id": "39-00", + "resource-version": "1593511782169", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4b2bdbc0-cf7e-4c50-882a-f660e3ab8520", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "4b2bdbc0-cf7e-4c50-882a-f660e3ab8520" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "DemoEmbb" + }] + }] + }, + "allotted-resources": { + "allotted-resource": [{ + "id": "362e46c2-cd84-45e4-a6c1-77f4ef88328d", + "model-invariant-id": "e5941a50-ddb4-4f74-be03-25449ae02ddc", + "model-version-id": "ab171d60-c2cc-4903-ac1d-c451b647e461", + "resource-version": "1593511173712", + "type": "Allotted Resource", + "allotted-resource-name": "Allotted_DemoEmbb", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/ea107578-9854-4718-8145-7c7febf0de6c", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "ea107578-9854-4718-8145-7c7febf0de6c" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "nsi_DemoEmbb" + }] + }] + } + }] + }, + "slice-profiles": { + "slice-profile": [{ + "profile-id": "b86df550-9d70-452b-a5a9-eb8823417255", + "latency": 6, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "Beijing;Beijing;HaidianDistrict;WanshouluStreet", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 500, + "exp-data-rate-DL": 1000, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "s-nssai": "01-5B179BD4", + "resource-version": "1593511356725" + }] + } +} + """ + } + + String mockQuerySliceServiceReturn(){ + String expect = + """{ + "service-instance-id": "NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX", + "service-instance-name": "nssi_DemoEmbb", + "service-role": "nssi", + "environment-context": "cn", + "model-invariant-id": "da575e8e-0863-4172-88b3-b3a9ead67895", + "model-version-id": "e398c92f-27da-44b9-a717-1dbfc1bdd82e", + "service-instance-location-id": "39-00", + "resource-version": "1593525640482", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/206535e7-77c9-4036-9387-3f1cf57b4379", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "206535e7-77c9-4036-9387-3f1cf57b4379" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "nsi_DemoEmbb" + }] + }, + { + "related-to": "allotted-resource", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/0d3d3cce-46a8-486d-816a-954e71697c4e/allotted-resources/allotted-resource/d63c241a-4c0b-4294-b4c3-5a57421a1769", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "0d3d3cce-46a8-486d-816a-954e71697c4e" + }, { + "relationship-key": "allotted-resource.id", + "relationship-value": "d63c241a-4c0b-4294-b4c3-5a57421a1769" + }], + "related-to-property": [{ + "property-key": "allotted-resource.description" + }, { + "property-key": "allotted-resource.allotted-resource-name", + "property-value": "Allotted_DemoEmbb_shared" + }] + }, { + "related-to": "allotted-resource", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/1c7046f2-a5a3-4d7f-9da8-388ee641a795/allotted-resources/allotted-resource/362e46c2-cd84-45e4-a6c1-77f4ef88328d", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "1c7046f2-a5a3-4d7f-9da8-388ee641a795" + }, { + "relationship-key": "allotted-resource.id", + "relationship-value": "362e46c2-cd84-45e4-a6c1-77f4ef88328d" + }], + "related-to-property": [{ + "property-key": "allotted-resource.description" + }, { + "property-key": "allotted-resource.allotted-resource-name", + "property-value": "Allotted_DemoEmbb" + }] + } + ] + } +} + """ + return expect + } + + void setUpMockdataFromCommonActivateSliceSubnet() { + + String bpmnRequest = """ + { + "serviceInstanceID": "NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX", + "networkType": "an/cn/tn", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "additionalProperties": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "snssaiList": [ + "01-5B179BD4" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098" + } + } + """ + + String sliceParams ="""{ + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "snssaiList": [ + "01-5B179BD4" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098" + }""" + + when(mockExecution.getVariable("msoRequestId")).thenReturn("5ad89cf9-0569-4a93-4509-d8324321e2be") + when(mockExecution.getVariable("serviceInstanceID")).thenReturn("NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX") + when(mockExecution.getVariable("nsiId")).thenReturn("NSI-M-001-HDBNJ-NSMF-01-A-ZX") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5G") + when(mockExecution.getVariable("operationType")).thenReturn("deactivateInstance") + when(mockExecution.getVariable("jobId")).thenReturn("5ad89cf9-0569-4a93-9999-d8324321e2be") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(bpmnRequest) + when(mockExecution.getVariable("sliceParams")).thenReturn(sliceParams) + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSITest.groovy new file mode 100644 index 0000000000..dc7a429c2c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSITest.groovy @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Tech Mahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import static org.junit.Assert.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.so.bpmn.common.scripts.MsoGroovyTest + +import static org.mockito.Mockito.when +import static org.mockito.Mockito.times +import static org.mockito.ArgumentMatchers.eq + +class DoAllocateCoreNSSITest extends MsoGroovyTest { + + @Before + void init() throws IOException { + super.init("DoAllocateCoreNSSI") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testPreProcessRequest() { + + String sliceParams="""{ + "sliceProfile": { + "snssaiList": [ + "001-100001" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098", + "plmnIdList": [ + "460-00", + "460-01" + ], + "perfReq": { + "perfReqEmbbList ": [{ + "activityFactor": 50 + }] + }, + "maxNumberofUEs": 200, + "coverageAreaTAList": [ + "1", + "2", + "3", + "4" + ], + "latency": 2, + "resourceSharingLevel": "non-shared" + }, + "endPoints": [{ + "nodeId": "", + "additionalInfo": { + "xxx": "xxx" + } + }, + { + "nodeId": "", + "additionalInfo": { + "xxx": "xxx" + } + } + ], + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + "scriptName": "AN1" +}""" + String expected = """{"plmnIdList":["460-00","460-01"],"sliceProfileId":"ab9af40f13f721b5f13539d87484098","maxNumberofUEs":200,"latency":2,"snssaiList":["001-100001"],"perfReq":{"perfReqEmbbList ":[{"activityFactor":50}]},"coverageAreaTAList":["1","2","3","4"],"resourceSharingLevel":"non-shared"}""" + when(mockExecution.getVariable("sliceParams")).thenReturn(sliceParams) + DoAllocateCoreNSSI allocateNssi = new DoAllocateCoreNSSI() + allocateNssi.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sliceProfile"), captor.capture()) + def sliceProfile = captor.getValue() + assertEquals(expected, sliceProfile) + Mockito.verify(mockExecution, times(3)).setVariable(captor.capture() as String, captor.capture()) + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy new file mode 100644 index 0000000000..1eddf66b86 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy @@ -0,0 +1,118 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Tech Mahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import static org.junit.Assert.* + +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import com.fasterxml.jackson.databind.ObjectMapper + +import static org.mockito.Mockito.when +import static org.mockito.Mockito.times +import static org.mockito.Mockito.eq + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.onap.so.bpmn.common.scripts.MsoGroovyTest + +class DoAllocateCoreNonSharedSliceTest extends MsoGroovyTest { + + @Before + void init() throws IOException { + super.init("DoAllocateCoreNonSharedSlice") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testPreProcessRequest() { + + String networkServiceModelInfo=""" { + "modelName" : "5GC-eMBB Service Proxy", + "modelUuid" : "b666119e-4400-47c6-a0c1-bbe050a33b47", + "modelInvariantUuid" : "a26327e1-4a9b-4883-b7a5-5f37dcb7405a", + "modelVersion" : "1.0", + "modelCustomizationUuid" : "cbc12c2a-67e6-4336-9236-eaf51eacdc75", + "modelInstanceName" : "5gcembb_proxy 0" + }""" + + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("123456") + when(mockExecution.getVariable("networkServiceModelInfo")).thenReturn(networkServiceModelInfo) + + DoAllocateCoreNonSharedSlice allocateNssi = new DoAllocateCoreNonSharedSlice() + allocateNssi.preProcessRequest(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceModelUuid"), captor.capture()) + captor.getValue() + assertEquals("b666119e-4400-47c6-a0c1-bbe050a33b47", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceName"), captor.capture()) + assertEquals("5GC-eMBB", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("orchestrationStatus"), captor.capture()) + assertEquals("created", captor.getValue()) + Mockito.verify(mockExecution, times(4)).setVariable(captor.capture() as String, captor.capture()) + } + + @Test + void testPrepareServiceOrderRequest() { + + 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 }" + when(mockExecution.getVariable("sliceProfile")).thenReturn(sliceProfile) + when(mockExecution.getVariable("serviceType")).thenReturn("5g") + when(mockExecution.getVariable("networkServiceName")).thenReturn("5g_embb") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("networkServiceModelUuid")).thenReturn("12345") + + DoAllocateCoreNonSharedSlice allocateNssi = new DoAllocateCoreNonSharedSlice() + allocateNssi.prepareServiceOrderRequest(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("serviceOrderRequest"), captor.capture()) + String value = captor.getValue() + assertNotNull(value) + } + + @Test + void testRetrieveServiceCharacteristicsAsKeyValue() { + + 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 }" + Map<String, Object> ServiceCharacteristicValue = new LinkedHashMap<>() + Map<String, Object> ServiceCharacteristicValueObject = new LinkedHashMap<>() + ServiceCharacteristicValueObject.put("serviceCharacteristicValue","001-100001") + ServiceCharacteristicValue.put("name", "snssai") + ServiceCharacteristicValue.put("value", ServiceCharacteristicValueObject) + + List expectedList= new ArrayList() + expectedList.add(ServiceCharacteristicValue) + + ObjectMapper objectMapper = new ObjectMapper() + Map<String, Object> serviceCharacteristic = objectMapper.readValue(sliceProfile, Map.class); + + DoAllocateCoreNonSharedSlice allocateNssi = new DoAllocateCoreNonSharedSlice() + List characteristicList=allocateNssi.retrieveServiceCharacteristicsAsKeyValue(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 new file mode 100644 index 0000000000..e5799eca66 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSliceTest.groovy @@ -0,0 +1,646 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Tech Mahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import static org.junit.Assert.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.mockito.Mockito +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory + +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when +import static org.mockito.ArgumentMatchers.eq + +import javax.ws.rs.NotFoundException + +class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { + + DoAllocateCoreSharedSlice allocate = new DoAllocateCoreSharedSlice() + + @Before + void init() throws IOException { + super.init("DoAllocateCoreSharedSlice") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest(){ + + String solutions = """ [ + { + "invariantUUID": "y7685f64-5717-4562-b3fc-2c963f66afa6", + "UUID": "8u785f64-5717-4562-b3fc-2c963f66afa6", + "NSSIName": "embb-core-ser", + "NSSIId": "f4485f64-5717-4562-b3fc-2c963f66afa6", + "matchLevel": { + "blob":"content" + } + } + ]""" + String sliceProfile = "{\r\n \"snssaiList\": [ \r\n \"001-100001\"\r\n ],\r\n \"sliceProfileId\": \"ab9af40f13f721b5f13539d87484098\",\r\n \"plmnIdList\": [\r\n \"460-00\",\r\n \"460-01\"\r\n ],\r\n \"perfReq\": {\r\n \"perfReqEmbbList \": [\r\n {\r\n \"activityFactor\": 50\r\n }\r\n ]\r\n },\r\n \"maxNumberofUEs\": 200, \r\n \"coverageAreaTAList\": [ \r\n \"1\",\r\n \"2\",\r\n \"3\",\r\n \"4\"\r\n ],\r\n \"latency\": 2,\r\n \"resourceSharingLevel\": \"non-shared\" \r\n }" + + setUpBaseMockData() + + when(mockExecution.getVariable("solutions")).thenReturn(solutions) + when(mockExecution.getVariable("sliceProfile")).thenReturn(sliceProfile) + + allocate.preProcessRequest(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("nssiId"), captor.capture()) + def nssiId = captor.getValue() + assertEquals("f4485f64-5717-4562-b3fc-2c963f66afa6", nssiId) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("sNssai"), captor.capture()) + def sNssai = captor.getValue() + assertEquals("001-100001", sNssai) + + Mockito.verify(mockExecution,times(3)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + public void tesPrepareSOMacroRequestPayload() { + + 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 }" + String vnfs="[{\"toscaNodeType\":\"VF\",\"vfModules\":[{\"initialCount\":0,\"vfModuleLabel\":\"label\",\"modelInfo\":{\"modelInvariantUuid\":\"06bd0a18-65c0-4418-83c7-5b0d13cba01a\",\"modelName\":\"NetworkFqdnTest4\",\"modelVersion\":\"2.0\",\"modelCustomizationUuid\":\"06bd0a18-65c0-4418-83c7-5b0d13cba01a\",\"modelUuid\":\"025606c1-4223-11e7-9252-005056850d2e\"},\"hasVolumeGroup\":true,\"isBase\":true},{\"initialCount\":0,\"vfModuleLabel\":\"label\",\"modelInfo\":{\"modelInvariantUuid\":\"06bd0a18-65c0-4418-83c7-5b0d13cba0bb\",\"modelName\":\"NetworkFqdnTest3\",\"modelVersion\":\"1.0\",\"modelCustomizationUuid\":\"06bd0a18-65c0-4418-83c7-5b0d13cba0bb\",\"modelUuid\":\"02560575-4223-11e7-9252-005056850d2e\"},\"hasVolumeGroup\":false,\"isBase\":true},{\"initialCount\":0,\"vfModuleLabel\":\"label\",\"modelInfo\":{\"modelInvariantUuid\":\"06bd0a18-65c0-4418-83c7-5b0d14cba01a\",\"modelName\":\"NetworkFqdnTest5\",\"modelVersion\":\"1.0\",\"modelCustomizationUuid\":\"06bd0a18-65c0-4418-83c7-5b0d14cba01a\",\"modelUuid\":\"025607e4-4223-11e7-9252-005056850d2e\"},\"hasVolumeGroup\":false,\"isBase\":false},{\"initialCount\":0,\"vfModuleLabel\":\"PCM\",\"modelInfo\":{\"modelInvariantUuid\":\"93e9c1d2-7d37-11e7-bb31-be2e44b06b34\",\"modelName\":\"vSAMP10aDEV::PCM::module-2\",\"modelVersion\":\"2\",\"modelCustomizationUuid\":\"6728bee8-7d3a-11e7-bb31-be2e44b06b34\",\"modelUuid\":\"7774b4e4-7d37-11e7-bb31-be2e44b06b34\"},\"hasVolumeGroup\":true,\"isBase\":false},{\"initialCount\":0,\"vfModuleLabel\":\"PCM\",\"modelInfo\":{\"modelInvariantUuid\":\"64efd51a-2544-11e7-93ae-92361f002671\",\"modelName\":\"vSAMP10aDEV::PCM::module-1\",\"modelVersion\":\"2\",\"modelCustomizationUuid\":\"b4ea86b4-253f-11e7-93ae-92361f002671\",\"modelUuid\":\"066de97e-253e-11e7-93ae-92361f002671\"},\"hasVolumeGroup\":true,\"isBase\":false},{\"initialCount\":1,\"vfModuleLabel\":\"base\",\"modelInfo\":{\"modelInvariantUuid\":\"78ca26d0-246d-11e7-93ae-92361f002671\",\"modelName\":\"vSAMP10aDEV::base::module-0\",\"modelVersion\":\"2\",\"modelCustomizationUuid\":\"cb82ffd8-252a-11e7-93ae-92361f002671\",\"modelUuid\":\"20c4431c-246d-11e7-93ae-92361f002671\"},\"hasVolumeGroup\":true,\"isBase\":true},{\"initialCount\":1,\"vfModuleLabel\":\"base\",\"modelInfo\":{\"modelInvariantUuid\":null,\"modelName\":\"vSAMP10a::base::module-0\",\"modelVersion\":\"2\",\"modelCustomizationUuid\":\"MIGRATED_36e76920-ef30-4793-9979-cbd7d4b2bfc4\",\"modelUuid\":\"02560de2-4223-11e7-9252-005056850d2e\"},\"hasVolumeGroup\":true,\"isBase\":true},{\"initialCount\":1,\"vfModuleLabel\":\"module-0\",\"modelInfo\":{\"modelInvariantUuid\":null,\"modelName\":\"base::module-0\",\"modelVersion\":\"1\",\"modelCustomizationUuid\":\"MIGRATED_51baae4c-b7c7-4f57-b77e-6e01acca89e5\",\"modelUuid\":\"02561381-4223-11e7-9252-005056850d2e\"},\"hasVolumeGroup\":false,\"isBase\":true},{\"initialCount\":1,\"vfModuleLabel\":\"PCM\",\"modelInfo\":{\"modelInvariantUuid\":null,\"modelName\":\"vSAMP10a::PCM::module-1\",\"modelVersion\":\"1\",\"modelCustomizationUuid\":\"MIGRATED_e9be2ed7-45b6-479c-b06e-9093899f8ce8\",\"modelUuid\":\"02560f1b-4223-11e7-9252-005056850d2e\"},\"hasVolumeGroup\":true,\"isBase\":true}],\"modelInfo\":{\"modelInvariantUuid\":\"2fff5b20-214b-11e7-93ae-92361f002671\",\"modelName\":\"vSAMP10a\",\"modelVersion\":\"1.0\",\"modelCustomizationUuid\":\"68dc9a92-214c-11e7-93ae-92361f002671\",\"modelInstanceName\":\"vSAMP10a 1\",\"modelUuid\":\"ff2ae348-214a-11e7-93ae-92361f002671\"},\"nfRole\":null,\"nfType\":null,\"multiStageDesign\":null,\"nfFunction\":null,\"nfNamingCode\":null}]\r\n" + String service = "{\r\n \"modelName\" : \"eMBB-NSST\",\r\n \"modelUuid\" : \"ecfa2329-8765-4665-84e0-a32a2ac2be90\",\r\n \"modelInvariantUuid\" : \"2eeeb5ff-4655-47d8-8aa3-044682246b60\",\r\n \"modelVersion\" : \"1.0\"\r\n }" + + when(mockExecution.getVariable("serviceVnfs")).thenReturn(vnfs) + + when(mockExecution.getVariable("serviceType")).thenReturn("5g") + when(mockExecution.getVariable("vnfs")).thenReturn(vnfs) + when(mockExecution.getVariable("serviceModelInfo")).thenReturn(service) + when(mockExecution.getVariable("sliceProfile")).thenReturn(sliceProfile) + allocate.prepareSOMacroRequestPayload(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("requestPayload"), captor.capture()) + assertNotNull(captor.getValue()) + } + + @Test + void testPrepareVnfInstanceParamsJson() { + List<Map<String, Object>> snssaiList = new ArrayList<>() + Map<String, Object> snssaiMap = new LinkedHashMap<>() + snssaiMap.put("snssai", "01-5C83F071") + snssaiMap.put("status", "activated") + snssaiList.add(snssaiMap) + Map<String, Object> snssaiMap1 = new LinkedHashMap<>() + snssaiMap1.put("snssai", "01-5B179BD4") + snssaiMap1.put("status", "activated") + snssaiList.add(snssaiMap1) + + 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"}]}}""" + assertEquals(expectedJsonAsString, returnedJsonAsString) + } + + @Test + void testGetNetworkInstanceWithSPInstanceAssociatedWithNssiId(){ + + setUpBaseMockData() + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + DoAllocateCoreSharedSlice obj = spy(DoAllocateCoreSharedSlice.class) + when(obj.getAAIClient()).thenReturn(client) + AAIResourceUri resourceUri1 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX") + when(client.exists(resourceUri1)).thenReturn(true) + AAIResultWrapper wrapper1 = new AAIResultWrapper(mockQuerySliceServiceReturn()) + when(client.get(resourceUri1, NotFoundException.class)).thenReturn(wrapper1) + + //networkServiceInstanceId + when(mockExecution.getVariable("networkServiceInstanceId")).thenReturn("206535e7-77c9-4036-9387-3f1cf57b4379") + + AAIResourceUri resourceUri2 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "206535e7-77c9-4036-9387-3f1cf57b4379") + when(client.exists(resourceUri2)).thenReturn(true) + AAIResultWrapper wrapper2 = new AAIResultWrapper(mockQueryNS()) + when(client.get(resourceUri2, NotFoundException.class)).thenReturn(wrapper2) + + //Check Vnf + when(mockExecution.getVariable("vnfId")).thenReturn("eeb66c6f-36bd-47ad-8294-48f46b1aa912") + AAIResourceUri resourceUri3 = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "eeb66c6f-36bd-47ad-8294-48f46b1aa912") + when(client.exists(resourceUri3)).thenReturn(true) + AAIResultWrapper wrapper3 = new AAIResultWrapper(mockQueryVnf()) + when(client.get(resourceUri3, NotFoundException.class)).thenReturn(wrapper3) + + + //Allotted Resources-1 + AAIResourceUri resourceUri4 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "0d3d3cce-46a8-486d-816a-954e71697c4e") + when(client.exists(resourceUri4)).thenReturn(true) + AAIResultWrapper wrapper4 = new AAIResultWrapper(mockServiceProfile1()) + when(client.get(resourceUri4, NotFoundException.class)).thenReturn(wrapper4) + + //Allotted Resources-2 + AAIResourceUri resourceUri5 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "1c7046f2-a5a3-4d7f-9da8-388ee641a795") + when(client.exists(resourceUri5)).thenReturn(true) + AAIResultWrapper wrapper5 = new AAIResultWrapper(mockServiceProfile2()) + when(client.get(resourceUri5, NotFoundException.class)).thenReturn(wrapper5) + + obj.getNetworkInstanceAssociatedWithNssiId(mockExecution) + + //networkServiceInstanceId + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceInstanceId"), captor.capture()) + assertEquals("206535e7-77c9-4036-9387-3f1cf57b4379", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceInstanceName"), captor.capture()) + assertEquals("nsi_DemoEmbb", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceModelInvariantUuid"), captor.capture()) + assertEquals("848c5656-5594-4d41-84bb-7afc7c64765c", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("owningEntityId"), captor.capture()) + assertEquals("OE-generic", captor.getValue()) + + //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") + snssaiList.add(snssaiMap) + Map<String, Object> snssaiMap1 = new LinkedHashMap<>() + snssaiMap1.put("snssai", "01-5B179BD4") + snssaiMap1.put("orchestrationStatus", "activated") + snssaiList.add(snssaiMap1) + assertEquals(snssaiList, captor.getValue()) + + //Verify Project + Mockito.verify(mockExecution, times(1)).setVariable(eq("projectName"), captor.capture()) + assertEquals("Project-generic", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("tenantId"), captor.capture()) + assertEquals("3d5819f1542e4ef9a4ccb0bcb278ca10", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("cloudOwner"), captor.capture()) + assertEquals("k8scloudowner", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("lcpCloudRegionId"), captor.capture()) + assertEquals("k8sregion", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("platformName"), captor.capture()) + assertEquals("test", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("lineOfBusinessName"), captor.capture()) + assertEquals("LOB-Demonstration", captor.getValue()) + + } + + void setUpBaseMockData() { + + String sliceParams ="""{ + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "snssaiList": [ + "01-5B179BD4" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098" + }""" + + when(mockExecution.getVariable("msoRequestId")).thenReturn("5ad89cf9-0569-4a93-4509-d8324321e2be") + when(mockExecution.getVariable("serviceInstanceID")).thenReturn("NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX") + when(mockExecution.getVariable("nsiId")).thenReturn("NSI-M-001-HDBNJ-NSMF-01-A-ZX") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5G") + when(mockExecution.getVariable("operationType")).thenReturn("deactivateInstance") + when(mockExecution.getVariable("jobId")).thenReturn("5ad89cf9-0569-4a93-9999-d8324321e2be") + when(mockExecution.getVariable("sliceParams")).thenReturn(sliceParams) + } + + String mockQueryNS() { + return """ + { + "service-instance-id": "206535e7-77c9-4036-9387-3f1cf57b4379", + "service-instance-name": "nsi_DemoEmbb", + "environment-context": "General_Revenue-Bearing", + "workload-context": "Production", + "model-invariant-id": "848c5656-5594-4d41-84bb-7afc7c64765c", + "model-version-id": "2de92587-3395-44e8-bb2c-b9529747e580", + "resource-version": "1599228110527", + "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/206535e7-77c9-4036-9387-3f1cf57b4379/service-data/service-topology/", + "orchestration-status": "Assigned", + "relationship-list": { + "relationship": [{ + "related-to": "owning-entity", + "relationship-label": "org.onap.relationships.inventory.BelongsTo", + "related-link": "/aai/v19/business/owning-entities/owning-entity/OE-generic", + "relationship-data": [{ + "relationship-key": "owning-entity.owning-entity-id", + "relationship-value": "OE-generic" + }] + }, { + "related-to": "generic-vnf", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/network/generic-vnfs/generic-vnf/eeb66c6f-36bd-47ad-8294-48f46b1aa912", + "relationship-data": [{ + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "eeb66c6f-36bd-47ad-8294-48f46b1aa912" + }], + "related-to-property": [{ + "property-key": "generic-vnf.vnf-name", + "property-value": "vfwuctest 0" + }] + }, { + "related-to": "project", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/projects/project/Project-generic", + "relationship-data": [{ + "relationship-key": "project.project-name", + "relationship-value": "Project-generic" + }] + }] + } +} + """ + } + + String mockQueryVnf() { + + return """ + { + "vnf-id": "eeb66c6f-36bd-47ad-8294-48f46b1aa912", + "vnf-name": "vfwuctest 0", + "vnf-type": "vfwuctest/null", + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "prov-status": "PREPROV", + "orchestration-status": "ConfigAssigned", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1599228155361", + "model-invariant-id": "1086e068-c932-4b61-ae3b-2d2eb0cbe3ec", + "model-version-id": "7fbb28cf-7dfc-447a-892c-4a3130b371d2", + "model-customization-id": "471b3188-e8f2-470b-9f4d-89e74d45445f", + "relationship-list": { + "relationship": [{ + "related-to": "tenant", + "relationship-label": "org.onap.relationships.inventory.BelongsTo", + "related-link": "/aai/v19/cloud-infrastructure/cloud-regions/cloud-region/k8scloudowner/k8sregion/tenants/tenant/3d5819f1542e4ef9a4ccb0bcb278ca10", + "relationship-data": [{ + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "k8scloudowner" + }, { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "k8sregion" + }, { + "relationship-key": "tenant.tenant-id", + "relationship-value": "3d5819f1542e4ef9a4ccb0bcb278ca10" + }], + "related-to-property": [{ + "property-key": "tenant.tenant-name", + "property-value": "onap-tm5g-dev" + }] + }, { + "related-to": "cloud-region", + "relationship-label": "org.onap.relationships.inventory.LocatedIn", + "related-link": "/aai/v19/cloud-infrastructure/cloud-regions/cloud-region/k8scloudowner/k8sregion", + "relationship-data": [{ + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "k8scloudowner" + }, { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "k8sregion" + }], + "related-to-property": [{ + "property-key": "cloud-region.owner-defined-type", + "property-value": "OwnerType" + }] + }, { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vfw-k8s/service-instances/service-instance/206535e7-77c9-4036-9387-3f1cf57b4379", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "Demonstration" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "vfw-k8s" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "206535e7-77c9-4036-9387-3f1cf57b4379" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "vfw-0201" + }] + }, { + "related-to": "platform", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/platforms/platform/test", + "relationship-data": [{ + "relationship-key": "platform.platform-name", + "relationship-value": "test" + }] + }, { + "related-to": "line-of-business", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/lines-of-business/line-of-business/LOB-Demonstration", + "relationship-data": [{ + "relationship-key": "line-of-business.line-of-business-name", + "relationship-value": "LOB-Demonstration" + }] + }] + } +} + """ + } + + String mockQuerySliceServiceReturn(){ + String expect = + """{ + "service-instance-id": "NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX", + "service-instance-name": "nssi_DemoEmbb", + "service-role": "nssi", + "environment-context": "cn", + "model-invariant-id": "da575e8e-0863-4172-88b3-b3a9ead67895", + "model-version-id": "e398c92f-27da-44b9-a717-1dbfc1bdd82e", + "service-instance-location-id": "39-00", + "resource-version": "1593525640482", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/206535e7-77c9-4036-9387-3f1cf57b4379", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "206535e7-77c9-4036-9387-3f1cf57b4379" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "nsi_DemoEmbb" + }] + }, + { + "related-to": "allotted-resource", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/0d3d3cce-46a8-486d-816a-954e71697c4e/allotted-resources/allotted-resource/d63c241a-4c0b-4294-b4c3-5a57421a1769", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "0d3d3cce-46a8-486d-816a-954e71697c4e" + }, { + "relationship-key": "allotted-resource.id", + "relationship-value": "d63c241a-4c0b-4294-b4c3-5a57421a1769" + }], + "related-to-property": [{ + "property-key": "allotted-resource.description" + }, { + "property-key": "allotted-resource.allotted-resource-name", + "property-value": "Allotted_DemoEmbb_shared" + }] + }, { + "related-to": "allotted-resource", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/1c7046f2-a5a3-4d7f-9da8-388ee641a795/allotted-resources/allotted-resource/362e46c2-cd84-45e4-a6c1-77f4ef88328d", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "1c7046f2-a5a3-4d7f-9da8-388ee641a795" + }, { + "relationship-key": "allotted-resource.id", + "relationship-value": "362e46c2-cd84-45e4-a6c1-77f4ef88328d" + }], + "related-to-property": [{ + "property-key": "allotted-resource.description" + }, { + "property-key": "allotted-resource.allotted-resource-name", + "property-value": "Allotted_DemoEmbb" + }] + } + ] + } +} + """ + return expect + } + + String mockServiceProfile1() { + return """{ + "service-instance-id": "0d3d3cce-46a8-486d-816a-954e71697c4e", + "service-instance-name": "DemoEmbb2", + "service-role": "e2esliceprofile-service", + "environment-context": "01-5C83F071", + "model-invariant-id": "040b1b40-3120-446b-b8e3-4f21d153d11e", + "model-version-id": "8b7dabb3-3f27-4555-a9fe-803e862b0292", + "service-instance-location-id": "39-00", + "resource-version": "1593511782269", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4b2bdbc0-cf7e-4c50-882a-f660e3ab8520", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "4b2bdbc0-cf7e-4c50-882a-f660e3ab8520" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "DemoEmbb" + }] + }] + }, + "allotted-resources": { + "allotted-resource": [{ + "id": "362e46c2-cd84-45e4-a6c1-77f4ef88328d", + "model-invariant-id": "e5941a50-ddb4-4f74-be03-25449ae02ddc", + "model-version-id": "ab171d60-c2cc-4903-ac1d-c451b647e461", + "resource-version": "1593511173712", + "type": "Allotted Resource", + "allotted-resource-name": "Allotted_DemoEmbb", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/ea107578-9854-4718-8145-7c7febf0de6c", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "ea107578-9854-4718-8145-7c7febf0de6c" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "nsi_DemoEmbb" + }] + }] + } + }] + }, + "slice-profiles": { + "slice-profile": [{ + "profile-id": "31a83df8-5bd0-4df7-a50f-7900476b81a2", + "latency": 3, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "Beijing;Beijing;HaidianDistrict;WanshouluStreet", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 500, + "exp-data-rate-DL": 2000, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "s-nssai": "01-5C83F071", + "resource-version": "1593525640617" + }] + } +}""" + } + + String mockServiceProfile2() { + return """{ + "service-instance-id": "1c7046f2-a5a3-4d7f-9da8-388ee641a795", + "service-instance-name": "DemoEmbb", + "service-role": "e2esliceprofile-service", + "environment-context": "01-5B179BD4", + "model-invariant-id": "040b1b40-3120-446b-b8e3-4f21d153d12e", + "model-version-id": "8b7dabb3-3f27-4555-a9fe-803e862b0282", + "service-instance-location-id": "39-00", + "resource-version": "1593511782169", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4b2bdbc0-cf7e-4c50-882a-f660e3ab8520", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "4b2bdbc0-cf7e-4c50-882a-f660e3ab8520" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "DemoEmbb" + }] + }] + }, + "allotted-resources": { + "allotted-resource": [{ + "id": "362e46c2-cd84-45e4-a6c1-77f4ef88328d", + "model-invariant-id": "e5941a50-ddb4-4f74-be03-25449ae02ddc", + "model-version-id": "ab171d60-c2cc-4903-ac1d-c451b647e461", + "resource-version": "1593511173712", + "type": "Allotted Resource", + "allotted-resource-name": "Allotted_DemoEmbb", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/ea107578-9854-4718-8145-7c7febf0de6c", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "ea107578-9854-4718-8145-7c7febf0de6c" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "nsi_DemoEmbb" + }] + }] + } + }] + }, + "slice-profiles": { + "slice-profile": [{ + "profile-id": "b86df550-9d70-452b-a5a9-eb8823417255", + "latency": 6, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "Beijing;Beijing;HaidianDistrict;WanshouluStreet", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 500, + "exp-data-rate-DL": 1000, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "s-nssai": "01-5B179BD4", + "resource-version": "1593511356725" + }] + } +}""" + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnetTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnetTest.groovy new file mode 100644 index 0000000000..b7515a487c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnetTest.groovy @@ -0,0 +1,72 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import static org.junit.Assert.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor + +class ModifySliceSubnetTest { + @Before + void init() throws IOException { + super.init("ModifySliceSubnet") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testPreProcessRequest() { + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "serviceInstanceID": "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX ", + "networkType": "an/cn/tn", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "additionalProperties": { + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + } +} +""".replaceAll("\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("edb08d97-e0f9-4c71-840a-72080d7be42e") + ModifySliceSubnet sliceSubnet = new ModifySliceSubnet() + sliceSubnet.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testPrepareInitOperationStatus() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("54321") + when(mockExecution.getVariable("jobId")).thenReturn("54321") + when(mockExecution.getVariable("nsiId")).thenReturn("11111") + ModifySliceSubnet sliceSubnet = new ModifySliceSubnet() + sliceSubnet.prepareInitOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("initResourceOperationStatus"), captor.capture()) + String res = captor.getValue() + assertNotNull(res) + } + + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("jobId")).thenReturn("123456") + ModifySliceSubnet sliceSubnet = new ModifySliceSubnet() + sliceSubnet.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertEquals(updateVolumeGroupRequest, true) + } + + @Test + public void test() { + fail("Not yet implemented") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSliceSubnet.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSliceSubnet.bpmn new file mode 100644 index 0000000000..a2b7f4f67a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSliceSubnet.bpmn @@ -0,0 +1,224 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_04ua9m1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="ActivateSliceSubnet" name="ActivateSliceSubnet" isExecutable="true"> + <bpmn:startEvent id="Event_1h6wq31" name="Start"> + <bpmn:outgoing>Flow_1rnck9o</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="Activity_0r1fyr9" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_1rnck9o</bpmn:incoming> + <bpmn:outgoing>Flow_1ruhu5s</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new ActivateSliceSubnet() +nss.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_19eqlu7" name="Send Sync Response" scriptFormat="groovy"> + <bpmn:incoming>Flow_1da78f4</bpmn:incoming> + <bpmn:outgoing>Flow_17ebcpc</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new ActivateSliceSubnet() +nss.sendSyncResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_150n9jp" name="Whether Network type"> + <bpmn:incoming>Flow_17ebcpc</bpmn:incoming> + <bpmn:outgoing>Flow_1t9x0sg</bpmn:outgoing> + <bpmn:outgoing>Flow_1q1kc3c</bpmn:outgoing> + <bpmn:outgoing>Flow_0ptiwv3</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="Event_07betxq"> + <bpmn:incoming>Flow_0krl0oq</bpmn:incoming> + <bpmn:incoming>Flow_0wwue07</bpmn:incoming> + <bpmn:incoming>Flow_115ylm7</bpmn:incoming> + </bpmn:endEvent> + <bpmn:serviceTask id="Activity_1jbt8op" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${initResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0wjhvtf</bpmn:incoming> + <bpmn:outgoing>Flow_1da78f4</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1rnck9o" sourceRef="Event_1h6wq31" targetRef="Activity_0r1fyr9" /> + <bpmn:sequenceFlow id="Flow_1da78f4" sourceRef="Activity_1jbt8op" targetRef="Activity_19eqlu7" /> + <bpmn:sequenceFlow id="Flow_17ebcpc" sourceRef="Activity_19eqlu7" targetRef="Gateway_150n9jp" /> + <bpmn:sequenceFlow id="Flow_1t9x0sg" name="Is CN ?" sourceRef="Gateway_150n9jp" targetRef="CallDoActivateCoreNSSI"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "CN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1q1kc3c" name="Is TN ?" sourceRef="Gateway_150n9jp" targetRef="CallDoActivateTransportNSSI"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "TN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:callActivity id="CallDoActivateAccessNSSI" name="Call ANActivateNSSI" calledElement="DoActivateAccessNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="operationType" target="operationType" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0ptiwv3</bpmn:incoming> + <bpmn:outgoing>Flow_0krl0oq</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_0ptiwv3" name="Is AN ?" sourceRef="Gateway_150n9jp" targetRef="CallDoActivateAccessNSSI"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "AN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0krl0oq" sourceRef="CallDoActivateAccessNSSI" targetRef="Event_07betxq" /> + <bpmn:callActivity id="CallDoActivateCoreNSSI" name="Call CNActivateNSSI" calledElement="DoActivateCoreNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="operationType" target="operationType" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1t9x0sg</bpmn:incoming> + <bpmn:outgoing>Flow_0wwue07</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_0wwue07" sourceRef="CallDoActivateCoreNSSI" targetRef="Event_07betxq" /> + <bpmn:callActivity id="CallDoActivateTransportNSSI" name="Call TNActivateNSSI" calledElement="DoActivateTransportNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="operationType" target="operationType" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1q1kc3c</bpmn:incoming> + <bpmn:outgoing>Flow_115ylm7</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_115ylm7" sourceRef="CallDoActivateTransportNSSI" targetRef="Event_07betxq" /> + <bpmn:scriptTask id="Activity_13km4np" name="Init Resource Operation Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_1ruhu5s</bpmn:incoming> + <bpmn:outgoing>Flow_0wjhvtf</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new ActivateSliceSubnet() +nss.prepareInitOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1ruhu5s" sourceRef="Activity_0r1fyr9" targetRef="Activity_13km4np" /> + <bpmn:sequenceFlow id="Flow_0wjhvtf" sourceRef="Activity_13km4np" targetRef="Activity_1jbt8op" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ActivateSliceSubnet"> + <bpmndi:BPMNEdge id="Flow_115ylm7_di" bpmnElement="Flow_115ylm7"> + <di:waypoint x="1050" y="360" /> + <di:waypoint x="1140" y="360" /> + <di:waypoint x="1140" y="258" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0wwue07_di" bpmnElement="Flow_0wwue07"> + <di:waypoint x="1050" y="240" /> + <di:waypoint x="1122" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0krl0oq_di" bpmnElement="Flow_0krl0oq"> + <di:waypoint x="1050" y="120" /> + <di:waypoint x="1140" y="120" /> + <di:waypoint x="1140" y="222" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ptiwv3_di" bpmnElement="Flow_0ptiwv3"> + <di:waypoint x="860" y="215" /> + <di:waypoint x="860" y="120" /> + <di:waypoint x="950" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="881" y="166" width="37" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1q1kc3c_di" bpmnElement="Flow_1q1kc3c"> + <di:waypoint x="860" y="265" /> + <di:waypoint x="860" y="360" /> + <di:waypoint x="950" y="360" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="882" y="333" width="36" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1t9x0sg_di" bpmnElement="Flow_1t9x0sg"> + <di:waypoint x="885" y="240" /> + <di:waypoint x="950" y="240" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="894" y="222" width="37" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_17ebcpc_di" bpmnElement="Flow_17ebcpc"> + <di:waypoint x="770" y="240" /> + <di:waypoint x="835" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1da78f4_di" bpmnElement="Flow_1da78f4"> + <di:waypoint x="620" y="240" /> + <di:waypoint x="670" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1ruhu5s_di" bpmnElement="Flow_1ruhu5s"> + <di:waypoint x="330" y="240" /> + <di:waypoint x="390" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1rnck9o_di" bpmnElement="Flow_1rnck9o"> + <di:waypoint x="188" y="240" /> + <di:waypoint x="230" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0wjhvtf_di" bpmnElement="Flow_0wjhvtf"> + <di:waypoint x="490" y="240" /> + <di:waypoint x="520" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Activity_19eqlu7_di" bpmnElement="Activity_19eqlu7"> + <dc:Bounds x="670" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_150n9jp_di" bpmnElement="Gateway_150n9jp" isMarkerVisible="true"> + <dc:Bounds x="835" y="215" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="817" y="258" width="85" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_07betxq_di" bpmnElement="Event_07betxq"> + <dc:Bounds x="1122" y="222" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1jbt8op_di" bpmnElement="Activity_1jbt8op"> + <dc:Bounds x="520" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0663qmy_di" bpmnElement="CallDoActivateAccessNSSI"> + <dc:Bounds x="950" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0k9faej_di" bpmnElement="CallDoActivateCoreNSSI"> + <dc:Bounds x="950" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0rmx5qf_di" bpmnElement="CallDoActivateTransportNSSI"> + <dc:Bounds x="950" y="320" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1h6wq31_di" bpmnElement="Event_1h6wq31"> + <dc:Bounds x="152" y="222" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="158" y="265" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0r1fyr9_di" bpmnElement="Activity_0r1fyr9"> + <dc:Bounds x="230" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_13km4np_di" bpmnElement="Activity_13km4np"> + <dc:Bounds x="390" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn new file mode 100644 index 0000000000..450faaebca --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn @@ -0,0 +1,219 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_04bdlh3" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="AllocateSliceSubnet" name="AllocateSliceSubnet" isExecutable="true"> + <bpmn:startEvent id="Event_16inlk9" name="Start"> + <bpmn:outgoing>Flow_0cmaj9d</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="Activity_1hyt0pb" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_0cmaj9d</bpmn:incoming> + <bpmn:outgoing>Flow_0ou7wr9</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new AllocateSliceSubnet() +nss.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1usi32q" name="Send Sync Response" scriptFormat="groovy"> + <bpmn:incoming>Flow_0ayd6dj</bpmn:incoming> + <bpmn:outgoing>Flow_0m5n6md</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new AllocateSliceSubnet() +nss.sendSyncResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_15a04ct" name="Whether Network type"> + <bpmn:incoming>Flow_0m5n6md</bpmn:incoming> + <bpmn:outgoing>Flow_1fij4ds</bpmn:outgoing> + <bpmn:outgoing>Flow_0g7721r</bpmn:outgoing> + <bpmn:outgoing>Flow_1kk0exp</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="Event_18u424w"> + <bpmn:incoming>Flow_09b50tn</bpmn:incoming> + <bpmn:incoming>Flow_189zwjw</bpmn:incoming> + <bpmn:incoming>Flow_1coedjo</bpmn:incoming> + </bpmn:endEvent> + <bpmn:serviceTask id="Activity_0qlstj2" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${initResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_18cgkru</bpmn:incoming> + <bpmn:outgoing>Flow_0ayd6dj</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0cmaj9d" sourceRef="Event_16inlk9" targetRef="Activity_1hyt0pb" /> + <bpmn:sequenceFlow id="Flow_0ayd6dj" sourceRef="Activity_0qlstj2" targetRef="Activity_1usi32q" /> + <bpmn:sequenceFlow id="Flow_0m5n6md" sourceRef="Activity_1usi32q" targetRef="Gateway_15a04ct" /> + <bpmn:sequenceFlow id="Flow_1fij4ds" name="Is CN ?" sourceRef="Gateway_15a04ct" targetRef="CallDoAllocateCoreNSSI"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "CN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0g7721r" name="Is TN ?" sourceRef="Gateway_15a04ct" targetRef="CallDoAllocateTransportNSSI"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "TN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1kk0exp" name="Is AN ?" sourceRef="Gateway_15a04ct" targetRef="CallDoAllocateAccessNSSI"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "AN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_09b50tn" sourceRef="CallDoAllocateAccessNSSI" targetRef="Event_18u424w" /> + <bpmn:callActivity id="CallDoAllocateAccessNSSI" name="Call ANAllocateNSSI" calledElement="DoAllocateAccessNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="modelInvariantUuid" target="modelInvariantUuid" /> + <camunda:in source="modelUuid" target="modelUuid" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="dummyServiceId" target="dummyServiceId" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1kk0exp</bpmn:incoming> + <bpmn:outgoing>Flow_09b50tn</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_1ydx2rx" name="Init Resource Operation Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0ou7wr9</bpmn:incoming> + <bpmn:outgoing>Flow_18cgkru</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new AllocateSliceSubnet() +nss.prepareInitOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0ou7wr9" sourceRef="Activity_1hyt0pb" targetRef="Activity_1ydx2rx" /> + <bpmn:sequenceFlow id="Flow_18cgkru" sourceRef="Activity_1ydx2rx" targetRef="Activity_0qlstj2" /> + <bpmn:callActivity id="CallDoAllocateTransportNSSI" name="Call TNAllocateNSSI" calledElement="DoAllocateTransportNSSI"> + <bpmn:extensionElements> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0g7721r</bpmn:incoming> + <bpmn:outgoing>Flow_189zwjw</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_189zwjw" sourceRef="CallDoAllocateTransportNSSI" targetRef="Event_18u424w" /> + <bpmn:callActivity id="CallDoAllocateCoreNSSI" name="Call CNAllocateNSSI" calledElement="DoAllocateCoreNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="modelInvariantUuid" target="modelInvariantUuid" /> + <camunda:in source="modelUuid" target="modelUuid" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="dummyServiceId" target="dummyServiceId" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1fij4ds</bpmn:incoming> + <bpmn:outgoing>Flow_1coedjo</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_1coedjo" sourceRef="CallDoAllocateCoreNSSI" targetRef="Event_18u424w" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="AllocateSliceSubnet"> + <bpmndi:BPMNEdge id="Flow_1coedjo_di" bpmnElement="Flow_1coedjo"> + <di:waypoint x="1080" y="190" /> + <di:waypoint x="1152" y="190" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_189zwjw_di" bpmnElement="Flow_189zwjw"> + <di:waypoint x="1080" y="300" /> + <di:waypoint x="1170" y="300" /> + <di:waypoint x="1170" y="208" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_18cgkru_di" bpmnElement="Flow_18cgkru"> + <di:waypoint x="480" y="190" /> + <di:waypoint x="550" y="190" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ou7wr9_di" bpmnElement="Flow_0ou7wr9"> + <di:waypoint x="320" y="190" /> + <di:waypoint x="380" y="190" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_09b50tn_di" bpmnElement="Flow_09b50tn"> + <di:waypoint x="1080" y="90" /> + <di:waypoint x="1170" y="90" /> + <di:waypoint x="1170" y="172" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1kk0exp_di" bpmnElement="Flow_1kk0exp"> + <di:waypoint x="890" y="165" /> + <di:waypoint x="890" y="90" /> + <di:waypoint x="980" y="90" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="911" y="125" width="37" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0g7721r_di" bpmnElement="Flow_0g7721r"> + <di:waypoint x="890" y="215" /> + <di:waypoint x="890" y="300" /> + <di:waypoint x="980" y="300" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="912" y="273" width="36" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1fij4ds_di" bpmnElement="Flow_1fij4ds"> + <di:waypoint x="915" y="190" /> + <di:waypoint x="980" y="190" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="921" y="172" width="37" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0m5n6md_di" bpmnElement="Flow_0m5n6md"> + <di:waypoint x="800" y="190" /> + <di:waypoint x="865" y="190" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ayd6dj_di" bpmnElement="Flow_0ayd6dj"> + <di:waypoint x="650" y="190" /> + <di:waypoint x="700" y="190" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0cmaj9d_di" bpmnElement="Flow_0cmaj9d"> + <di:waypoint x="188" y="190" /> + <di:waypoint x="220" y="190" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_16inlk9_di" bpmnElement="Event_16inlk9"> + <dc:Bounds x="152" y="172" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="158" y="215" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1hyt0pb_di" bpmnElement="Activity_1hyt0pb"> + <dc:Bounds x="220" y="150" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1usi32q_di" bpmnElement="Activity_1usi32q"> + <dc:Bounds x="700" y="150" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_15a04ct_di" bpmnElement="Gateway_15a04ct" isMarkerVisible="true"> + <dc:Bounds x="865" y="165" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="847" y="208" width="85" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_18u424w_di" bpmnElement="Event_18u424w"> + <dc:Bounds x="1152" y="172" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0qlstj2_di" bpmnElement="Activity_0qlstj2"> + <dc:Bounds x="550" y="150" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ezmthy_di" bpmnElement="CallDoAllocateAccessNSSI"> + <dc:Bounds x="980" y="50" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1ydx2rx_di" bpmnElement="Activity_1ydx2rx"> + <dc:Bounds x="380" y="150" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_008nbm9_di" bpmnElement="CallDoAllocateTransportNSSI"> + <dc:Bounds x="980" y="260" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_01669p4_di" bpmnElement="CallDoAllocateCoreNSSI"> + <dc:Bounds x="980" y="150" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeAllocateSliceSubnet.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeAllocateSliceSubnet.bpmn new file mode 100644 index 0000000000..bf08c6e630 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeAllocateSliceSubnet.bpmn @@ -0,0 +1,224 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1stoy5y" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="DeAllocateSliceSubnet" name="DeallocateSliceSubnet" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1" name="Start"> + <bpmn:outgoing>Flow_143ck2k</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="Flow_143ck2k" sourceRef="StartEvent_1" targetRef="Activity_0zyhkvj" /> + <bpmn:scriptTask id="Activity_0zyhkvj" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_143ck2k</bpmn:incoming> + <bpmn:outgoing>Flow_0pttfuf</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DeAllocateSliceSubnet() +nss.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0c6o2o7" name="Send Sync Response" scriptFormat="groovy"> + <bpmn:incoming>Flow_1c1j5i1</bpmn:incoming> + <bpmn:outgoing>Flow_1kljyhj</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DeAllocateSliceSubnet() +nss.sendSyncResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1dykbz9" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${initResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_04jsg9s</bpmn:incoming> + <bpmn:outgoing>Flow_1c1j5i1</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0pttfuf" sourceRef="Activity_0zyhkvj" targetRef="Activity_1fj0cge" /> + <bpmn:sequenceFlow id="Flow_1c1j5i1" sourceRef="Activity_1dykbz9" targetRef="Activity_0c6o2o7" /> + <bpmn:scriptTask id="Activity_1fj0cge" name="Init Resource Operation Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0pttfuf</bpmn:incoming> + <bpmn:outgoing>Flow_04jsg9s</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DeAllocateSliceSubnet() +nss.prepareInitOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_04jsg9s" sourceRef="Activity_1fj0cge" targetRef="Activity_1dykbz9" /> + <bpmn:exclusiveGateway id="Gateway_1jagvdq" name="Whether Network type"> + <bpmn:incoming>Flow_1kljyhj</bpmn:incoming> + <bpmn:outgoing>Flow_0fp8gep</bpmn:outgoing> + <bpmn:outgoing>Flow_0zwyxxc</bpmn:outgoing> + <bpmn:outgoing>Flow_0roz1jy</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:callActivity id="Activity_02dflyr" name="Call TNDeallocateNSSI" calledElement="DoDeallocateTransportNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0fp8gep</bpmn:incoming> + <bpmn:outgoing>Flow_1hij53h</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:callActivity id="Activity_1ceupdn" name="Call CNDeallocateNSSI" calledElement="DoDeallocateCoreNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0roz1jy</bpmn:incoming> + <bpmn:outgoing>Flow_1fth8go</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:callActivity id="Activity_0li16m1" name="Call ANDeallocateNSSI" calledElement="DoDeallocateAccessNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0zwyxxc</bpmn:incoming> + <bpmn:outgoing>Flow_1l74oic</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:endEvent id="Event_1ecylff"> + <bpmn:incoming>Flow_1hij53h</bpmn:incoming> + <bpmn:incoming>Flow_1fth8go</bpmn:incoming> + <bpmn:incoming>Flow_1l74oic</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_0fp8gep" name="Is TN ?" sourceRef="Gateway_1jagvdq" targetRef="Activity_02dflyr"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "TN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0zwyxxc" name="Is AN ?" sourceRef="Gateway_1jagvdq" targetRef="Activity_0li16m1"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "AN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0roz1jy" name="Is CN ?" sourceRef="Gateway_1jagvdq" targetRef="Activity_1ceupdn"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "CN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1hij53h" sourceRef="Activity_02dflyr" targetRef="Event_1ecylff" /> + <bpmn:sequenceFlow id="Flow_1fth8go" sourceRef="Activity_1ceupdn" targetRef="Event_1ecylff" /> + <bpmn:sequenceFlow id="Flow_1l74oic" sourceRef="Activity_0li16m1" targetRef="Event_1ecylff" /> + <bpmn:sequenceFlow id="Flow_1kljyhj" sourceRef="Activity_0c6o2o7" targetRef="Gateway_1jagvdq" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeAllocateSliceSubnet"> + <bpmndi:BPMNEdge id="Flow_1kljyhj_di" bpmnElement="Flow_1kljyhj"> + <di:waypoint x="890" y="250" /> + <di:waypoint x="975" y="250" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1l74oic_di" bpmnElement="Flow_1l74oic"> + <di:waypoint x="1190" y="120" /> + <di:waypoint x="1280" y="120" /> + <di:waypoint x="1280" y="232" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1fth8go_di" bpmnElement="Flow_1fth8go"> + <di:waypoint x="1190" y="250" /> + <di:waypoint x="1262" y="250" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1hij53h_di" bpmnElement="Flow_1hij53h"> + <di:waypoint x="1190" y="360" /> + <di:waypoint x="1280" y="360" /> + <di:waypoint x="1280" y="268" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0roz1jy_di" bpmnElement="Flow_0roz1jy"> + <di:waypoint x="1025" y="250" /> + <di:waypoint x="1090" y="250" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1035" y="232" width="37" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0zwyxxc_di" bpmnElement="Flow_0zwyxxc"> + <di:waypoint x="1000" y="225" /> + <di:waypoint x="1000" y="120" /> + <di:waypoint x="1090" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="964" y="129" width="37" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0fp8gep_di" bpmnElement="Flow_0fp8gep"> + <di:waypoint x="1000" y="275" /> + <di:waypoint x="1000" y="360" /> + <di:waypoint x="1090" y="360" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1000" y="345" width="36" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_04jsg9s_di" bpmnElement="Flow_04jsg9s"> + <di:waypoint x="520" y="250" /> + <di:waypoint x="600" y="250" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1c1j5i1_di" bpmnElement="Flow_1c1j5i1"> + <di:waypoint x="700" y="250" /> + <di:waypoint x="790" y="250" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0pttfuf_di" bpmnElement="Flow_0pttfuf"> + <di:waypoint x="330" y="250" /> + <di:waypoint x="420" y="250" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_143ck2k_di" bpmnElement="Flow_143ck2k"> + <di:waypoint x="168" y="250" /> + <di:waypoint x="230" y="250" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="132" y="232" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="138" y="275" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1jawdkz_di" bpmnElement="Activity_0zyhkvj"> + <dc:Bounds x="230" y="210" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1n1ajr4_di" bpmnElement="Activity_0c6o2o7"> + <dc:Bounds x="790" y="210" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1dykbz9_di" bpmnElement="Activity_1dykbz9"> + <dc:Bounds x="600" y="210" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1fj0cge_di" bpmnElement="Activity_1fj0cge"> + <dc:Bounds x="420" y="210" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1jagvdq_di" bpmnElement="Gateway_1jagvdq" isMarkerVisible="true"> + <dc:Bounds x="975" y="225" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="957" y="268" width="85" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_02dflyr_di" bpmnElement="Activity_02dflyr"> + <dc:Bounds x="1090" y="320" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1ceupdn_di" bpmnElement="Activity_1ceupdn"> + <dc:Bounds x="1090" y="210" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0li16m1_di" bpmnElement="Activity_0li16m1"> + <dc:Bounds x="1090" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1ecylff_di" bpmnElement="Event_1ecylff"> + <dc:Bounds x="1262" y="232" width="36" height="36" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ModifySliceSubnet.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ModifySliceSubnet.bpmn new file mode 100644 index 0000000000..38ddf2edcd --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ModifySliceSubnet.bpmn @@ -0,0 +1,224 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0fme930" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="ModifySliceSubnet" name="ModifySliceSubnet" isExecutable="true"> + <bpmn:startEvent id="Event_05idy03" name="Start"> + <bpmn:outgoing>Flow_1t0w8dn</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="Activity_0kd9pxx" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_1t0w8dn</bpmn:incoming> + <bpmn:outgoing>Flow_0fzchbl</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new ModifySliceSubnet() +nss.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1dzkfh2" name="Send Sync Response" scriptFormat="groovy"> + <bpmn:incoming>Flow_1q030ul</bpmn:incoming> + <bpmn:outgoing>Flow_0ps6iyc</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new ModifySliceSubnet() +nss.sendSyncResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_1baxf7k" name="Whether Network type"> + <bpmn:incoming>Flow_0ps6iyc</bpmn:incoming> + <bpmn:outgoing>Flow_15luvlg</bpmn:outgoing> + <bpmn:outgoing>Flow_0usuozn</bpmn:outgoing> + <bpmn:outgoing>Flow_1dfyoe6</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="Event_103vvkf"> + <bpmn:incoming>Flow_1b2k523</bpmn:incoming> + <bpmn:incoming>Flow_0pklfqu</bpmn:incoming> + <bpmn:incoming>Flow_1bbqkjv</bpmn:incoming> + </bpmn:endEvent> + <bpmn:serviceTask id="Activity_0ptby3d" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${initResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1grhlet</bpmn:incoming> + <bpmn:outgoing>Flow_1q030ul</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1t0w8dn" sourceRef="Event_05idy03" targetRef="Activity_0kd9pxx" /> + <bpmn:sequenceFlow id="Flow_0fzchbl" sourceRef="Activity_0kd9pxx" targetRef="Activity_1s8ojcr" /> + <bpmn:sequenceFlow id="Flow_1q030ul" sourceRef="Activity_0ptby3d" targetRef="Activity_1dzkfh2" /> + <bpmn:sequenceFlow id="Flow_0ps6iyc" sourceRef="Activity_1dzkfh2" targetRef="Gateway_1baxf7k" /> + <bpmn:sequenceFlow id="Flow_15luvlg" name="Is TN ?" sourceRef="Gateway_1baxf7k" targetRef="Activity_192bdyv"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "TN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0usuozn" name="Is AN ?" sourceRef="Gateway_1baxf7k" targetRef="Activity_0t1g4mp"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "AN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:scriptTask id="Activity_1s8ojcr" name="Init Resource Operation Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0fzchbl</bpmn:incoming> + <bpmn:outgoing>Flow_1grhlet</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new ModifySliceSubnet() +nss.prepareInitOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1grhlet" sourceRef="Activity_1s8ojcr" targetRef="Activity_0ptby3d" /> + <bpmn:callActivity id="Activity_0t1g4mp" name="Call ANModifyNSSI" calledElement="DoModifyAccessNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0usuozn</bpmn:incoming> + <bpmn:outgoing>Flow_1b2k523</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_1b2k523" sourceRef="Activity_0t1g4mp" targetRef="Event_103vvkf" /> + <bpmn:callActivity id="Activity_0v2hxmv" name="Call CNModifyNSSI" calledElement="DoModifyCoreNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1dfyoe6</bpmn:incoming> + <bpmn:outgoing>Flow_0pklfqu</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:callActivity id="Activity_192bdyv" name="Call TNModifyNSSI" calledElement="DoModifyTransportNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_15luvlg</bpmn:incoming> + <bpmn:outgoing>Flow_1bbqkjv</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_0pklfqu" sourceRef="Activity_0v2hxmv" targetRef="Event_103vvkf" /> + <bpmn:sequenceFlow id="Flow_1dfyoe6" name="Is CN ?" sourceRef="Gateway_1baxf7k" targetRef="Activity_0v2hxmv"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "CN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1bbqkjv" sourceRef="Activity_192bdyv" targetRef="Event_103vvkf" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ModifySliceSubnet"> + <bpmndi:BPMNEdge id="Flow_0usuozn_di" bpmnElement="Flow_0usuozn"> + <di:waypoint x="830" y="245" /> + <di:waypoint x="830" y="140" /> + <di:waypoint x="920" y="140" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="794" y="149" width="37" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_15luvlg_di" bpmnElement="Flow_15luvlg"> + <di:waypoint x="830" y="295" /> + <di:waypoint x="830" y="380" /> + <di:waypoint x="920" y="380" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="830" y="365" width="36" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1dfyoe6_di" bpmnElement="Flow_1dfyoe6"> + <di:waypoint x="855" y="270" /> + <di:waypoint x="920" y="270" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="865" y="252" width="37" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ps6iyc_di" bpmnElement="Flow_0ps6iyc"> + <di:waypoint x="740" y="270" /> + <di:waypoint x="805" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1q030ul_di" bpmnElement="Flow_1q030ul"> + <di:waypoint x="590" y="270" /> + <di:waypoint x="640" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0fzchbl_di" bpmnElement="Flow_0fzchbl"> + <di:waypoint x="310" y="270" /> + <di:waypoint x="340" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1t0w8dn_di" bpmnElement="Flow_1t0w8dn"> + <di:waypoint x="188" y="270" /> + <di:waypoint x="210" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1grhlet_di" bpmnElement="Flow_1grhlet"> + <di:waypoint x="440" y="270" /> + <di:waypoint x="490" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1b2k523_di" bpmnElement="Flow_1b2k523"> + <di:waypoint x="1020" y="140" /> + <di:waypoint x="1110" y="140" /> + <di:waypoint x="1110" y="252" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0pklfqu_di" bpmnElement="Flow_0pklfqu"> + <di:waypoint x="1020" y="270" /> + <di:waypoint x="1092" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1bbqkjv_di" bpmnElement="Flow_1bbqkjv"> + <di:waypoint x="1020" y="380" /> + <di:waypoint x="1110" y="380" /> + <di:waypoint x="1110" y="288" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Activity_1dzkfh2_di" bpmnElement="Activity_1dzkfh2"> + <dc:Bounds x="640" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1baxf7k_di" bpmnElement="Gateway_1baxf7k" isMarkerVisible="true"> + <dc:Bounds x="805" y="245" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="787" y="288" width="85" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_103vvkf_di" bpmnElement="Event_103vvkf"> + <dc:Bounds x="1092" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ptby3d_di" bpmnElement="Activity_0ptby3d"> + <dc:Bounds x="490" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_05idy03_di" bpmnElement="Event_05idy03"> + <dc:Bounds x="152" y="252" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="158" y="295" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0kd9pxx_di" bpmnElement="Activity_0kd9pxx"> + <dc:Bounds x="210" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1s8ojcr_di" bpmnElement="Activity_1s8ojcr"> + <dc:Bounds x="340" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0t1g4mp_di" bpmnElement="Activity_0t1g4mp"> + <dc:Bounds x="920" y="100" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0v2hxmv_di" bpmnElement="Activity_0v2hxmv"> + <dc:Bounds x="920" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_192bdyv_di" bpmnElement="Activity_192bdyv"> + <dc:Bounds x="920" y="340" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateCoreNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateCoreNSSI.bpmn new file mode 100644 index 0000000000..b422545e84 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateCoreNSSI.bpmn @@ -0,0 +1,420 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1r4k2c2" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0"> + <bpmn:process id="DoActivateCoreNSSI" name="DoActivateCoreNSSI" isExecutable="true"> + <bpmn:startEvent id="StartEvent_0lgslwq" name="Start"> + <bpmn:outgoing>SequenceFlow_0wwo1lh</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="ScriptTask_1x13jc1" name="Pre-process request Check operationType" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0wwo1lh</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_139ejmn</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_0usuysi" name="Call AAI get VNF/VFs and model info" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1654pt0</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_09nihof</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.getServiceVNFAndVFsFromCatalogDB(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_1t06mlw" name="Prepare request payload for SO macro service api" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_09nihof</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0fbr356</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.prepareSOMacroRequestPayLoad(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_0lxbaxd" name="Call AAI update sliceProlie service Instance status" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1e20i9g</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0j0egoi</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.updateSliceProfileOrchestrationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_1rjha8r" name="get NSSI instance with relationships and sliceProfile instance" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_139ejmn</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1654pt0</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.getNetworkInstanceWithSPInstanceAssociatedWithNssiId(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_1tfpgcs" name="PUT SO Macro" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1mi4waj</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0rjd7tg</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.sendPutRequestToSOMacro(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_1frasll" name="Prepare Call CheckServiceProcessStatus" scriptFormat="groovy"> + <bpmn:incoming>Flow_039sx2v</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_18x9gdi</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.prepareCallCheckProcessStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="CallActivity_11hntoj" name="CallCheckServiceProcessStatus" calledElement="CheckServiceProcessStatus"> + <bpmn:extensionElements> + <camunda:in source="networkServiceInstanceId" target="serviceInstanceId" /> + <camunda:in source="macroOperationId" target="operationId" /> + <camunda:in source="successConditions" target="successConditions" /> + <camunda:in source="errorConditions" target="errorConditions" /> + <camunda:in source="processServiceType" target="processServiceType" /> + <camunda:in source="timeOut" target="timeOut" /> + <camunda:out source="operationStatus" target="result" /> + <camunda:out source="operationContent" target="reason" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="isTimeOut" target="isTimeOut" /> + <camunda:in source="subOperationType" target="operationType" /> + <camunda:in source="initProgress" target="initProgress" /> + <camunda:in source="endProgress" target="endProgress" /> + <camunda:in source="serviceInstanceID" target="parentServiceInstanceId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="operationId" target="parentOperationId" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_18x9gdi</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1l9ry0a</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="ScriptTask_1sfn88d" name="Prepare update Service operation status " scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1l9ry0a</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0wx21io</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.prepareUpdateResourceOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0wwo1lh" sourceRef="StartEvent_0lgslwq" targetRef="ScriptTask_1x13jc1" /> + <bpmn:sequenceFlow id="SequenceFlow_139ejmn" sourceRef="ScriptTask_1x13jc1" targetRef="ScriptTask_1rjha8r" /> + <bpmn:sequenceFlow id="SequenceFlow_1654pt0" sourceRef="ScriptTask_1rjha8r" targetRef="ScriptTask_0usuysi" /> + <bpmn:sequenceFlow id="SequenceFlow_09nihof" sourceRef="ScriptTask_0usuysi" targetRef="ScriptTask_1t06mlw" /> + <bpmn:sequenceFlow id="SequenceFlow_1l9ry0a" sourceRef="CallActivity_11hntoj" targetRef="ScriptTask_1sfn88d" /> + <bpmn:sequenceFlow id="SequenceFlow_0fbr356" sourceRef="ScriptTask_1t06mlw" targetRef="IntermediateThrowEvent_0gueutz" /> + <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_0gueutz" name="Call SO macro api"> + <bpmn:incoming>SequenceFlow_0fbr356</bpmn:incoming> + <bpmn:linkEventDefinition name="CallSO" /> + </bpmn:intermediateThrowEvent> + <bpmn:sequenceFlow id="SequenceFlow_1mi4waj" sourceRef="IntermediateThrowEvent_150o0dl" targetRef="ScriptTask_1tfpgcs" /> + <bpmn:intermediateCatchEvent id="IntermediateThrowEvent_150o0dl" name="Call SO macro api"> + <bpmn:outgoing>SequenceFlow_1mi4waj</bpmn:outgoing> + <bpmn:linkEventDefinition name="CallSO" /> + </bpmn:intermediateCatchEvent> + <bpmn:sequenceFlow id="SequenceFlow_0rjd7tg" sourceRef="ScriptTask_1tfpgcs" targetRef="Gateway_03lo8jx" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_02nqn2k" name="is TimeOut?" default="SequenceFlow_07u1gfw"> + <bpmn:incoming>SequenceFlow_0wx21io</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1e20i9g</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_07u1gfw</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_0wx21io" sourceRef="ScriptTask_1sfn88d" targetRef="ExclusiveGateway_02nqn2k" /> + <bpmn:sequenceFlow id="SequenceFlow_1e20i9g" name="No" sourceRef="ExclusiveGateway_02nqn2k" targetRef="ScriptTask_0lxbaxd"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isTimeOut") == "NO")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:endEvent id="EndEvent_1061mty" name="End"> + <bpmn:incoming>SequenceFlow_0v0dntm</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_18x9gdi" sourceRef="ScriptTask_1frasll" targetRef="CallActivity_11hntoj" /> + <bpmn:exclusiveGateway id="Gateway_03lo8jx" name="is SO Response OK?" default="Flow_1jchhgj"> + <bpmn:incoming>SequenceFlow_0rjd7tg</bpmn:incoming> + <bpmn:outgoing>Flow_039sx2v</bpmn:outgoing> + <bpmn:outgoing>Flow_1jchhgj</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_039sx2v" name="Yes" sourceRef="Gateway_03lo8jx" targetRef="ScriptTask_1frasll"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isSOResponseSucceed" ) == "yes")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:serviceTask id="ServiceTask_02x7eqy" name="Update Service Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1jchhgj</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0j0egoi</bpmn:incoming> + <bpmn:incoming>SequenceFlow_07u1gfw</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0v0dntm</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0v0dntm" sourceRef="ServiceTask_02x7eqy" targetRef="EndEvent_1061mty" /> + <bpmn:sequenceFlow id="Flow_1jchhgj" name="No" sourceRef="Gateway_03lo8jx" targetRef="ServiceTask_02x7eqy" /> + <bpmn:sequenceFlow id="SequenceFlow_0j0egoi" sourceRef="ScriptTask_0lxbaxd" targetRef="ServiceTask_02x7eqy" /> + <bpmn:sequenceFlow id="SequenceFlow_07u1gfw" name="Yes" sourceRef="ExclusiveGateway_02nqn2k" targetRef="ServiceTask_02x7eqy" /> + <bpmn:subProcess id="Activity_1tmdw60" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_159txw2"> + <bpmn:outgoing>Flow_149oqyp</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_15ur8z3" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_0c1ec2y"> + <bpmn:incoming>Flow_1qooaff</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_0u3yna7" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_1iqw69c</bpmn:incoming> + <bpmn:outgoing>Flow_1qooaff</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0u4a0ry" name="Prepare Resource Operation Status Update" scriptFormat="groovy"> + <bpmn:incoming>Flow_149oqyp</bpmn:incoming> + <bpmn:outgoing>Flow_1dh5sht</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.prepareFailedOperationStatusUpdate(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_11422x1" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1dh5sht</bpmn:incoming> + <bpmn:outgoing>Flow_1iqw69c</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1iqw69c" sourceRef="Activity_11422x1" targetRef="Activity_0u3yna7" /> + <bpmn:sequenceFlow id="Flow_1dh5sht" sourceRef="Activity_0u4a0ry" targetRef="Activity_11422x1" /> + <bpmn:sequenceFlow id="Flow_149oqyp" sourceRef="Event_159txw2" targetRef="Activity_0u4a0ry" /> + <bpmn:sequenceFlow id="Flow_1qooaff" sourceRef="Activity_0u3yna7" targetRef="Event_0c1ec2y" /> + </bpmn:subProcess> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoActivateCoreNSSI"> + <bpmndi:BPMNEdge id="SequenceFlow_07u1gfw_di" bpmnElement="SequenceFlow_07u1gfw"> + <di:waypoint x="976" y="319" /> + <di:waypoint x="1123" y="319" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1041" y="301" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0j0egoi_di" bpmnElement="SequenceFlow_0j0egoi"> + <di:waypoint x="1099" y="258" /> + <di:waypoint x="1173" y="258" /> + <di:waypoint x="1173" y="279" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="376" y="387" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1jchhgj_di" bpmnElement="Flow_1jchhgj"> + <di:waypoint x="400" y="344" /> + <di:waypoint x="400" y="450" /> + <di:waypoint x="1190" y="450" /> + <di:waypoint x="1190" y="360" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="788" y="432" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0v0dntm_di" bpmnElement="SequenceFlow_0v0dntm"> + <di:waypoint x="1223" y="319" /> + <di:waypoint x="1263" y="319" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="483" y="448" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_039sx2v_di" bpmnElement="Flow_039sx2v"> + <di:waypoint x="425" y="319" /> + <di:waypoint x="470" y="319" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="439" y="301" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_18x9gdi_di" bpmnElement="SequenceFlow_18x9gdi"> + <di:waypoint x="570" y="319" /> + <di:waypoint x="610" y="319" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-180.5" y="448" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1e20i9g_di" bpmnElement="SequenceFlow_1e20i9g"> + <di:waypoint x="951" y="294" /> + <di:waypoint x="951" y="258" /> + <di:waypoint x="999" y="258" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="959" y="273" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0wx21io_di" bpmnElement="SequenceFlow_0wx21io"> + <di:waypoint x="868" y="319" /> + <di:waypoint x="926" y="319" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="137" y="448" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0rjd7tg_di" bpmnElement="SequenceFlow_0rjd7tg"> + <di:waypoint x="330" y="319" /> + <di:waypoint x="375" y="319" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-336" y="448" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1mi4waj_di" bpmnElement="SequenceFlow_1mi4waj"> + <di:waypoint x="178" y="319" /> + <di:waypoint x="230" y="319" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-489.5" y="448" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0fbr356_di" bpmnElement="SequenceFlow_0fbr356"> + <di:waypoint x="1020" y="120" /> + <di:waypoint x="1132" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="384" y="249" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1l9ry0a_di" bpmnElement="SequenceFlow_1l9ry0a"> + <di:waypoint x="710" y="319" /> + <di:waypoint x="768" y="319" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-21" y="448" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_09nihof_di" bpmnElement="SequenceFlow_09nihof"> + <di:waypoint x="820" y="120" /> + <di:waypoint x="920" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-460" y="189" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1654pt0_di" bpmnElement="SequenceFlow_1654pt0"> + <di:waypoint x="610" y="120" /> + <di:waypoint x="720" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-910" y="189" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_139ejmn_di" bpmnElement="SequenceFlow_139ejmn"> + <di:waypoint x="430" y="120" /> + <di:waypoint x="510" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-381" y="245" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0wwo1lh_di" bpmnElement="SequenceFlow_0wwo1lh"> + <di:waypoint x="242" y="120" /> + <di:waypoint x="330" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-489.5" y="249" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_0lgslwq_di" bpmnElement="StartEvent_0lgslwq"> + <dc:Bounds x="206" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="211" y="142" width="25" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1x13jc1_di" bpmnElement="ScriptTask_1x13jc1"> + <dc:Bounds x="330" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0usuysi_di" bpmnElement="ScriptTask_0usuysi"> + <dc:Bounds x="720" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1t06mlw_di" bpmnElement="ScriptTask_1t06mlw"> + <dc:Bounds x="920" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0lxbaxd_di" bpmnElement="ScriptTask_0lxbaxd"> + <dc:Bounds x="999" y="218" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1rjha8r_di" bpmnElement="ScriptTask_1rjha8r"> + <dc:Bounds x="510" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1tfpgcs_di" bpmnElement="ScriptTask_1tfpgcs"> + <dc:Bounds x="230" y="279" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1frasll_di" bpmnElement="ScriptTask_1frasll"> + <dc:Bounds x="470" y="279" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_11hntoj_di" bpmnElement="CallActivity_11hntoj"> + <dc:Bounds x="610" y="279" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1sfn88d_di" bpmnElement="ScriptTask_1sfn88d"> + <dc:Bounds x="768" y="279" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateThrowEvent_1808y0j_di" bpmnElement="IntermediateThrowEvent_0gueutz"> + <dc:Bounds x="1132" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1106" y="142" width="90" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_11m7660_di" bpmnElement="IntermediateThrowEvent_150o0dl"> + <dc:Bounds x="142" y="301" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="115" y="341" width="90" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_02nqn2k_di" bpmnElement="ExclusiveGateway_02nqn2k" isMarkerVisible="true"> + <dc:Bounds x="926" y="294" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="922" y="354" width="59" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1061mty_di" bpmnElement="EndEvent_1061mty"> + <dc:Bounds x="1263" y="301" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1271" y="344" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_03lo8jx_di" bpmnElement="Gateway_03lo8jx" isMarkerVisible="true"> + <dc:Bounds x="375" y="294" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="360" y="264" width="80" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_02x7eqy_di" bpmnElement="ServiceTask_02x7eqy"> + <dc:Bounds x="1123" y="279" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1tmdw60_di" bpmnElement="Activity_1tmdw60" isExpanded="true"> + <dc:Bounds x="400" y="560" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_1qooaff_di" bpmnElement="Flow_1qooaff"> + <di:waypoint x="960" y="664" /> + <di:waypoint x="1068" y="664" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_149oqyp_di" bpmnElement="Flow_149oqyp"> + <di:waypoint x="466" y="664" /> + <di:waypoint x="530" y="664" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1dh5sht_di" bpmnElement="Flow_1dh5sht"> + <di:waypoint x="630" y="664" /> + <di:waypoint x="690" y="664" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1iqw69c_di" bpmnElement="Flow_1iqw69c"> + <di:waypoint x="790" y="664" /> + <di:waypoint x="860" y="664" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_159txw2_di" bpmnElement="Event_159txw2"> + <dc:Bounds x="430" y="646" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0c1ec2y_di" bpmnElement="Event_0c1ec2y"> + <dc:Bounds x="1068" y="646" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0u3yna7_di" bpmnElement="Activity_0u3yna7"> + <dc:Bounds x="860" y="624" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0u4a0ry_di" bpmnElement="Activity_0u4a0ry"> + <dc:Bounds x="530" y="624" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_11422x1_di" bpmnElement="Activity_11422x1"> + <dc:Bounds x="690" y="624" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreNSSI.bpmn new file mode 100644 index 0000000000..92407e9b2a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreNSSI.bpmn @@ -0,0 +1,309 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_19c8rxx" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0"> + <bpmn:process id="DoAllocateCoreNSSI" name="DoAllocateCoreNSSI" isExecutable="true"> + <bpmn:startEvent id="allocateNSSI_startEvent" name="Start"> + <bpmn:outgoing>SequenceFlow_0bjz7up</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="SequenceFlow_0bjz7up" sourceRef="allocateNSSI_startEvent" targetRef="processRequest_ScriptTask" /> + <bpmn:sequenceFlow id="SequenceFlow_1xiszom" sourceRef="processRequest_ScriptTask" targetRef="ScriptTask_13krb7d" /> + <bpmn:sequenceFlow id="SequenceFlow_1r5aycw" sourceRef="ScriptTask_0ybe0w9" targetRef="Activity_16u5d39" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_1xjahhp" default="SequenceFlow_1scva4p"> + <bpmn:incoming>Flow_0kbpihh</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1scva4p</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1ygklb8</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_1scva4p" name="No Existing s-nssai" sourceRef="ExclusiveGateway_1xjahhp" targetRef="CallActivity_0ue7vug" /> + <bpmn:sequenceFlow id="SequenceFlow_1ygklb8" sourceRef="ExclusiveGateway_1xjahhp" targetRef="CallActivity_0e6drr2"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("solutions") !="" }</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0enouyb" sourceRef="ScriptTask_13krb7d" targetRef="ScriptTask_0ybe0w9" /> + <bpmn:endEvent id="EndEvent_1e80uuk" name="End"> + <bpmn:incoming>SequenceFlow_0tytimn</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0tubodn</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="processRequest_ScriptTask" name="Preprocess request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0bjz7up</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1xiszom</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNSSI() +allocateNssi.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_13krb7d" name="Get NSST name from CatalogDB" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1xiszom</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0enouyb</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNSSI() +allocateNssi.getNSSTName(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_0ybe0w9" name="Prepare OOF request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0enouyb</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1r5aycw</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNSSI() +allocateNssi.prepareOOFRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="CallActivity_0ue7vug" name="Call non-shared slice flow" calledElement="DoAllocateCoreNonSharedSlice"> + <bpmn:extensionElements> + <camunda:in source="coreServiceInstanceId" target="serviceInstanceId" /> + <camunda:in source="networkServiceModelInfo" target="networkServiceModelInfo" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="modelInvariantUuid" target="modelInvariantUuid" /> + <camunda:in source="nsstName" target="nsstName" /> + <camunda:in source="modelUuid" target="modelUuid" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:in source="servicename" target="servicename" /> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="sliceProfile" target="sliceProfile" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1scva4p</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0tubodn</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:callActivity id="CallActivity_0e6drr2" name="Call shared slice flow " calledElement="DoAllocateCoreSharedSlice"> + <bpmn:extensionElements> + <camunda:in source="solutions" target="solutions" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="modelInvariantUuid" target="modelInvariantUuid" /> + <camunda:in source="nsstName" target="nsstName" /> + <camunda:in source="dummyServiceId" target="dummyServiceId" /> + <camunda:in source="networkServiceModelInfo" target="networkServiceModelInfo" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="modelUuid" target="modelUuid" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:in source="servicename" target="servicename" /> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="sliceProfile" target="sliceProfile" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1ygklb8</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0tytimn</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_0tytimn" sourceRef="CallActivity_0e6drr2" targetRef="EndEvent_1e80uuk" /> + <bpmn:sequenceFlow id="SequenceFlow_0tubodn" sourceRef="CallActivity_0ue7vug" targetRef="EndEvent_1e80uuk" /> + <bpmn:callActivity id="Activity_16u5d39" name="Call DoHandleOofRequest" calledElement="DoHandleOofRequest"> + <bpmn:extensionElements> + <camunda:in source="NSSI_apiPath" target="apiPath" /> + <camunda:in source="NSSI_correlator" target="correlator" /> + <camunda:in source="NSSI_messageType" target="messageType" /> + <camunda:in source="NSSI_timeout" target="timeout" /> + <camunda:in source="NSSI_oofRequest" target="oofRequest" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="asyncCallbackResponse" target="NSSI_asyncCallbackResponse" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1r5aycw</bpmn:incoming> + <bpmn:outgoing>Flow_1navrbe</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_1navrbe" sourceRef="Activity_16u5d39" targetRef="ScriptTask_1bg09vu" /> + <bpmn:scriptTask id="ScriptTask_1bg09vu" name="Process OOF Async ressponse" scriptFormat="groovy"> + <bpmn:incoming>Flow_1navrbe</bpmn:incoming> + <bpmn:outgoing>Flow_0kbpihh</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNSSI() +allocateNssi.processOOFAsyncResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0kbpihh" sourceRef="ScriptTask_1bg09vu" targetRef="ExclusiveGateway_1xjahhp" /> + <bpmn:subProcess id="Activity_0nliikd" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_0jeyy28"> + <bpmn:outgoing>Flow_1bd9s44</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_00bn0ig" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_0f5seph"> + <bpmn:incoming>Flow_1rrkw3k</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_016fs4l" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_1jn84pa</bpmn:incoming> + <bpmn:outgoing>Flow_1rrkw3k</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1wmb5hd" name="Prepare Resource Operation Status Update" scriptFormat="groovy"> + <bpmn:incoming>Flow_1bd9s44</bpmn:incoming> + <bpmn:outgoing>Flow_167qlhy</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi= new DoAllocateCoreNSSI() +allocateNssi.prepareFailedOperationStatusUpdate(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_0frxrqx" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_167qlhy</bpmn:incoming> + <bpmn:outgoing>Flow_1jn84pa</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1jn84pa" sourceRef="Activity_0frxrqx" targetRef="Activity_016fs4l" /> + <bpmn:sequenceFlow id="Flow_167qlhy" sourceRef="Activity_1wmb5hd" targetRef="Activity_0frxrqx" /> + <bpmn:sequenceFlow id="Flow_1bd9s44" sourceRef="Event_0jeyy28" targetRef="Activity_1wmb5hd" /> + <bpmn:sequenceFlow id="Flow_1rrkw3k" sourceRef="Activity_016fs4l" targetRef="Event_0f5seph" /> + </bpmn:subProcess> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoAllocateCoreNSSI"> + <bpmndi:BPMNEdge id="Flow_0kbpihh_di" bpmnElement="Flow_0kbpihh"> + <di:waypoint x="868" y="180" /> + <di:waypoint x="929" y="180" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="753.5" y="155" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1navrbe_di" bpmnElement="Flow_1navrbe"> + <di:waypoint x="735" y="180" /> + <di:waypoint x="768" y="180" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0tubodn_di" bpmnElement="SequenceFlow_0tubodn"> + <di:waypoint x="1096" y="115" /> + <di:waypoint x="1136" y="115" /> + <di:waypoint x="1136" y="184" /> + <di:waypoint x="1176" y="184" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1051" y="143.5" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0tytimn_di" bpmnElement="SequenceFlow_0tytimn"> + <di:waypoint x="1096" y="266" /> + <di:waypoint x="1136" y="266" /> + <di:waypoint x="1136" y="184" /> + <di:waypoint x="1176" y="184" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1051" y="219" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0enouyb_di" bpmnElement="SequenceFlow_0enouyb"> + <di:waypoint x="468" y="184" /> + <di:waypoint x="501" y="184" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="339.5" y="163" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ygklb8_di" bpmnElement="SequenceFlow_1ygklb8"> + <di:waypoint x="954" y="205" /> + <di:waypoint x="954" y="266" /> + <di:waypoint x="996" y="266" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="824" y="229.5" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1scva4p_di" bpmnElement="SequenceFlow_1scva4p"> + <di:waypoint x="954" y="155" /> + <di:waypoint x="954" y="115" /> + <di:waypoint x="996" y="115" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="897" y="116" width="56" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1r5aycw_di" bpmnElement="SequenceFlow_1r5aycw"> + <di:waypoint x="601" y="184" /> + <di:waypoint x="635" y="184" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="470.5" y="163" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1xiszom_di" bpmnElement="SequenceFlow_1xiszom"> + <di:waypoint x="343" y="184" /> + <di:waypoint x="368" y="184" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="210.5" y="163" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0bjz7up_di" bpmnElement="SequenceFlow_0bjz7up"> + <di:waypoint x="195" y="184" /> + <di:waypoint x="243" y="184" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="74" y="163" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="allocateNSSI_startEvent"> + <dc:Bounds x="159" y="166" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="166" y="209" width="25" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_1xjahhp_di" bpmnElement="ExclusiveGateway_1xjahhp" isMarkerVisible="true"> + <dc:Bounds x="929" y="155" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="975" y="284" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1e80uuk_di" bpmnElement="EndEvent_1e80uuk"> + <dc:Bounds x="1176" y="166" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1184" y="209" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1eo0wn0_di" bpmnElement="processRequest_ScriptTask"> + <dc:Bounds x="243" y="144" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0cs9cfh_di" bpmnElement="ScriptTask_13krb7d"> + <dc:Bounds x="368" y="144" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1v669aj_di" bpmnElement="ScriptTask_0ybe0w9"> + <dc:Bounds x="501" y="144" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_04schfi_di" bpmnElement="CallActivity_0ue7vug"> + <dc:Bounds x="996" y="75" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1vy16mp_di" bpmnElement="CallActivity_0e6drr2"> + <dc:Bounds x="996" y="226" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_16u5d39_di" bpmnElement="Activity_16u5d39"> + <dc:Bounds x="635" y="144" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_19cc8m2_di" bpmnElement="ScriptTask_1bg09vu"> + <dc:Bounds x="768" y="140" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0nliikd_di" bpmnElement="Activity_0nliikd" isExpanded="true"> + <dc:Bounds x="300" y="360" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_1rrkw3k_di" bpmnElement="Flow_1rrkw3k"> + <di:waypoint x="860" y="464" /> + <di:waypoint x="968" y="464" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1bd9s44_di" bpmnElement="Flow_1bd9s44"> + <di:waypoint x="366" y="464" /> + <di:waypoint x="430" y="464" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_167qlhy_di" bpmnElement="Flow_167qlhy"> + <di:waypoint x="530" y="464" /> + <di:waypoint x="590" y="464" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1jn84pa_di" bpmnElement="Flow_1jn84pa"> + <di:waypoint x="690" y="464" /> + <di:waypoint x="760" y="464" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_0jeyy28_di" bpmnElement="Event_0jeyy28"> + <dc:Bounds x="330" y="446" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0f5seph_di" bpmnElement="Event_0f5seph"> + <dc:Bounds x="968" y="446" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_016fs4l_di" bpmnElement="Activity_016fs4l"> + <dc:Bounds x="760" y="424" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1wmb5hd_di" bpmnElement="Activity_1wmb5hd"> + <dc:Bounds x="430" y="424" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0frxrqx_di" bpmnElement="Activity_0frxrqx"> + <dc:Bounds x="590" y="424" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreNonSharedSlice.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreNonSharedSlice.bpmn new file mode 100644 index 0000000000..22eeceea51 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreNonSharedSlice.bpmn @@ -0,0 +1,368 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_021ltql" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0"> + <bpmn:process id="DoAllocateCoreNonSharedSlice" name="DoAllocateCoreNonSharedSlice" isExecutable="true"> + <bpmn:startEvent id="StartEvent_0niin4a" name="Start"> + <bpmn:outgoing>SequenceFlow_0vxnxew</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:exclusiveGateway id="ExclusiveGateway_09xlga4" default="Flow_0ebyiqk"> + <bpmn:incoming>SequenceFlow_0pkw03j</bpmn:incoming> + <bpmn:outgoing>Flow_1xofp8o</bpmn:outgoing> + <bpmn:outgoing>Flow_0ebyiqk</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_0vxnxew" sourceRef="StartEvent_0niin4a" targetRef="Activity_0kvdq8n" /> + <bpmn:sequenceFlow id="SequenceFlow_1terk7m" sourceRef="Task_0n4n0mx" targetRef="Task_0nowehc" /> + <bpmn:sequenceFlow id="SequenceFlow_0pkw03j" sourceRef="Task_1p5lbp7" targetRef="ExclusiveGateway_09xlga4" /> + <bpmn:scriptTask id="Task_0n4n0mx" name="Call AAI Create NSSI" scriptFormat="groovy"> + <bpmn:incoming>Flow_13lzgo4</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1terk7m</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNonSharedSlice() +allocateNssi.createNSSIinAAI(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Task_0nowehc" name="Prepare serviceOrder request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1terk7m</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0qeif6i</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNonSharedSlice() +allocateNssi.prepareServiceOrderRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Task_1p5lbp7" name="Call serviceOrder api" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0cqjgbm</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0pkw03j</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNonSharedSlice() +allocateNssi.postNBIServiceOrder(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1xofp8o" name="ACK" sourceRef="ExclusiveGateway_09xlga4" targetRef="Task_15tmmrz"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("ServiceOrderId" ) != null && execution.getVariable("ServiceOrderId" ) != "" )}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:exclusiveGateway id="ExclusiveGateway_0bq5wvj" name="Status = processing" default="Flow_1hjbkma"> + <bpmn:incoming>SequenceFlow_1g8lnjx</bpmn:incoming> + <bpmn:outgoing>Flow_1hjbkma</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0zuc4mh</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_1g8lnjx" sourceRef="Task_15tmmrz" targetRef="ExclusiveGateway_0bq5wvj" /> + <bpmn:endEvent id="EndEvent_1pb7jxo" name="End"> + <bpmn:incoming>Flow_0ginxdy</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_13lzgo4" sourceRef="Activity_0kvdq8n" targetRef="Task_0n4n0mx" /> + <bpmn:scriptTask id="Activity_0kvdq8n" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0vxnxew</bpmn:incoming> + <bpmn:outgoing>Flow_13lzgo4</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNonSharedSlice() +allocateNssi.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Task_15tmmrz" name="Call Get ServiceOrder Progress" scriptFormat="groovy"> + <bpmn:incoming>Flow_1xofp8o</bpmn:incoming> + <bpmn:incoming>Flow_0d9xaja</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1g8lnjx</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNonSharedSlice() +allocateNssi.getNBIServiceOrderProgress(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_19ywbh2" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0ebyiqk</bpmn:incoming> + <bpmn:incoming>Flow_140j38y</bpmn:incoming> + <bpmn:outgoing>Flow_0ginxdy</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0ebyiqk" name="Failed" sourceRef="ExclusiveGateway_09xlga4" targetRef="Activity_19ywbh2" /> + <bpmn:sequenceFlow id="Flow_1hjbkma" sourceRef="ExclusiveGateway_0bq5wvj" targetRef="Activity_0luwonx" /> + <bpmn:sequenceFlow id="Flow_0ginxdy" sourceRef="Activity_19ywbh2" targetRef="EndEvent_1pb7jxo" /> + <bpmn:sequenceFlow id="SequenceFlow_0zuc4mh" name="Yes" sourceRef="ExclusiveGateway_0bq5wvj" targetRef="Activity_0h5vkls"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("status" ) == "processing" )}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0d9xaja" sourceRef="Activity_0h5vkls" targetRef="Task_15tmmrz" /> + <bpmn:scriptTask id="Activity_0h5vkls" name="Time Delay" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0zuc4mh</bpmn:incoming> + <bpmn:outgoing>Flow_0d9xaja</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNonSharedSlice() +allocateNssi.timeDelay(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0luwonx" name="Call AAI associate NSSI with network service instance" scriptFormat="groovy"> + <bpmn:incoming>Flow_1hjbkma</bpmn:incoming> + <bpmn:outgoing>Flow_140j38y</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNonSharedSlice() +allocateNssi.updateRelationship(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_140j38y" sourceRef="Activity_0luwonx" targetRef="Activity_19ywbh2" /> + <bpmn:sequenceFlow id="SequenceFlow_0qeif6i" sourceRef="Task_0nowehc" targetRef="IntermediateThrowEvent_0m8avak" /> + <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_0m8avak" name="callServiceOrder"> + <bpmn:incoming>SequenceFlow_0qeif6i</bpmn:incoming> + <bpmn:linkEventDefinition name="callServiceOrder" /> + </bpmn:intermediateThrowEvent> + <bpmn:intermediateCatchEvent id="IntermediateThrowEvent_0nz9fnn" name="callServiceOrder"> + <bpmn:outgoing>SequenceFlow_0cqjgbm</bpmn:outgoing> + <bpmn:linkEventDefinition name="callServiceOrder" /> + </bpmn:intermediateCatchEvent> + <bpmn:sequenceFlow id="SequenceFlow_0cqjgbm" sourceRef="IntermediateThrowEvent_0nz9fnn" targetRef="Task_1p5lbp7" /> + <bpmn:subProcess id="Activity_0uegdhh" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_054d9nj"> + <bpmn:outgoing>Flow_022y6dc</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1e3e8ia" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_1kmtbm7"> + <bpmn:incoming>Flow_0luurk9</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_1ov9qpp" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_07lojd9</bpmn:incoming> + <bpmn:outgoing>Flow_0luurk9</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_016j574" name="Prepare Resource Operation Status Update" scriptFormat="groovy"> + <bpmn:incoming>Flow_022y6dc</bpmn:incoming> + <bpmn:outgoing>Flow_0g444ik</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNonSharedSlice() +allocateNssi.prepareFailedOperationStatusUpdate(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1wz7ppl" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0g444ik</bpmn:incoming> + <bpmn:outgoing>Flow_07lojd9</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0luurk9" sourceRef="Activity_1ov9qpp" targetRef="Event_1kmtbm7" /> + <bpmn:sequenceFlow id="Flow_022y6dc" sourceRef="Event_054d9nj" targetRef="Activity_016j574" /> + <bpmn:sequenceFlow id="Flow_0g444ik" sourceRef="Activity_016j574" targetRef="Activity_1wz7ppl" /> + <bpmn:sequenceFlow id="Flow_07lojd9" sourceRef="Activity_1wz7ppl" targetRef="Activity_1ov9qpp" /> + </bpmn:subProcess> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoAllocateCoreNonSharedSlice"> + <bpmndi:BPMNEdge id="SequenceFlow_0cqjgbm_di" bpmnElement="SequenceFlow_0cqjgbm"> + <di:waypoint x="188" y="295" /> + <di:waypoint x="250" y="295" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="219" y="274" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0qeif6i_di" bpmnElement="SequenceFlow_0qeif6i"> + <di:waypoint x="672" y="117" /> + <di:waypoint x="732" y="117" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="702" y="96" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_140j38y_di" bpmnElement="Flow_140j38y"> + <di:waypoint x="825" y="379" /> + <di:waypoint x="868" y="379" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="801.5" y="354" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0d9xaja_di" bpmnElement="Flow_0d9xaja"> + <di:waypoint x="589" y="483" /> + <di:waypoint x="508" y="483" /> + <di:waypoint x="508" y="419" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="503.5" y="458" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0zuc4mh_di" bpmnElement="SequenceFlow_0zuc4mh"> + <di:waypoint x="639" y="404" /> + <di:waypoint x="639" y="443" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="649" y="414" width="19" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ginxdy_di" bpmnElement="Flow_0ginxdy"> + <di:waypoint x="968" y="379" /> + <di:waypoint x="1013" y="379" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="945.5" y="354" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1hjbkma_di" bpmnElement="Flow_1hjbkma"> + <di:waypoint x="664" y="379" /> + <di:waypoint x="725" y="379" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="649.5" y="354" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ebyiqk_di" bpmnElement="Flow_0ebyiqk"> + <di:waypoint x="449" y="295" /> + <di:waypoint x="918" y="295" /> + <di:waypoint x="918" y="339" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="669" y="277" width="30" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_13lzgo4_di" bpmnElement="Flow_13lzgo4"> + <di:waypoint x="350" y="117" /> + <di:waypoint x="412" y="117" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="456" y="92" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1g8lnjx_di" bpmnElement="SequenceFlow_1g8lnjx"> + <di:waypoint x="558" y="379" /> + <di:waypoint x="614" y="379" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="541" y="358" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1xofp8o_di" bpmnElement="Flow_1xofp8o"> + <di:waypoint x="424" y="320" /> + <di:waypoint x="424" y="379" /> + <di:waypoint x="458" y="379" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="396" y="344" width="24" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0pkw03j_di" bpmnElement="SequenceFlow_0pkw03j"> + <di:waypoint x="350" y="295" /> + <di:waypoint x="399" y="295" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="329.5" y="274" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1terk7m_di" bpmnElement="SequenceFlow_1terk7m"> + <di:waypoint x="512" y="117" /> + <di:waypoint x="572" y="117" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="617" y="96" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0vxnxew_di" bpmnElement="SequenceFlow_0vxnxew"> + <di:waypoint x="188" y="117" /> + <di:waypoint x="250" y="117" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="294" y="96" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_0niin4a_di" bpmnElement="StartEvent_0niin4a"> + <dc:Bounds x="152" y="99" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="158" y="142" width="25" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_09xlga4_di" bpmnElement="ExclusiveGateway_09xlga4" isMarkerVisible="true"> + <dc:Bounds x="399" y="270" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-256" y="579" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0rs2nd3_di" bpmnElement="Task_0n4n0mx"> + <dc:Bounds x="412" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0m5z0ww_di" bpmnElement="Task_0nowehc"> + <dc:Bounds x="572" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1d5c0io_di" bpmnElement="Task_1p5lbp7"> + <dc:Bounds x="250" y="255" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_0bq5wvj_di" bpmnElement="ExclusiveGateway_0bq5wvj" isMarkerVisible="true"> + <dc:Bounds x="614" y="354" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="613" y="332" width="54" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1pb7jxo_di" bpmnElement="EndEvent_1pb7jxo"> + <dc:Bounds x="1013" y="361" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1021" y="404" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0e7umcn_di" bpmnElement="Activity_0kvdq8n"> + <dc:Bounds x="250" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_18jxe7s_di" bpmnElement="Task_15tmmrz"> + <dc:Bounds x="458" y="339" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_19ywbh2_di" bpmnElement="Activity_19ywbh2"> + <dc:Bounds x="868" y="339" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_07789nc_di" bpmnElement="Activity_0h5vkls"> + <dc:Bounds x="589" y="443" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0luwonx_di" bpmnElement="Activity_0luwonx"> + <dc:Bounds x="725" y="339" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateThrowEvent_0fs6uqw_di" bpmnElement="IntermediateThrowEvent_0m8avak"> + <dc:Bounds x="732" y="99" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="714" y="139" width="83" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_16ljm3v_di" bpmnElement="IntermediateThrowEvent_0nz9fnn"> + <dc:Bounds x="152" y="277" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="130" y="317" width="83" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0uegdhh_di" bpmnElement="Activity_0uegdhh" isExpanded="true"> + <dc:Bounds x="231" y="580" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_0luurk9_di" bpmnElement="Flow_0luurk9"> + <di:waypoint x="791" y="684" /> + <di:waypoint x="899" y="684" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_022y6dc_di" bpmnElement="Flow_022y6dc"> + <di:waypoint x="297" y="684" /> + <di:waypoint x="361" y="684" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0g444ik_di" bpmnElement="Flow_0g444ik"> + <di:waypoint x="461" y="684" /> + <di:waypoint x="521" y="684" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_07lojd9_di" bpmnElement="Flow_07lojd9"> + <di:waypoint x="621" y="684" /> + <di:waypoint x="691" y="684" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_054d9nj_di" bpmnElement="Event_054d9nj"> + <dc:Bounds x="261" y="666" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1kmtbm7_di" bpmnElement="Event_1kmtbm7"> + <dc:Bounds x="899" y="666" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1ov9qpp_di" bpmnElement="Activity_1ov9qpp"> + <dc:Bounds x="691" y="644" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_016j574_di" bpmnElement="Activity_016j574"> + <dc:Bounds x="361" y="644" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1wz7ppl_di" bpmnElement="Activity_1wz7ppl"> + <dc:Bounds x="521" y="644" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreSharedSlice.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreSharedSlice.bpmn new file mode 100644 index 0000000000..0a482beca0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreSharedSlice.bpmn @@ -0,0 +1,367 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1px21lh" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0"> + <bpmn:process id="DoAllocateCoreSharedSlice" name="DoAllocateCoreSharedSlice" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1" name="Start"> + <bpmn:outgoing>SequenceFlow_1ym7ydc</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="SequenceFlow_1ym7ydc" sourceRef="StartEvent_1" targetRef="Activity_1264hec" /> + <bpmn:endEvent id="EndEvent_1av4kxa" name="End"> + <bpmn:incoming>Flow_09uu75h</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_0da7dao" sourceRef="Activity_0no0sxa" targetRef="Task_16983t3" /> + <bpmn:scriptTask id="Task_1htaioi" name="Call AAI get network service instance associated with NSSI id" scriptFormat="groovy"> + <bpmn:incoming>Flow_1r07vnu</bpmn:incoming> + <bpmn:outgoing>Flow_1973d9m</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreSharedSlice() +allocateNssi.getNetworkInstanceAssociatedWithNssiId(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1r07vnu" sourceRef="Activity_1264hec" targetRef="Task_1htaioi" /> + <bpmn:scriptTask id="Activity_1264hec" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1ym7ydc</bpmn:incoming> + <bpmn:outgoing>Flow_1r07vnu</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreSharedSlice() +allocateNssi.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1973d9m" sourceRef="Task_1htaioi" targetRef="Activity_0no0sxa" /> + <bpmn:scriptTask id="Task_16983t3" name="Prepare request payload for SO macro service call" scriptFormat="groovy"> + <bpmn:incoming>Flow_0da7dao</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1j1qqcs</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreSharedSlice() +allocateNssi.prepareSOMacroRequestPayload(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_12jcmzc" name="PUT SO Macro" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_013bc74</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_08q2fd9</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreSharedSlice() +allocateNssi.sendPutRequestToSOMacro(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0ge2y0l" name="Prepare Call CheckServiceProcessStatus" scriptFormat="groovy"> + <bpmn:incoming>Flow_0x7shtq</bpmn:incoming> + <bpmn:outgoing>Flow_1c9nkx4</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreSharedSlice() +allocateNssi.prepareCallCheckProcessStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_19xwwnc" name="CallCheckServiceProcessStatus" calledElement="CheckServiceProcessStatus"> + <bpmn:extensionElements> + <camunda:in source="networkServiceInstanceId" target="serviceInstanceId" /> + <camunda:in source="macroOperationId" target="operationId" /> + <camunda:in source="successConditions" target="successConditions" /> + <camunda:in source="errorConditions" target="errorConditions" /> + <camunda:in source="processServiceType" target="processServiceType" /> + <camunda:in source="timeOut" target="timeOut" /> + <camunda:out source="operationStatus" target="result" /> + <camunda:out source="operationContent" target="reason" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="isTimeOut" target="isTimeOut" /> + <camunda:in source="subOperationType" target="operationType" /> + <camunda:in source="initProgress" target="initProgress" /> + <camunda:in source="endProgress" target="endProgress" /> + <camunda:in source="serviceInstanceID" target="parentServiceInstanceId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="operationId" target="parentOperationId" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1c9nkx4</bpmn:incoming> + <bpmn:outgoing>Flow_0c94gye</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_1c9nkx4" sourceRef="Activity_0ge2y0l" targetRef="Activity_19xwwnc" /> + <bpmn:sequenceFlow id="Flow_0c94gye" sourceRef="Activity_19xwwnc" targetRef="Activity_1t49t6c" /> + <bpmn:scriptTask id="Activity_0no0sxa" name="Get VNF/VFs modelInfo from CatalogDB" scriptFormat="groovy"> + <bpmn:incoming>Flow_1973d9m</bpmn:incoming> + <bpmn:outgoing>Flow_0da7dao</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreSharedSlice() +allocateNssi.getServiceVNFAndVFsFromCatalogDB(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1t49t6c" name="Prepare Update Operation Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0c94gye</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1re5jor</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreSharedSlice() +allocateNssi.prepareUpdateResourceOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_0t6viuq" name="Update Service Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1re5jor</bpmn:incoming> + <bpmn:incoming>Flow_1nn15tq</bpmn:incoming> + <bpmn:outgoing>Flow_09uu75h</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_09uu75h" sourceRef="Activity_0t6viuq" targetRef="EndEvent_1av4kxa" /> + <bpmn:sequenceFlow id="SequenceFlow_08q2fd9" sourceRef="Activity_12jcmzc" targetRef="Gateway_0sfmiku" /> + <bpmn:sequenceFlow id="SequenceFlow_1re5jor" sourceRef="Activity_1t49t6c" targetRef="Activity_0t6viuq" /> + <bpmn:sequenceFlow id="SequenceFlow_1j1qqcs" sourceRef="Task_16983t3" targetRef="IntermediateThrowEvent_09rhn4h" /> + <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_09rhn4h" name="Call SO macro api"> + <bpmn:incoming>SequenceFlow_1j1qqcs</bpmn:incoming> + <bpmn:linkEventDefinition name="CallSO" /> + </bpmn:intermediateThrowEvent> + <bpmn:intermediateCatchEvent id="IntermediateThrowEvent_0qh9wy2" name="Call SO macro api"> + <bpmn:outgoing>SequenceFlow_013bc74</bpmn:outgoing> + <bpmn:linkEventDefinition name="CallSO" /> + </bpmn:intermediateCatchEvent> + <bpmn:sequenceFlow id="SequenceFlow_013bc74" sourceRef="IntermediateThrowEvent_0qh9wy2" targetRef="Activity_12jcmzc" /> + <bpmn:exclusiveGateway id="Gateway_0sfmiku" name="is SO Response OK?" default="Flow_0x7shtq"> + <bpmn:incoming>SequenceFlow_08q2fd9</bpmn:incoming> + <bpmn:outgoing>Flow_0x7shtq</bpmn:outgoing> + <bpmn:outgoing>Flow_1nn15tq</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_0x7shtq" name="Yes" sourceRef="Gateway_0sfmiku" targetRef="Activity_0ge2y0l" /> + <bpmn:sequenceFlow id="Flow_1nn15tq" name="No" sourceRef="Gateway_0sfmiku" targetRef="Activity_0t6viuq"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isSOResponseSucceed" ) == "no")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:subProcess id="Activity_08h38js" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_07tr56z"> + <bpmn:outgoing>Flow_0nauwik</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_154c21j" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_02arrfq"> + <bpmn:incoming>Flow_0y8rsb3</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_1150yu6" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_128o22z</bpmn:incoming> + <bpmn:outgoing>Flow_0y8rsb3</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0sqggtb" name="Prepare Resource Operation Status Update" scriptFormat="groovy"> + <bpmn:incoming>Flow_0nauwik</bpmn:incoming> + <bpmn:outgoing>Flow_0kadgoq</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreSharedSlice() +allocateNssi.prepareFailedOperationStatusUpdate(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1btidug" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0kadgoq</bpmn:incoming> + <bpmn:outgoing>Flow_128o22z</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0y8rsb3" sourceRef="Activity_1150yu6" targetRef="Event_02arrfq" /> + <bpmn:sequenceFlow id="Flow_0nauwik" sourceRef="Event_07tr56z" targetRef="Activity_0sqggtb" /> + <bpmn:sequenceFlow id="Flow_0kadgoq" sourceRef="Activity_0sqggtb" targetRef="Activity_1btidug" /> + <bpmn:sequenceFlow id="Flow_128o22z" sourceRef="Activity_1btidug" targetRef="Activity_1150yu6" /> + </bpmn:subProcess> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoAllocateCoreSharedSlice"> + <bpmndi:BPMNEdge id="Flow_1nn15tq_di" bpmnElement="Flow_1nn15tq"> + <di:waypoint x="420" y="306" /> + <di:waypoint x="420" y="360" /> + <di:waypoint x="967" y="360" /> + <di:waypoint x="967" y="321" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="687" y="342" width="14" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0x7shtq_di" bpmnElement="Flow_0x7shtq"> + <di:waypoint x="445" y="281" /> + <di:waypoint x="484" y="281" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="456" y="263" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_013bc74_di" bpmnElement="SequenceFlow_013bc74"> + <di:waypoint x="218" y="281" /> + <di:waypoint x="260" y="281" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="252" y="340" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1j1qqcs_di" bpmnElement="SequenceFlow_1j1qqcs"> + <di:waypoint x="896" y="120" /> + <di:waypoint x="949" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="862.5" y="179" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1re5jor_di" bpmnElement="SequenceFlow_1re5jor"> + <di:waypoint x="878" y="281" /> + <di:waypoint x="917" y="281" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="837.5" y="340" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_08q2fd9_di" bpmnElement="SequenceFlow_08q2fd9"> + <di:waypoint x="360" y="281" /> + <di:waypoint x="395" y="281" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="402" y="340" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_09uu75h_di" bpmnElement="Flow_09uu75h"> + <di:waypoint x="1017" y="281" /> + <di:waypoint x="1056" y="281" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="931.5" y="336" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0c94gye_di" bpmnElement="Flow_0c94gye"> + <di:waypoint x="736" y="281" /> + <di:waypoint x="778" y="281" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="652" y="336" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1c9nkx4_di" bpmnElement="Flow_1c9nkx4"> + <di:waypoint x="584" y="281" /> + <di:waypoint x="636" y="281" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="505" y="336" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1973d9m_di" bpmnElement="Flow_1973d9m"> + <di:waypoint x="600" y="120" /> + <di:waypoint x="654" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="522" y="175" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1r07vnu_di" bpmnElement="Flow_1r07vnu"> + <di:waypoint x="440" y="120" /> + <di:waypoint x="500" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0da7dao_di" bpmnElement="Flow_0da7dao"> + <di:waypoint x="754" y="120" /> + <di:waypoint x="796" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="670" y="175" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ym7ydc_di" bpmnElement="SequenceFlow_1ym7ydc"> + <di:waypoint x="284" y="120" /> + <di:waypoint x="340" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="207" y="179" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="248" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="254" y="145" width="25" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1av4kxa_di" bpmnElement="EndEvent_1av4kxa"> + <dc:Bounds x="1056" y="263" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1064" y="306" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_16cbdb6_di" bpmnElement="Task_1htaioi"> + <dc:Bounds x="500" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1wo5rx5_di" bpmnElement="Activity_1264hec"> + <dc:Bounds x="340" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0csnjjc_di" bpmnElement="Task_16983t3"> + <dc:Bounds x="796" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_05dh84g_di" bpmnElement="Activity_12jcmzc"> + <dc:Bounds x="260" y="241" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ge2y0l_di" bpmnElement="Activity_0ge2y0l"> + <dc:Bounds x="484" y="241" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_19xwwnc_di" bpmnElement="Activity_19xwwnc"> + <dc:Bounds x="636" y="241" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0k70k5i_di" bpmnElement="Activity_0no0sxa"> + <dc:Bounds x="654" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0mb2ssd_di" bpmnElement="Activity_1t49t6c"> + <dc:Bounds x="778" y="241" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0t6viuq_di" bpmnElement="Activity_0t6viuq"> + <dc:Bounds x="917" y="241" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateThrowEvent_06785ru_di" bpmnElement="IntermediateThrowEvent_09rhn4h"> + <dc:Bounds x="949" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="923" y="142" width="90" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_09u3rdp_di" bpmnElement="IntermediateThrowEvent_0qh9wy2"> + <dc:Bounds x="182" y="263" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="156" y="303" width="90" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_0sfmiku_di" bpmnElement="Gateway_0sfmiku" isMarkerVisible="true"> + <dc:Bounds x="395" y="256" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="380" y="226" width="80" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_08h38js_di" bpmnElement="Activity_08h38js" isExpanded="true"> + <dc:Bounds x="250" y="440" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_128o22z_di" bpmnElement="Flow_128o22z"> + <di:waypoint x="640" y="544" /> + <di:waypoint x="710" y="544" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0kadgoq_di" bpmnElement="Flow_0kadgoq"> + <di:waypoint x="480" y="544" /> + <di:waypoint x="540" y="544" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0nauwik_di" bpmnElement="Flow_0nauwik"> + <di:waypoint x="316" y="544" /> + <di:waypoint x="380" y="544" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0y8rsb3_di" bpmnElement="Flow_0y8rsb3"> + <di:waypoint x="810" y="544" /> + <di:waypoint x="918" y="544" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_07tr56z_di" bpmnElement="Event_07tr56z"> + <dc:Bounds x="280" y="526" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_02arrfq_di" bpmnElement="Event_02arrfq"> + <dc:Bounds x="918" y="526" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1150yu6_di" bpmnElement="Activity_1150yu6"> + <dc:Bounds x="710" y="504" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0sqggtb_di" bpmnElement="Activity_0sqggtb"> + <dc:Bounds x="380" y="504" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1btidug_di" bpmnElement="Activity_1btidug"> + <dc:Bounds x="540" y="504" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateNSSI.bpmn index db805ecb92..c107cfb53a 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateNSSI.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_0884541" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_0884541" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.2"> <bpmn:process id="DoDeallocateNSSIV1" name="DoDeallocateNSSIV1" isExecutable="true"> <bpmn:startEvent id="StartEvent_1" name="start"> <bpmn:outgoing>SequenceFlow_05jfhy6</bpmn:outgoing> @@ -35,25 +35,15 @@ dnssi.processDecomposition(execution)</bpmn:script> <bpmn:sequenceFlow id="SequenceFlow_1e7o57n" sourceRef="Task_15ut397" targetRef="Task_0vi4ijv" /> <bpmn:scriptTask id="Task_0vi4ijv" name="Send deallocate request to NSSMF" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_1e7o57n</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_03b0822</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1wj89r5</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def dnssi= new DoDeallocateNSSI() dnssi.sendRequestToNSSMF(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_03b0822" sourceRef="Task_0vi4ijv" targetRef="Task_0kl6lcq" /> - <bpmn:scriptTask id="Task_0kl6lcq" name="Query Job Status" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_03b0822</bpmn:incoming> - <bpmn:incoming>SequenceFlow_1anlirk</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1jj0p5q</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def dnssi= new DoDeallocateNSSI() -dnssi.getJobStatus(execution)</bpmn:script> - </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_1jj0p5q" sourceRef="Task_0kl6lcq" targetRef="ExclusiveGateway_0nhfsui" /> - <bpmn:exclusiveGateway id="ExclusiveGateway_0nhfsui" name="Is deallocate finish?" default="SequenceFlow_0sfh52b"> - <bpmn:incoming>SequenceFlow_1jj0p5q</bpmn:incoming> + <bpmn:exclusiveGateway id="ExclusiveGateway_0nhfsui" name="Is deallocate finish?"> + <bpmn:incoming>SequenceFlow_02327ff</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0xq380j</bpmn:outgoing> - <bpmn:outgoing>SequenceFlow_0sfh52b</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1wpbkt9</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:scriptTask id="Task_13vaezk" name="Delete Slice Profile From AAI" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_0xq380j</bpmn:incoming> @@ -77,15 +67,6 @@ dnssi.delSliceProfileFromAAI(execution)</bpmn:script> def dnssi= new DoDeallocateNSSI() dnssi.preProcessRequest(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_1anlirk" sourceRef="Task_0fxuz4i" targetRef="Task_0kl6lcq" /> - <bpmn:scriptTask id="Task_0fxuz4i" name="TimeDelay" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_1ugva41</bpmn:incoming> - <bpmn:incoming>SequenceFlow_1u66wjs</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1anlirk</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def dnssi= new DoDeallocateNSSI() -dnssi.timeDelay(execution)</bpmn:script> - </bpmn:scriptTask> <bpmn:serviceTask id="Task_0amt4hu" name="Update Service Operation Status"> <bpmn:extensionElements> <camunda:connector> @@ -105,149 +86,171 @@ dnssi.timeDelay(execution)</bpmn:script> <camunda:connectorId>http-connector</camunda:connectorId> </camunda:connector> </bpmn:extensionElements> - <bpmn:incoming>SequenceFlow_04vg0c2</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1ugva41</bpmn:outgoing> + <bpmn:incoming>SequenceFlow_19cdxhv</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_02327ff</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:exclusiveGateway id="ExclusiveGateway_0y0w592" name="IsNeedUpdateDB?" default="SequenceFlow_1u66wjs"> - <bpmn:incoming>SequenceFlow_0sfh52b</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0r95j9m</bpmn:outgoing> - <bpmn:outgoing>SequenceFlow_1u66wjs</bpmn:outgoing> - </bpmn:exclusiveGateway> - <bpmn:sequenceFlow id="SequenceFlow_0sfh52b" sourceRef="ExclusiveGateway_0nhfsui" targetRef="ExclusiveGateway_0y0w592" /> - <bpmn:sequenceFlow id="SequenceFlow_0r95j9m" sourceRef="ExclusiveGateway_0y0w592" targetRef="Task_1renmzf"> - <bpmn:documentation>#{(execution.getVariable("isNeedUpdateDB" ) == true)}</bpmn:documentation> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isNeedUpdateDB" ) == true)}</bpmn:conditionExpression> - </bpmn:sequenceFlow> - <bpmn:sequenceFlow id="SequenceFlow_04vg0c2" sourceRef="Task_1renmzf" targetRef="Task_0amt4hu" /> - <bpmn:sequenceFlow id="SequenceFlow_1ugva41" sourceRef="Task_0amt4hu" targetRef="Task_0fxuz4i" /> - <bpmn:sequenceFlow id="SequenceFlow_1u66wjs" sourceRef="ExclusiveGateway_0y0w592" targetRef="Task_0fxuz4i" /> <bpmn:scriptTask id="Task_1renmzf" name="Prepare Update Operation Status" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_0r95j9m</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_04vg0c2</bpmn:outgoing> + <bpmn:incoming>SequenceFlow_0o7qjoo</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_19cdxhv</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dnssi= new DoDeallocateNSSI() +dnssi.prepareUpdateOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Task_1x3et9h" name="Query Job Status" calledElement="QueryJobStatus"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> + <camunda:in source="serviceModelInfo" target="serviceModelInfo" /> + <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> + <camunda:out source="serviceDecompositionString" target="serviceDecompositionString" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0w01l14</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_10nogqz</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_10nogqz" sourceRef="Task_1x3et9h" targetRef="Task_1v3sdzq" /> + <bpmn:sequenceFlow id="SequenceFlow_1wj89r5" sourceRef="Task_0vi4ijv" targetRef="Task_1vt5xaa" /> + <bpmn:scriptTask id="Task_1v3sdzq" name="Handle Job Status" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_10nogqz</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0o7qjoo</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def dnssi= new DoDeallocateNSSI() dnssi.handleJobStatus(execution)</bpmn:script> </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0o7qjoo" sourceRef="Task_1v3sdzq" targetRef="Task_1renmzf" /> + <bpmn:scriptTask id="Task_1vt5xaa" name="prepare QueryJobStatus Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1wj89r5</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0w01l14</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dnssi= new DoDeallocateNSSI() +dnssi.prepareJobStatusRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0w01l14" sourceRef="Task_1vt5xaa" targetRef="Task_1x3et9h" /> + <bpmn:sequenceFlow id="SequenceFlow_19cdxhv" sourceRef="Task_1renmzf" targetRef="Task_0amt4hu" /> + <bpmn:sequenceFlow id="SequenceFlow_02327ff" sourceRef="Task_0amt4hu" targetRef="ExclusiveGateway_0nhfsui" /> + <bpmn:endEvent id="Event_11u9vp2"> + <bpmn:incoming>SequenceFlow_1wpbkt9</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_11pdh1q" errorRef="Error_1o5kb95" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1wpbkt9" name="no" sourceRef="ExclusiveGateway_0nhfsui" targetRef="Event_11u9vp2" /> </bpmn:process> + <bpmn:error id="Error_1o5kb95" name="MSO Workflow Exception" errorCode="MSOWorkflowException" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoDeallocateNSSIV1"> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> - <dc:Bounds x="192" y="112" width="36" height="36" /> + <bpmndi:BPMNEdge id="Flow_1wpbkt9_di" bpmnElement="SequenceFlow_1wpbkt9"> + <di:waypoint x="1860" y="155" /> + <di:waypoint x="1860" y="212" /> <bpmndi:BPMNLabel> - <dc:Bounds x="199" y="155" width="22" height="14" /> + <dc:Bounds x="1869" y="165" width="13" height="14" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_02327ff_di" bpmnElement="SequenceFlow_02327ff"> + <di:waypoint x="1770" y="130" /> + <di:waypoint x="1835" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_19cdxhv_di" bpmnElement="SequenceFlow_19cdxhv"> + <di:waypoint x="1610" y="130" /> + <di:waypoint x="1670" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0w01l14_di" bpmnElement="SequenceFlow_0w01l14"> + <di:waypoint x="1120" y="130" /> + <di:waypoint x="1190" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0o7qjoo_di" bpmnElement="SequenceFlow_0o7qjoo"> + <di:waypoint x="1450" y="130" /> + <di:waypoint x="1510" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1wj89r5_di" bpmnElement="SequenceFlow_1wj89r5"> + <di:waypoint x="970" y="130" /> + <di:waypoint x="1020" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_10nogqz_di" bpmnElement="SequenceFlow_10nogqz"> + <di:waypoint x="1290" y="130" /> + <di:waypoint x="1350" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0eug5nv_di" bpmnElement="SequenceFlow_0eug5nv"> + <di:waypoint x="340" y="130" /> + <di:waypoint x="390" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0xq380j_di" bpmnElement="SequenceFlow_0xq380j"> + <di:waypoint x="1885" y="130" /> + <di:waypoint x="1940" y="130" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1904" y="112" width="17" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ii5002_di" bpmnElement="SequenceFlow_1ii5002"> + <di:waypoint x="2040" y="130" /> + <di:waypoint x="2102" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1e7o57n_di" bpmnElement="SequenceFlow_1e7o57n"> + <di:waypoint x="800" y="130" /> + <di:waypoint x="870" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1e451y9_di" bpmnElement="SequenceFlow_1e451y9"> + <di:waypoint x="650" y="130" /> + <di:waypoint x="700" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0wlyy5i_di" bpmnElement="SequenceFlow_0wlyy5i"> + <di:waypoint x="490" y="130" /> + <di:waypoint x="550" y="130" /> + </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_05jfhy6_di" bpmnElement="SequenceFlow_05jfhy6"> - <di:waypoint x="228" y="130" /> - <di:waypoint x="310" y="130" /> + <di:waypoint x="188" y="130" /> + <di:waypoint x="240" y="130" /> </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="152" y="112" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="159" y="155" width="23" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_159g5ey_di" bpmnElement="Task_1m8upus"> - <dc:Bounds x="490" y="90" width="100" height="80" /> + <dc:Bounds x="390" y="90" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0wlyy5i_di" bpmnElement="SequenceFlow_0wlyy5i"> - <di:waypoint x="590" y="130" /> - <di:waypoint x="660" y="130" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_1ep4ama_di" bpmnElement="Task_1giechg"> - <dc:Bounds x="660" y="90" width="100" height="80" /> + <dc:Bounds x="550" y="90" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1e451y9_di" bpmnElement="SequenceFlow_1e451y9"> - <di:waypoint x="760" y="130" /> - <di:waypoint x="820" y="130" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1yt5s46_di" bpmnElement="Task_15ut397"> - <dc:Bounds x="820" y="90" width="100" height="80" /> + <dc:Bounds x="700" y="90" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1e7o57n_di" bpmnElement="SequenceFlow_1e7o57n"> - <di:waypoint x="920" y="130" /> - <di:waypoint x="970" y="130" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_16dxpvz_di" bpmnElement="Task_0vi4ijv"> - <dc:Bounds x="970" y="90" width="100" height="80" /> + <dc:Bounds x="870" y="90" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_03b0822_di" bpmnElement="SequenceFlow_03b0822"> - <di:waypoint x="1070" y="130" /> - <di:waypoint x="1120" y="130" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_0arl3j9_di" bpmnElement="Task_0kl6lcq"> - <dc:Bounds x="1120" y="90" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1jj0p5q_di" bpmnElement="SequenceFlow_1jj0p5q"> - <di:waypoint x="1220" y="130" /> - <di:waypoint x="1505" y="130" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_0nhfsui_di" bpmnElement="ExclusiveGateway_0nhfsui" isMarkerVisible="true"> - <dc:Bounds x="1505" y="105" width="50" height="50" /> + <dc:Bounds x="1835" y="105" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1501" y="75" width="63" height="27" /> + <dc:Bounds x="1831" y="75" width="63" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1rfdrw3_di" bpmnElement="Task_13vaezk"> - <dc:Bounds x="1690" y="90" width="100" height="80" /> + <dc:Bounds x="1940" y="90" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_1f579t4_di" bpmnElement="EndEvent_1f579t4"> - <dc:Bounds x="1862" y="112" width="36" height="36" /> + <dc:Bounds x="2102" y="112" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1871" y="155" width="19" height="14" /> + <dc:Bounds x="2111" y="155" width="19" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1ii5002_di" bpmnElement="SequenceFlow_1ii5002"> - <di:waypoint x="1790" y="130" /> - <di:waypoint x="1862" y="130" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0xq380j_di" bpmnElement="SequenceFlow_0xq380j"> - <di:waypoint x="1555" y="130" /> - <di:waypoint x="1690" y="130" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1614" y="112" width="17" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0eug5nv_di" bpmnElement="SequenceFlow_0eug5nv"> - <di:waypoint x="410" y="130" /> - <di:waypoint x="490" y="130" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1dytya8_di" bpmnElement="Task_1vste9s"> - <dc:Bounds x="310" y="90" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1anlirk_di" bpmnElement="SequenceFlow_1anlirk"> - <di:waypoint x="1170" y="190" /> - <di:waypoint x="1170" y="170" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_0a4zalz_di" bpmnElement="Task_0fxuz4i"> - <dc:Bounds x="1120" y="190" width="100" height="80" /> + <dc:Bounds x="240" y="90" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0vegqix_di" bpmnElement="Task_0amt4hu"> - <dc:Bounds x="1280" y="300" width="100" height="80" /> + <dc:Bounds x="1670" y="90" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ExclusiveGateway_0y0w592_di" bpmnElement="ExclusiveGateway_0y0w592" isMarkerVisible="true"> - <dc:Bounds x="1505" y="205" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1567" y="216" width="86" height="27" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0sfh52b_di" bpmnElement="SequenceFlow_0sfh52b"> - <di:waypoint x="1530" y="155" /> - <di:waypoint x="1530" y="205" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0r95j9m_di" bpmnElement="SequenceFlow_0r95j9m"> - <di:waypoint x="1530" y="255" /> - <di:waypoint x="1530" y="300" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_04vg0c2_di" bpmnElement="SequenceFlow_04vg0c2"> - <di:waypoint x="1480" y="340" /> - <di:waypoint x="1380" y="340" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1ugva41_di" bpmnElement="SequenceFlow_1ugva41"> - <di:waypoint x="1280" y="340" /> - <di:waypoint x="1170" y="340" /> - <di:waypoint x="1170" y="270" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1u66wjs_di" bpmnElement="SequenceFlow_1u66wjs"> - <di:waypoint x="1505" y="230" /> - <di:waypoint x="1220" y="230" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_10pw6ot_di" bpmnElement="Task_1renmzf"> - <dc:Bounds x="1480" y="300" width="100" height="80" /> + <dc:Bounds x="1510" y="90" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1x3et9h_di" bpmnElement="Task_1x3et9h"> + <dc:Bounds x="1190" y="90" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1v3sdzq_di" bpmnElement="Task_1v3sdzq"> + <dc:Bounds x="1350" y="90" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1vt5xaa_di" bpmnElement="Task_1vt5xaa"> + <dc:Bounds x="1020" y="90" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_11u9vp2_di" bpmnElement="Event_11u9vp2"> + <dc:Bounds x="1842" y="212" width="36" height="36" /> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteSliceService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteSliceService.bpmn index 5f4816e78f..5510dcde38 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteSliceService.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteSliceService.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1p1suc9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1p1suc9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.2"> <bpmn:process id="DoDeleteSliceServiceV1" name="DoDeleteSliceServiceV1" isExecutable="true"> <bpmn:startEvent id="StartEvent_1" name="start"> <bpmn:outgoing>SequenceFlow_0ep5het</bpmn:outgoing> @@ -23,12 +23,11 @@ ddss.getNSIFromAAI(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:scriptTask id="Task_1u755sr" name="Query NSSI List From AAI" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_1rgfzzy</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_05si1me</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1aa2ek0</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def ddss= new DoDeleteSliceService() ddss.getNSSIListFromAAI(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_05si1me" sourceRef="Task_1u755sr" targetRef="Task_1iomfas" /> <bpmn:exclusiveGateway id="ExclusiveGateway_1ogbunu" name="Is all NSSI finished?"> <bpmn:incoming>SequenceFlow_15z9iio</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1c4fjbv</bpmn:outgoing> @@ -40,7 +39,6 @@ ddss.getNSSIListFromAAI(execution)</bpmn:script> <bpmn:sequenceFlow id="SequenceFlow_1c4fjbv" name="yes" sourceRef="ExclusiveGateway_1ogbunu" targetRef="EndEvent_0jaitqv"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isAllNSSIFinished" ) == true)}</bpmn:conditionExpression> </bpmn:sequenceFlow> - <bpmn:sequenceFlow id="SequenceFlow_01o2qpv" sourceRef="Task_1iomfas" targetRef="Task_1qqljvu" /> <bpmn:sequenceFlow id="SequenceFlow_0c58sw3" sourceRef="Task_1rc7mcw" targetRef="ScriptTask_159855t" /> <bpmn:sequenceFlow id="SequenceFlow_0926ghe" name="no" sourceRef="ExclusiveGateway_1ogbunu" targetRef="Task_1iomfas"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isAllNSSIFinished" ) == false)}</bpmn:conditionExpression> @@ -55,8 +53,8 @@ ddss.preProcessRequest(execution)</bpmn:script> <bpmn:sequenceFlow id="SequenceFlow_0npmman" sourceRef="Task_0etki1p" targetRef="Task_13k9usx" /> <bpmn:scriptTask id="Task_1iomfas" name="Get Current NSSI" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_0926ghe</bpmn:incoming> - <bpmn:incoming>SequenceFlow_05si1me</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_01o2qpv</bpmn:outgoing> + <bpmn:incoming>SequenceFlow_1252rbf</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_17tvomo</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def ddss= new DoDeleteSliceService() ddss.getCurrentNSSI(execution)</bpmn:script> @@ -69,14 +67,6 @@ def ddss= new DoDeleteSliceService() ddss.parseNextNSSI(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_15z9iio" sourceRef="ScriptTask_159855t" targetRef="ExclusiveGateway_1ogbunu" /> - <bpmn:sequenceFlow id="SequenceFlow_0q83qg3" sourceRef="Task_1qqljvu" targetRef="Task_1rc7mcw" /> - <bpmn:scriptTask id="Task_1qqljvu" name="Query Slice Profile From AAI" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_01o2qpv</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0q83qg3</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def ddss= new DoDeleteSliceService() -ddss.querySliceProfileFromAAI(execution)</bpmn:script> - </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_029u1wr" sourceRef="Task_13k9usx" targetRef="Task_1ujnqtj" /> <bpmn:scriptTask id="Task_13k9usx" name="Query E2ESlice Serive From AAI" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_0npmman</bpmn:incoming> @@ -93,30 +83,84 @@ ddss.queryE2ESliceSeriveFromAAI(execution)</bpmn:script> <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> <camunda:out source="WorkflowException" target="WorkflowException" /> </bpmn:extensionElements> - <bpmn:incoming>SequenceFlow_0q83qg3</bpmn:incoming> + <bpmn:incoming>SequenceFlow_17tvomo</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0c58sw3</bpmn:outgoing> </bpmn:callActivity> + <bpmn:scriptTask id="Task_1iuls9p" name="Terminate NSI Query" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1aa2ek0</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1252rbf</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dss= new DeleteSliceService() +dss.terminateNSIQuery(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_17tvomo" sourceRef="Task_1iomfas" targetRef="Task_1rc7mcw" /> + <bpmn:sequenceFlow id="SequenceFlow_1aa2ek0" sourceRef="Task_1u755sr" targetRef="Task_1iuls9p" /> + <bpmn:sequenceFlow id="SequenceFlow_1252rbf" sourceRef="Task_1iuls9p" targetRef="Task_1iomfas" /> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoDeleteSliceServiceV1"> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> - <dc:Bounds x="152" y="122" width="36" height="36" /> + <bpmndi:BPMNEdge id="Flow_1252rbf_di" bpmnElement="SequenceFlow_1252rbf"> + <di:waypoint x="1150" y="140" /> + <di:waypoint x="1200" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1aa2ek0_di" bpmnElement="SequenceFlow_1aa2ek0"> + <di:waypoint x="1000" y="140" /> + <di:waypoint x="1050" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_17tvomo_di" bpmnElement="SequenceFlow_17tvomo"> + <di:waypoint x="1300" y="140" /> + <di:waypoint x="1370" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_029u1wr_di" bpmnElement="SequenceFlow_029u1wr"> + <di:waypoint x="530" y="140" /> + <di:waypoint x="600" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_15z9iio_di" bpmnElement="SequenceFlow_15z9iio"> + <di:waypoint x="1640" y="140" /> + <di:waypoint x="1715" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0npmman_di" bpmnElement="SequenceFlow_0npmman"> + <di:waypoint x="370" y="140" /> + <di:waypoint x="430" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0926ghe_di" bpmnElement="SequenceFlow_0926ghe"> + <di:waypoint x="1740" y="165" /> + <di:waypoint x="1740" y="260" /> + <di:waypoint x="1250" y="260" /> + <di:waypoint x="1250" y="180" /> <bpmndi:BPMNLabel> - <dc:Bounds x="159" y="165" width="22" height="14" /> + <dc:Bounds x="1489" y="242" width="13" height="14" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0ep5het_di" bpmnElement="SequenceFlow_0ep5het"> - <di:waypoint x="188" y="140" /> - <di:waypoint x="270" y="140" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1qkgvvu_di" bpmnElement="SequenceFlow_1qkgvvu"> - <di:waypoint x="700" y="140" /> - <di:waypoint x="750" y="140" /> + <bpmndi:BPMNEdge id="SequenceFlow_0c58sw3_di" bpmnElement="SequenceFlow_0c58sw3"> + <di:waypoint x="1470" y="140" /> + <di:waypoint x="1540" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1c4fjbv_di" bpmnElement="SequenceFlow_1c4fjbv"> + <di:waypoint x="1765" y="140" /> + <di:waypoint x="1802" y="140" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1771" y="118" width="17" height="14" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1rgfzzy_di" bpmnElement="SequenceFlow_1rgfzzy"> <di:waypoint x="850" y="140" /> <di:waypoint x="900" y="140" /> </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1qkgvvu_di" bpmnElement="SequenceFlow_1qkgvvu"> + <di:waypoint x="700" y="140" /> + <di:waypoint x="750" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0ep5het_di" bpmnElement="SequenceFlow_0ep5het"> + <di:waypoint x="188" y="140" /> + <di:waypoint x="270" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="152" y="122" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="159" y="165" width="22" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1bj6tw4_di" bpmnElement="Task_1ujnqtj"> <dc:Bounds x="600" y="100" width="100" height="80" /> </bpmndi:BPMNShape> @@ -126,79 +170,35 @@ ddss.queryE2ESliceSeriveFromAAI(execution)</bpmn:script> <bpmndi:BPMNShape id="ScriptTask_01fp1vt_di" bpmnElement="Task_1u755sr"> <dc:Bounds x="900" y="100" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_05si1me_di" bpmnElement="SequenceFlow_05si1me"> - <di:waypoint x="1000" y="140" /> - <di:waypoint x="1040" y="140" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_1ogbunu_di" bpmnElement="ExclusiveGateway_1ogbunu" isMarkerVisible="true"> - <dc:Bounds x="1555" y="115" width="50" height="50" /> + <dc:Bounds x="1715" y="115" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1560" y="85" width="52" height="27" /> + <dc:Bounds x="1720" y="85" width="52" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_0jaitqv_di" bpmnElement="EndEvent_0jaitqv"> - <dc:Bounds x="1692" y="122" width="36" height="36" /> + <dc:Bounds x="1802" y="122" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1700" y="168" width="20" height="14" /> + <dc:Bounds x="1810" y="168" width="20" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1c4fjbv_di" bpmnElement="SequenceFlow_1c4fjbv"> - <di:waypoint x="1605" y="140" /> - <di:waypoint x="1692" y="140" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1630" y="118" width="17" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_01o2qpv_di" bpmnElement="SequenceFlow_01o2qpv"> - <di:waypoint x="1140" y="140" /> - <di:waypoint x="1170" y="140" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0c58sw3_di" bpmnElement="SequenceFlow_0c58sw3"> - <di:waypoint x="1400" y="140" /> - <di:waypoint x="1420" y="140" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0926ghe_di" bpmnElement="SequenceFlow_0926ghe"> - <di:waypoint x="1580" y="165" /> - <di:waypoint x="1580" y="260" /> - <di:waypoint x="1090" y="260" /> - <di:waypoint x="1090" y="180" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1329" y="242" width="13" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_0icszw6_di" bpmnElement="Task_0etki1p"> <dc:Bounds x="270" y="100" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0npmman_di" bpmnElement="SequenceFlow_0npmman"> - <di:waypoint x="370" y="140" /> - <di:waypoint x="430" y="140" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1obnwrr_di" bpmnElement="Task_1iomfas"> - <dc:Bounds x="1040" y="100" width="100" height="80" /> + <dc:Bounds x="1200" y="100" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_159855t_di" bpmnElement="ScriptTask_159855t"> - <dc:Bounds x="1420" y="100" width="100" height="80" /> + <dc:Bounds x="1540" y="100" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_15z9iio_di" bpmnElement="SequenceFlow_15z9iio"> - <di:waypoint x="1520" y="140" /> - <di:waypoint x="1555" y="140" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0q83qg3_di" bpmnElement="SequenceFlow_0q83qg3"> - <di:waypoint x="1270" y="140" /> - <di:waypoint x="1300" y="140" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_0y9ppnc_di" bpmnElement="Task_1qqljvu"> - <dc:Bounds x="1170" y="100" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_029u1wr_di" bpmnElement="SequenceFlow_029u1wr"> - <di:waypoint x="530" y="140" /> - <di:waypoint x="600" y="140" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_0f9rjq4_di" bpmnElement="Task_13k9usx"> <dc:Bounds x="430" y="100" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_18qkiat_di" bpmnElement="Task_1rc7mcw"> - <dc:Bounds x="1300" y="100" width="100" height="80" /> + <dc:Bounds x="1370" y="100" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1iuls9p_di" bpmnElement="Task_1iuls9p"> + <dc:Bounds x="1050" y="100" width="100" height="80" /> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoHandleOofRequest.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoHandleOofRequest.bpmn index 7ca1a62312..d6b251649f 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoHandleOofRequest.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoHandleOofRequest.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0nlt5gi" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0nlt5gi" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> <bpmn:process id="DoHandleOofRequest" name="DoHandleOofRequest" isExecutable="true"> <bpmn:startEvent id="StartEvent_1"> <bpmn:outgoing>Flow_1jorico</bpmn:outgoing> @@ -10,8 +10,7 @@ <bpmn:outgoing>Flow_013jfci</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.common.scripts.* def oofHandler = new DoHandleOofRequest() -oofHandler .callOofAdapter(execution) -</bpmn:script> +oofHandler.callOofAdapter(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="Flow_1jorico" sourceRef="StartEvent_1" targetRef="Activity_0tki17o" /> <bpmn:scriptTask id="Activity_0tki17o" name="Preprocess Request" scriptFormat="groovy"> @@ -19,8 +18,7 @@ oofHandler .callOofAdapter(execution) <bpmn:outgoing>Flow_1fbzzqg</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.common.scripts.* def oofHandler = new DoHandleOofRequest() -oofHandler .preProcessRequest(execution) -</bpmn:script> +oofHandler .preProcessRequest(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:subProcess id="Activity_02ru8n9" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> <bpmn:startEvent id="Event_1r00tca"> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/QueryJobStatus.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/QueryJobStatus.bpmn new file mode 100644 index 0000000000..b2b6c031f9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/QueryJobStatus.bpmn @@ -0,0 +1,141 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0le3oyh" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.2"> + <bpmn:process id="QueryJobStatus" name="QueryJobStatus" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1" name="Start"> + <bpmn:outgoing>Flow_16nxw2f</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="Activity_0cd23fy" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_16nxw2f</bpmn:incoming> + <bpmn:outgoing>Flow_0qhl0m8</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def qjs= new QueryJobStatus() +qjs.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1aivult" name="Query Job Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${NSSMF_AdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/json</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${NSSMF_AdapterRequest}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_ResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_Response">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0qhl0m8</bpmn:incoming> + <bpmn:incoming>Flow_1qqqckj</bpmn:incoming> + <bpmn:outgoing>Flow_18di8yy</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_16nxw2f" sourceRef="StartEvent_1" targetRef="Activity_0cd23fy" /> + <bpmn:sequenceFlow id="Flow_0qhl0m8" sourceRef="Activity_0cd23fy" targetRef="Activity_1aivult" /> + <bpmn:scriptTask id="Activity_16hyg49" name="Check Job Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_18di8yy</bpmn:incoming> + <bpmn:outgoing>Flow_0ct1kfw</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def qjs= new QueryJobStatus() +qjs.checkJobStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_1ruy0j9" name="Is Completed?"> + <bpmn:incoming>Flow_0ct1kfw</bpmn:incoming> + <bpmn:outgoing>Flow_1x9fug6</bpmn:outgoing> + <bpmn:outgoing>Flow_1qqqckj</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_18di8yy" sourceRef="Activity_1aivult" targetRef="Activity_16hyg49" /> + <bpmn:sequenceFlow id="Flow_0ct1kfw" sourceRef="Activity_16hyg49" targetRef="Gateway_1ruy0j9" /> + <bpmn:scriptTask id="Activity_0rtwx97" name="Update JobStatus details" scriptFormat="groovy"> + <bpmn:incoming>Flow_1x9fug6</bpmn:incoming> + <bpmn:outgoing>Flow_0qqltc9</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def qjs= new QueryJobStatus() +qjs.updateJobStatusDetails(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1x9fug6" name="yes" sourceRef="Gateway_1ruy0j9" targetRef="Activity_0rtwx97"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("JobStatusCompleted") == "TRUE"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:endEvent id="Event_0p00z2s" name="End"> + <bpmn:incoming>Flow_0qqltc9</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_0qqltc9" sourceRef="Activity_0rtwx97" targetRef="Event_0p00z2s" /> + <bpmn:sequenceFlow id="Flow_1qqqckj" name="No" sourceRef="Gateway_1ruy0j9" targetRef="Activity_1aivult"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("JobStatusCompleted") == "FALSE"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="QueryJobStatus"> + <bpmndi:BPMNEdge id="Flow_1qqqckj_di" bpmnElement="Flow_1qqqckj"> + <di:waypoint x="880" y="152" /> + <di:waypoint x="880" y="280" /> + <di:waypoint x="550" y="280" /> + <di:waypoint x="550" y="167" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="892" y="163" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0qqltc9_di" bpmnElement="Flow_0qqltc9"> + <di:waypoint x="1100" y="127" /> + <di:waypoint x="1152" y="127" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1x9fug6_di" bpmnElement="Flow_1x9fug6"> + <di:waypoint x="905" y="127" /> + <di:waypoint x="1000" y="127" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="944" y="109" width="17" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ct1kfw_di" bpmnElement="Flow_0ct1kfw"> + <di:waypoint x="780" y="127" /> + <di:waypoint x="855" y="127" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_18di8yy_di" bpmnElement="Flow_18di8yy"> + <di:waypoint x="600" y="127" /> + <di:waypoint x="680" y="127" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0qhl0m8_di" bpmnElement="Flow_0qhl0m8"> + <di:waypoint x="410" y="127" /> + <di:waypoint x="500" y="127" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_16nxw2f_di" bpmnElement="Flow_16nxw2f"> + <di:waypoint x="215" y="127" /> + <di:waypoint x="310" y="127" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="179" y="109" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="186" y="152" width="25" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0cd23fy_di" bpmnElement="Activity_0cd23fy"> + <dc:Bounds x="310" y="87" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1aivult_di" bpmnElement="Activity_1aivult"> + <dc:Bounds x="500" y="87" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_16hyg49_di" bpmnElement="Activity_16hyg49"> + <dc:Bounds x="680" y="87" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1ruy0j9_di" bpmnElement="Gateway_1ruy0j9" isMarkerVisible="true"> + <dc:Bounds x="855" y="102" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="844" y="83" width="72" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0rtwx97_di" bpmnElement="Activity_0rtwx97"> + <dc:Bounds x="1000" y="87" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0p00z2s_di" bpmnElement="Event_0p00z2s"> + <dc:Bounds x="1152" y="109" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1160" y="152" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/docs/developer_info/BBUnderstanding.rst b/docs/developer_info/BBUnderstanding.rst index 2aa7097ad9..6e96e5dca2 100644 --- a/docs/developer_info/BBUnderstanding.rst +++ b/docs/developer_info/BBUnderstanding.rst @@ -5,3 +5,443 @@ Building Block Understanding
============================
+UNDERSTANDING BUILDING BLOCKS USING MACRO FLOW
+----------------------------------------------
+
+
+
+There are basically 2 flows - macro , a la carte.
+
+In a la carte we manually will initiate each step for a process.
+
+In macro , the whole flow happens at a single click - like if we want to create a service, the flow will itself look whether there are vnfs, pnfs or networks in the service and it will be created and activated in the flow also.
+
+Thus these independent tasks like if vnf is present, then assign create and activate vnf are all taken up as individual building blocks and are only called on need basis.
+
+
+Each and every request will reach to the api handler first.
+
+API HANDLER( ServiceInstances.java )
+------------------------------------
+
+
+
+# 1. Rest call reaching SO Api handler with the input json - According to the below path it is mapped to the createServiceInstance function in ServiceInstances file.
+
+curl -v -H "Content-Type: application/json" -X POST --data @serviceinstance.json -u mso_admin:password1$ http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances.
+
+# 2. Herein a unique requestid is generated corresponding to every request, and is checked whether that particular requestid exists in request db (Happens in createServiceInstance in ServiceInstances).
+
+ a. http://request-db-adapter:8083/infraActiveRequests/requestid (GET), which will return a 404 if not exists.
+
+ b. CreateInstance is set to the action variable. Here the request scope is set to service from the inputjson - modelType.
+
+# 3. Running local validations on input json.
+
+# 4. create InfraActiveRequests, to store request details in request db adapter and as a payload to bpmn.
+
+ a. A new InfraActiveRequests object is created. And all the necessary information from the input is set to it.
+
+ b. Retrieving productFamilyName from the input json to put into requests db. http://aai/servicedesigncreation/services/service/{productfamilyid} (GET), which will return a 404 if not exists in aai. If service exists, then that service's serviceDescritiption is set as productfamilyName.
+
+ c. http://aai/cloudinfrastructure/cloudregions/cloudregion/cloudowner/{lcpCloudRegionId}/tenants/tenant/{tenantId} (GET), checks for whether the particular cloud configuration exists in aai, if not exists returns 404. If we are able to get, then the tenant's name derived from aai is set as tenantName.
+
+ d. serviceInstanceNamee is derived from requestInfo.instanceName and is set.
+
+ e. Request json is also set as RequestBody of InfraActiveRequests.
+
+# 5. Checks fro whether duplicate name exists.
+
+ a. version v[integer] is converted to the particular integer and stored.
+
+ b. Checks whether instance name already exists in with a POST request in http://request-db-adapter:8083/infraActiveRequests/checkInstanceNameDuplicate, with the data { instanceIdmap = null, instanceName = {instanceName} , instanceservice = service } . It checks for the current progress and if in progress it throws the particular status.
+
+# 6. Gets the orchestration url from the recipe table.
+
+ a. Checks whether the service already exists in catalogdb http://catalog-db-adapter:8082/service/{modelNameVersionId} (GET).
+
+ b. Checks the service recipe table with the modelNameVersionId and the action to be performed http://catalog-db-adapter:8082/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID={modelNameVersionId}&action=createInstance . Returns a 404 if no recipe exists with the corresponding id.
+
+ c. As recipe corresponding to this doesn't exist, we try to get with a default value. This flow comes under generic resource flow so the default value is GR-API-DEFAULT. First we get service with this value http://catalog-db-adapter:8082/service/search/findFirstByModelNameOrderByModelVersionDesc?modelName=GR-API-DEFAULT (GET). It returns a service with modelUUID as d88da85c-d9e8-4f73-b837-3a72a431622b, and further can be used to get the recipe.
+
+ d. http://catalog-db-adapter:8082/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622b&action=createInstance (GET), gives a recipe which has a parameter "orchestrationUri" as "/mso/async/services/WorkflowActionBB".
+
+# 7. Updates the infraActiveRequests with the current request.
+ a. http://request-db-adapter:8083/infraActiveRequests/ (POST) with the data formed. And a 201 created response is received.
+
+# 8. Call the bpmn with a post call on orchestrationUri. The data to bpmn is prepared having parameters like
+ a. bpmnRequest - formed from input request.
+
+ b. vfModuleId, pnfCorrelationId, networkId, configurationId, vfModuleType, serviceInstanceId , serviceType are updated if present in the input json or else set to empty string.
+
+ c. apiVersion , requestId, aLaCarte = false (def), recipeTimeout = 180(def), requestAction= createInstance are all updated accordingly.
+
+ d. requestUri - v7/serviceInstances ,which is formed from the request url.
+
+
+# 9. A sync response is obtained on reaching bpmn like {"requestReferences":{"requestId":"c45702f7-3f08-4081-bc98-2f9f18b81607","instanceId":"cadca18f-9bff-44be-8910-ad29d342e91f","requestSelfLink":"http://159.138.57.166:30277/orchestrationRequests/v7/c45702f7-3f08-4081-bc98-2f9f18b81607"}}.
+
+
+
+
+
+
+BPMN
+-----
+
+
+Hits WorkflowActionBB.bpmn
+--------------------------
+
+.. image:: ../images/workflow.png
+
+
+# 1. RetrieveBBExecutionList - implemented in selectExecutionList in WorkflowAction.java
+
+a. resourcetype, resourceid are formed from matching the requestUri to a regex pattern matcher [pattern=[vV]\d+.*?(?:(?:/(?<type>vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances|instanceGroups)(?:/(?<id>[^/]+))?)(?:/(?<action>[^/]+))?(?:/resume)?)] .
+
+b. Checks whether there is a service subscription with service instance name as {instanceName} correspoding to the customer in aai https://aai.onap:8443/aai/v19/business/customers/customer/slice1/service-subscriptions/service-subscription/service/service-instances?depth=2&resultIndex=0&resultSize=1&service-instance-name={instanceName}. Returns 404 not found, if it doesnt exists then the id of that particular instance is taken and given as both the resourceid and serviceinstance id. If not present then a random value is generated, and is assigned same to both.
+
+c. Checks whether there is a service of the particular serviceInstanceId exists in aai. https://aai.onap:8443/aai/v19/nodes/service-instances/service-instance/{serviceInstanceId} , returns not found if it doesnt exist. If service with corresponding instance name already exists , then flowsToExecute is got by quering the requestdbadapter with the earlier request id. If not present, then only orchestrationflows are got, and later from that the flowsToExecute are found out.
+
+d. Get the particular service from catalogdb . http://so-catalog-db-adapter.onap:8082/service/{modelNameVersionId} (GET). Be sure that the service with this particular modelNameVersionId exists in catalogdb, because based on the services (like whether pnf, or vnf, or networkcollection) present in that particular service, which all bbs to execute are decided.
+
+e. This being a service, "service" is added to the resource list. And is checked upon for other resources like vnf and network, eg:
+
+ http://so-catalog-db-adapter.onap:8082/service/{modelNameVersionId}/vnfCustomizations (GET)
+ http://so-catalog-db-adapter.onap:8082/service/{modelNameVersionId}/collectionResourceCustomizations (GET)
+ http://so-catalog-db-adapter.onap:8082/service/{modelNameVersionId}/networkCustomizations (GET)
+ And depending on the reources in the service, the resources found is updated like
+ Found :Service - 1 Vnf - 0 Pnf - 0 VfModule - 0 VolumeGroup - 0 Network - 0 VirtualLink - 0 NetworkCollection - 0 Configuration - 0 InstanceGroup - 0
+
+f. Then the orchestration flows are get from the orchestration_flow_table depending on the cloudowner and request scope: http://so-catalog-db-adapter.onap:8082/northbound_request_ref_lookup/search/findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwnerAndServiceType action=createInstance&requestScope=Service&isALaCarte=false&cloudOwner={CloudOwner}&serviceType=%2A (GET) Here if present, then the orchestration flows are returned or else with default cloud owner, we try again
+
+http://so-catalog-db-adapter.onap:8082/northbound_request_ref_lookup/search/findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwnerAndServiceType?action=createInstance&requestScope=Service&isALaCarte=false&cloudOwner=DEFAULT&serviceType=%2A (GET)
+Here in northBoundRequest is returned which has the parameter orchestrationFlowList, that contains the link that will return the orchestration flows.
+
+"orchestrationFlowList" : { "href" : "http://so-catalog-db-adapter.onap:8082/northbound_request_ref_lookup/101/orchestrationFlowList"}
+
+Now we do a get on the orchestration flow link to get the set of orchestartion flows required
+http://so-catalog-db-adapter.onap:8082/northbound_request_ref_lookup/101/orchestrationFlowList.
+Here a set of 20 orchestration flows are returned under the action of Service-Macro-Create, each with a sequence no assigned sequentially in the given order
+AssignServiceInstanceBB,
+
+CreateNetworkCollectionBB,
+
+AssignNetworkBB,
+
+AssignVnfBB,
+
+AssignVolumeGroupBB,
+
+AssignVfModuleBB,
+
+ConfigAssignVnfBB,
+
+AssignPnfBB,
+
+WaitForPnfReadyBB,
+
+ActivatePnfBB,
+
+CreateNetworkBB,
+
+ActivateNetworkBB,
+
+CreateVolumeGroupBB,
+
+ActivateVolumeGroupBB,
+
+CreateVfModuleBB,
+
+ActivateVfModuleBB,
+
+ConfigDeployVnfBB,
+
+ActivateVnfBB,
+
+ActivateNetworkCollectionBB,
+
+ActivateServiceInstanceBB.
+
+
+.. image:: ../images/flowchart.png
+
+
+g. Flows to execute is determined by iterating through all the orchestartion flows and matching it with the found resources. It is merely a contains matching. In this particular as service was the only resource : List of BuildingBlocks to execute:AssignServiceInstanceBB, ActivateServiceInstanceBB.
+
+h. processing data is added to the requestdbadapter. Here the data is post to the requestdb as two different building blocks http://so-request-db-adapter.onap:8083/requestProcessingData.
+
+i. The already stored request details in request db is ammended like "lastModifiedBy" : "CamundaBPMN" , and status to in_progress with a put request.
+
+
+# 2. sendSyncAck - This was used to give an acknowledgement , with status code as 200, and requestId and resourceId is sent as content.
+
+
+# 3. Prevalidate the workflow
+
+
+# 4. SelectBB - implemented in selectBBin WorkflowActionBBTasks
+This is used to select the building block from the flows to execute depending on the sequence order.
+
+ a. Depending on the current sequence , the building block is selected from the flows to execute.
+
+ b. Execution variable, that is passed between the different building blocks as the payload is ammended as:
+
+ execution.setVariable("buildingBlock", buildingblockselected).
+
+ c. current sequence is incremented by 1, and updated in execution variable.
+
+ d. Depending on whether currentSequence is greater than flowsToExecute.size(), COMPLETED variable is either set to true or false.
+
+
+# 5. updateFlowStatistics - implemented in updateFlowStatistics in WorkflowActionBBTasks
+a. Depending on the current sequence no, the completed bb and next bb is got from the flows to execute. And these are mentioned in a statusMessage.
+b. Percentage progress is got from the total no of bbs
+c. These are ammended to the already present request in the request db
+
+# 6. Execute BB - calls the ExecuteBuildingBlock.bpmn
+
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+Hits ExecuteBuildingBlock.bpmn
+------------------------------
+
+.. image:: ../images/ExecuteBuildingBlock.png
+
+# 1. BBInputSetup - implemented in execute in BBInputSetup
+Here a generalbuildingblock is formed from executingbuildingblock after certain updations and validations.
+
+ a. lookupKeyMap is formed from the input , and a map is formed with serviceInstanceId, networkID, vnfID, pnfID, vfmoduleID, volumegroupID, configurationID, instancegroupID as the keys.
+
+ b. Depending on whether a la carte or macro , different flows are called. getGBBMacro is called in here.
+
+ c. In getGBBMacro , a valid customer is got with service subscription.(getCustomerAndServiceSubscription)
+
+ First a customer is got by get request on https://aai.onap:8443/aai/v19/business/customers/customer/{globalSubscriberId}
+
+ After that ServiceSubscription is got by doing a get request
+ https://aai.onap:8443/aai/v19/business/customers/customer/{globalSubscriberId}/service-subscriptions/service-subscription/service
+
+ If, the above request doesnt give any , then ServiceSubscription is fetched by first creating uri keys
+ https://aai.onap:8443/aai/v19/nodes/service-instances/service-instance/{resourceId}?format=pathed.
+ Then ServiceSubscription is got from the globalSubscriberId and the uri keys
+
+'Note': a valid customer and a corresponding ServiceSubscription must be present in the aai, for setting up the customer to gbuildingblock
+
+ d. project and owningEntity is updated from the input
+
+ e. service is got from the catalog db either by ModelVersionId or by ModelVersion and ModelInvariantId.
+
+ f. ServiceInstance is created from the above parameters, and this ServiceInstance is used in the preparation of general building block.
+
+ g. Depending on whether the current executing block name contains either of the network, or configuration, or network collection. A new instance of the corresponding type is created and is updated to the general building block (Happens in getGBBMacroNoUserParamsCreate)
+
+ h. This general building block is set to the gBuildingBlockExecution and gBBInput parameter of execution.
+
+
+# 2. StatusPolicy - implemented in validateOrchestrationStatus in OrchestrationStatusValidator. Input being gBuildingBlockExecution
+ a. orchestrationStatus is obtained after checking the resource type. We had updated the orchestrationStatus in the above step when a new service instance was created.
+ b. OrchestrationStatusStateTransitionDirective is got by doing a get call to the catlog db with the url as findOneByResourceTypeAndOrchestrationStatusAndTargetAction
+http://so-catalog-db-adapter.onap:8082/orchestrationStatusStateTransitionDirective/search/findOneByResourceTypeAndOrchestrationStatusAndTargetAction?resourceType=SERVICE&orchestrationStatus=PRECREATED&targetAction=ASSIGN
+ c. orchestrationStatusValidationResult parameter is set to execution variable from the OrchestrationStatusStateTransitionDirective.getFlowDirective() "flowDirective" : "CONTINUE"
+
+# 3. Prevalidate the gBuildingBlockExecution
+
+# 4. BB To Execute: Depending on which building block is to be executed, that particular bpmn is called .In this case, AssignServiceInstanceBB is called
+
+-------------------------------------------------------------------------------------------------------------------------
+
+Hits AssignServiceInstanceBB.bpmn
+---------------------------------
+
+.. image:: ../images/AssignServiceInstanceBB.png
+
+# 1. AAI create service subscription - implemented in createServiceSubscription of createAAITasks
+This method is used for creating and subscribing the service in A&AI
+
+ a. Customer is got from the general building block that was updated above
+
+ b. Here a serviceSubscriptionURI is formed by taking in the globalSubscriberId and the serviceType
+
+ c. If a service subscription for the particular customer doesnt exist in AAI, then a new subscription is created by taking in the serviceSubscriptionURI
+
+GET performed on uri:https://aai.onap:8443/aai/v19/business/customers/customer/slice1/service-subscriptions/service-subscription/service?
+{"results":[{"service-subscription":1}]}
+
+# 2. AAI create service instance - implemented in createServiceInstance of createAAITasks
+This method is used for creating the service instance in A&AI
+
+ a. Customer is got from the general building block that was updated above
+
+ b. A serviceInstanceURI is formed by taking in the globalSubscriberId, the serviceType and the service instance id
+
+ c. If the service instance in the particular path doesnt exist in AAI , then a new service instance is created by using the serviceInstanceURI
+
+GET to:https://aai.onap:8443/aai/v19/business/customers/customer/slice1/service-subscriptions/service-subscription/service/service-instances/service-instance/2b955def-e536-40ee-84cb-3f06e3cc6d84?
+response: {"requestError":{"serviceException":{"messageId":"SVC3001","text":"Resource not found for %1 using id %2 (msg=%3) (ec=%4)","variables":["GET","business/customers/customer/slice1/service-subscriptions/service-subscription/service/service-instances/service-instance/2b955def-e536-40ee-84cb-3f06e3cc6d84","Node Not Found:No Node of type service-instance found at: business/customers/customer/slice1/service-subscriptions/service-subscription/service/service-instances/service-instance/2b955def-e536-40ee-84cb-3f06e3cc6d84","ERR.5.4.6114"]}}}
+
+Sending HTTP PUT to:https://aai.onap:8443/aai/v19/business/customers/customer/slice1/service-subscriptions/service-subscription/service/service-instances/service-instance/2b955def-e536-40ee-84cb-3f06e3cc6d84
+with req body : {"service-instance-id":"2b955def-e536-40ee-84cb-3f06e3cc6d84","service-instance-name":"DEMO_123456","model-invariant-id":"944862ae-bb65-4429-8330-a6c9170d6672","model-version-id":"d88da85c-d9e8-4f73-b837-3a72a431622b","orchestration-status":"Inventoried"}
+
+# 3. AAI create project - implemented in createProject of createAAITasks
+This method is used for creation of the project A&AI. Here too it checks whether a project with a {projectName} exist in AAI . If not it creates one, and connects it to the service instance identified by the serviceInstanceId
+Sending HTTP PUT to:https://aai.onap:8443/aai/v19/business/projects/project/name%20of%20proj/relationship-list/relationship
+with req body: {"related-link":"/business/customers/customer/slice1/service-subscriptions/service-subscription/service/service-instances/service-instance/2b955def-e536-40ee-84cb-3f06e3cc6d84"}
+
+# 4. AAI create owning entity - implemented in createOwningEntity of createAAITasks
+
+ a. OwningEntityId and OwningEntityName is extracted from the OwningEntity given in the input json
+
+ b. If both of them are null, then an exception is raised.
+
+ c. If only OwningEntityId is null, then whether the OwningEntityName is present in AAI is checked. If present then OwningEntityId is set by quering the OwningEntity from AAI. And then connect it to the service instance. If not present in the aai then a random id is generated and assigned to OwningEntityId. Then Owning entity is first created and then connected to the service instance
+
+ d. Depending on whether the owning entity is already present or not, either createOwningEntityandConnectServiceInstance is called, or connectOwningEntityandServiceInstanceis called.
+
+Sending HTTP PUT to:https://aai.onap:8443/aai/v19/business/owning-entities/owning-entity/owningEntityIdof%20owningEntity/relationship-list/relationship
+req body: {"related-link":"/business/customers/customer/slice1/service-subscriptions/service-subscription/service/service-instances/service-instance/2b955def-e536-40ee-84cb-3f06e3cc6d84"}
+
+# 5. SDNC Create Assign Request - implemented in assignServiceInstance of SDNCAssignTasks
+
+ a. Here first the requestContext, serviceInstance, customer are obtained from the general building block
+
+ b. Then a payload for the assignServiceInstance of the sdnc is formed by passing in the above parameters to the assignServiceInstance in sdncSIResources.
+
+ c. A new sdnc request is formed with the above thing as payload
+
+ d. This sdnc request is assigned to the SDNCRequest parameter of the execution variable
+
+.. code-block:: bash
+
+ {"input":{
+ "request-information" : {
+ "request-action" : "CreateServiceInstance",
+ "source" : "MSO",
+ "request-id" : "139636cd-4b69-4c3a-9e67-fed2c283baee"
+
+ },
+ "sdnc-request-header" : {
+
+ "svc-request-id" : "9bfe8cb0-bb8b-4dca-949d-2f2b51011b54",
+ "svc-action" : "assign"
+
+ },
+ "service-information" : {
+
+ "onap-model-information" : {
+ "model-name" : "GR-API-DEFAULT",
+ "model-version" : "1.0",
+ "model-uuid" : "d88da85c-d9e8-4f73-b837-3a72a431622b",
+ "model-invariant-uuid" : "944862ae-bb65-4429-8330-a6c9170d6672"
+
+ },
+ "subscription-service-type" : "service",
+ "service-id" : "2b955def-e536-40ee-84cb-3f06e3cc6d84",
+ "global-customer-id" : {global_customerid},
+ "service-instance-id" : "2b955def-e536-40ee-84cb-3f06e3cc6d84"
+
+ },
+ "service-request-input" : {
+
+ "service-input-parameters" : {
+ "param" : [ {
+ "name" : "some name",
+ "value" : "some value"
+
+ } ]
+
+ },
+ "service-instance-name" : {instance_name}
+ }
+ }}
+
+# 6. It calls another bpmn file - SDNCHandler.bpmn
+
+ a. Setup callback variables - Here mainly the correlator variable and the sdnc timeout variable is set
+
+ b. callSDNC - Here post call to sdnc client is done with the above prepared payload. And then isSDNCCompleted is set to the execution variable
+
+Both the above tasks are implemented in SDNCRequestTasks.
+http://sdnc-oam.onap:8282/restconf/operations/GENERIC-RESOURCE-API:service-topology-operation/
+
+# 7. AAI Update (svc instance)- implemented in th updateOrchestrationStatusAssignedService in AAIUpdateTasks
+ BPMN access method to update the status of Service to Assigned in AAI.
+ Here serviceInstance is obtained , then its orchestration status is changed to assigned and is updated in the AAI
+
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+Reaches back to ExecuteBuildingBlock.bpmn
+
+# 5. Post validate the generic building block
+
+# 6. Set Handling Code To Success - implemented in setHandlingStatusSuccess in ExecuteBuildingBlockRainyDay
+handling code is set to success for the execution variable
+
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+Reaches back to WorkflowActionBB.bpmn
+
+# 7. postProcessingExecuteBB
+If the building block excuted is ActivateVfModuleBB, then a postProcessingExecuteBBActivateVfModule needs to be executed
+
+Then again it is looped back to selectBB through a checkRetryStatus block.
+This block comes into play only if the handlingCode is retry, and the retry count is lesser than the maximum allowed no of retries, then the current sequence is again reduced by 1 , so that the same block is executed again.Request in the requestdb is updated with a setRetryStatusMessage, keeping an eye on the no of retries executed.
+
+
+And in this particular example ActivateServiceInstanceBB.bpmn is called next in the sequence.
+Here updateOrchestrationStatusActiveService is called, which is BPMN access method to update status of Service to Active in AAI. Here orchestrationStatus is set to active for the particular service instance and is updated in the AAI .
+
+# 8. updateRequestStatusToComplete is called if the "complete" flag is true
+ a. Here first the request is got from the requestDbclient http://request-db-adapter:8083/infraActiveRequests/requestid
+
+ b. Then a status message is formed as "Macro-" + resourceName + "-" + action + " request was executed correctly."
+
+ This status message is updated in the request as well as is set to finalStatusMessage of the execution variable
+
+ c. Other request parameters are updated
+
+ request.setEndTime(endTime);
+
+ request.setFlowStatus("Successfully completed all Building Blocks");
+
+ request.setProgress(Long.valueOf(100));
+
+ request.setRequestStatus("COMPLETE");
+
+ request.setLastModifiedBy("CamundaBPMN");
+
+ d. This new request parameters are updated by a put request to the requestDbclient
+
+
+
+
+Flow ends
+----------
+
+If there are other resources present along with the service : Eg :- Volumegroup.( These BBs wil be specifically called )
+
+1) AssignVolumeGroupBB :
+
+ a. genericvnfid and volumegroupid is obtained from the execution block.
+ b. volumegroup orchestrationstatus is set to assigned
+ c. a volume group of the above details is created in aai
+ d. connect volumegroup to this genericvnf
+ e. cloud configuration is got, and then the volumegroup is linked to tenant
+
+
+
+2) createVolumeGroupBB :
+
+ a. get the vf details according to Vf module id from sdnc.
+ b. vfmodulequeriedfromsdnc is set to the executionvariable.
+ c. createVolumeGroupRequest is formed with getCloudRegion, serviceinstance, genericVnf, volumegroup, sdncVfModuleQueryResponse.
+ d. calls vnfadapter, which in turn calls openstackadaptertask.
+ e. update heattask in the volumegroup and which is ammended in the aai.
+ f. orchestrationstatus for the volume group is set to created.
+
+
+3) ActivateVolumeGroupBB :
+
+ orchestrationstatus for the volume group is ammended to active.
+
diff --git a/docs/images/AssignServiceInstanceBB.png b/docs/images/AssignServiceInstanceBB.png Binary files differnew file mode 100644 index 0000000000..d1dbb038aa --- /dev/null +++ b/docs/images/AssignServiceInstanceBB.png diff --git a/docs/images/ExecuteBuildingBlock.png b/docs/images/ExecuteBuildingBlock.png Binary files differnew file mode 100644 index 0000000000..7c8256ca3f --- /dev/null +++ b/docs/images/ExecuteBuildingBlock.png diff --git a/docs/images/flowchart.png b/docs/images/flowchart.png Binary files differnew file mode 100644 index 0000000000..cbb9aef1f2 --- /dev/null +++ b/docs/images/flowchart.png diff --git a/docs/images/workflow.png b/docs/images/workflow.png Binary files differnew file mode 100644 index 0000000000..a62a4e6496 --- /dev/null +++ b/docs/images/workflow.png diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java index e7b96b16a9..3f05c79dad 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java @@ -23,6 +23,11 @@ package org.onap.so.apihandlerinfra; import java.sql.Timestamp; import java.util.HashMap; import java.util.UUID; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.function.Function; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -54,6 +59,7 @@ import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.Allocate3gppServ import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.DeAllocate3gppService; import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.Modify3gppService; import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.QuerySubnetCapability; +import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.SubnetTypes; import org.onap.so.constants.Status; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.ServiceRecipe; @@ -70,6 +76,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.core.type.TypeReference; import io.swagger.v3.oas.annotations.OpenAPIDefinition; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.info.Info; @@ -238,8 +245,8 @@ public class Onap3gppServiceInstances { public Response getSliceSubnetCapabilities(QuerySubnetCapability request, @PathParam("version") String version) throws ApiException { logger.debug("Request received {}", request); - String subnetType = null; - return getSubnetCapabilities(subnetType, version); + List<SubnetTypes> subnetTypes = request.getSubnetTypes(); + return getSubnetCapabilities(subnetTypes, version); } /** @@ -577,8 +584,28 @@ public class Onap3gppServiceInstances { } // To be implemented for fetching Subnet capabilities - private Response getSubnetCapabilities(String subnetType, String version) throws ApiException { - return null; + private Response getSubnetCapabilities(List<SubnetTypes> subnetTypes, String version) throws ApiException { + ObjectMapper oMapper = new ObjectMapper(); + InputStream inputStream = TypeReference.class.getResourceAsStream("/subnetCapability.json"); + Map<String, Object> subnetCapability = new HashMap<>(); + try { + subnetCapability = oMapper.readValue(inputStream, Map.class); + } catch (Exception e) { + logger.debug("Exception while reading subnet capability value from json", e); + } + Map<String, Object> responseMap = new HashMap<>(); + for (SubnetTypes value : subnetTypes) { + if (subnetCapability.containsKey(value.toString())) { + responseMap.put(value.toString(), subnetCapability.get(value.toString())); + } + } + String response = null; + try { + response = oMapper.writeValueAsString(responseMap); + } catch (JsonProcessingException e) { + logger.debug("Exception while converting subnet capability object to String {}", e); + } + return builder.buildResponse(HttpStatus.SC_OK, null, response, version); } /** diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/QuerySubnetCapability.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/QuerySubnetCapability.java index 2e479e1ecb..c66b053609 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/QuerySubnetCapability.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/QuerySubnetCapability.java @@ -22,26 +22,26 @@ package org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans; import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Model class for slice subnet capability query */ public class QuerySubnetCapability { - private SubnetTypes subnetType; + @JsonProperty("subnetTypes") + private List<SubnetTypes> subnetTypes; - public SubnetTypes getSubnetType() { - return subnetType; + public List<SubnetTypes> getSubnetTypes() { + return subnetTypes; } - public void setSubnetType(SubnetTypes subnetType) { - this.subnetType = subnetType; + public void setSubnetTypes(List<SubnetTypes> subnetTypes) { + this.subnetTypes = subnetTypes; } @Override public String toString() { - return "QuerySubnetCapability [subnetType=" + subnetType + "]"; + return "QuerySubnetCapability [subnetType=" + subnetTypes + "]"; } - } - diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/subnetCapability.json b/mso-api-handlers/mso-api-handler-infra/src/main/resources/subnetCapability.json new file mode 100644 index 0000000000..0d5acef64a --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/subnetCapability.json @@ -0,0 +1,25 @@ +{ + "AN": { + "latency": "5", + "maxNumberofUEs": "100", + "maxThroughput": "150", + "terminalDensity": "50" + }, + "CN": { + "latency": "10", + "maxThroughput": "50", + "maxNumberofConns": "100" + }, + "TN_FH": { + "latency": "10", + "maxThroughput": "100" + }, + "TN_MH": { + "latency": "5", + "maxThroughput": "50" + }, + "TN_BH": { + "latency": "10", + "maxThroughput": "100" + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstancesTest.java index 503af1bdcb..c3c92be013 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstancesTest.java @@ -49,6 +49,9 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.util.UriComponentsBuilder; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.so.apihandlerinfra.exceptions.ApiException; +import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.QuerySubnetCapability; +import org.springframework.beans.factory.annotation.Autowired; public class Onap3gppServiceInstancesTest extends BaseTest { @@ -56,6 +59,9 @@ public class Onap3gppServiceInstancesTest extends BaseTest { private final ObjectMapper mapper = new ObjectMapper(); + @Autowired + private Onap3gppServiceInstances objUnderTest; + @Before public void init() throws JsonProcessingException { @@ -176,6 +182,17 @@ public class Onap3gppServiceInstancesTest extends BaseTest { assertEquals(expectedResponse, actualResponse); } + @Test + public void getSliceSubnetCapabilitiesTest() throws IOException, ApiException { + String request = "{\"subnetTypes\":[\"AN\"]}"; + QuerySubnetCapability subnetCapabilityRequest = mapper.readValue(request, QuerySubnetCapability.class); + String expectedResponse = + "{\"AN\":{\"latency\":\"5\",\"maxNumberofUEs\":\"100\",\"maxThroughput\":\"150\",\"terminalDensity\":\"50\"}}"; + Response response = objUnderTest.getSliceSubnetCapabilities(subnetCapabilityRequest, "v1"); + String actualResponse = (String) response.getEntity(); + assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); + assertEquals(expectedResponse, actualResponse); + } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResource.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResource.java index 19e875f8bc..3827c0e19f 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResource.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResource.java @@ -38,6 +38,8 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; import uk.co.blackpepper.bowman.annotation.LinkedResource; import uk.co.blackpepper.bowman.annotation.RemoteResource; @@ -76,6 +78,7 @@ public class AllottedResource implements Serializable { private Date created; @OneToMany(cascade = CascadeType.ALL, mappedBy = "allottedResource") + @NotFound(action = NotFoundAction.IGNORE) private Set<AllottedResourceCustomization> allotedResourceCustomization; @Override |