diff options
Diffstat (limited to 'bpmn')
7 files changed, 126 insertions, 18 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy index ff7b0a3b6d..515990ac1a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy @@ -37,6 +37,9 @@ import org.onap.so.db.request.beans.ResourceOperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory +import static org.apache.commons.lang3.StringUtils.isBlank +import static org.apache.commons.lang3.StringUtils.isEmpty + public class DoActivateTnNssi extends AbstractServiceTaskProcessor { String Prefix = "TNACT_" @@ -63,7 +66,9 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor { String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("modelUuid") - //here modelVersion is not set, we use modelUuid to decompose the service. + if (isEmpty(modelUuid)) { + modelUuid = tnNssmfUtils.getModelUuidFromServiceInstance(execution.getVariable("serviceInstanceID")) + } def isDebugLogEnabled = true execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) String serviceModelInfo = """{ @@ -83,7 +88,13 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor { String actionType = operationType.equals("activateInstance") ? "activate" : "deactivate" execution.setVariable("actionType", actionType) - tnNssmfUtils.setEnableSdncConfig(execution) + String additionalPropJsonStr = execution.getVariable("sliceParams") + if (isBlank(additionalPropJsonStr) || + isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution, + additionalPropJsonStr, + "enableSdnc", "enableSdnc"))) { + tnNssmfUtils.setEnableSdncConfig(execution) + } logger.debug("Finish preProcessRequest") } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy index 04f07b66d4..c06e313c4c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy @@ -35,6 +35,7 @@ import org.slf4j.Logger import org.slf4j.LoggerFactory import static org.apache.commons.lang3.StringUtils.isBlank +import static org.apache.commons.lang3.StringUtils.isNotBlank class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { @@ -63,7 +64,9 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { }""" execution.setVariable("serviceModelInfo", serviceModelInfo) - tnNssmfUtils.setEnableSdncConfig(execution) + if (isBlank(execution.getVariable("enableSdnc"))) { + tnNssmfUtils.setEnableSdncConfig(execution) + } logger.trace("Exit preProcessRequest") } @@ -110,6 +113,12 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { String ssInstanceId = execution.getVariable("sliceServiceInstanceId") String sliceProfileStr = execution.getVariable("sliceProfile") try { + if (sliceProfileStr == null || sliceProfileStr.isEmpty()) { + String msg = "ERROR: createServiceInstance: sliceProfile is null" + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + org.onap.aai.domain.yang.ServiceInstance ss = new org.onap.aai.domain.yang.ServiceInstance() ss.setServiceInstanceId(ssInstanceId) String sliceInstanceName = execution.getVariable("sliceServiceInstanceName") @@ -125,12 +134,18 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { String modelUuid = execution.getVariable("modelUuid") ss.setModelInvariantId(modelInvariantUuid) ss.setModelVersionId(modelUuid) - String serviceInstanceLocationid = tnNssmfUtils.getFirstPlmnIdFromSliceProfile(sliceProfileStr) - ss.setServiceInstanceLocationId(serviceInstanceLocationid) + String serviceInstanceLocationId = tnNssmfUtils.getFirstPlmnIdFromSliceProfile(sliceProfileStr) + ss.setServiceInstanceLocationId(serviceInstanceLocationId) String snssai = tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr) //ss.setEnvironmentContext(snssai) ss.setEnvironmentContext("tn") ss.setServiceRole(serviceRole) + + String domainTypeStr = jsonUtil.getJsonValue(sliceProfileStr, "domainType") + if (isNotBlank(domainTypeStr)) { + ss.setWorkloadContext(domainTypeStr) + } + AAIResourcesClient client = getAAIClient() AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() @@ -280,25 +295,30 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { List<String> linkStrList = jsonUtil.StringArrayToList(linkArrayStr) for (String linkStr : linkStrList) { - String logicalLinkId = UUID.randomUUID().toString() + String linkName = jsonUtil.getJsonValue(linkStr, "name") + if (isBlank(linkName)) { + linkName = "tn-nssmf-" + UUID.randomUUID().toString() + } + logger.debug("createLogicalLinksForAllocatedResource: linkName=" + linkName) + String epA = jsonUtil.getJsonValue(linkStr, "transportEndpointA") String epB = jsonUtil.getJsonValue(linkStr, "transportEndpointB") String modelInvariantId = execution.getVariable("modelInvariantUuid") String modelVersionId = execution.getVariable("modelUuid") org.onap.aai.domain.yang.LogicalLink resource = new org.onap.aai.domain.yang.LogicalLink() - resource.setLinkId(logicalLinkId) - resource.setLinkName(epA) + resource.setLinkName(linkName) + resource.setLinkId(epA) resource.setLinkName2(epB) resource.setLinkType("TsciConnectionLink") resource.setInMaint(false) //epA is link-name AAIResourceUri logicalLinkUri = - AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(epA)) + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(linkName)) getAAIClient().create(logicalLinkUri, resource) - tnNssmfUtils.attachLogicalLinkToAllottedResource(execution, AAI_VERSION, allottedResourceUri, epA); + tnNssmfUtils.attachLogicalLinkToAllottedResource(execution, AAI_VERSION, allottedResourceUri, linkName); } } catch (BpmnError e) { throw e diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy index a715e7799d..b09161d5cd 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy @@ -38,6 +38,9 @@ import org.onap.so.db.request.beans.ResourceOperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory +import static org.apache.commons.lang3.StringUtils.isBlank +import static org.apache.commons.lang3.StringUtils.isEmpty + class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { String Prefix = "TNDEALLOC_" @@ -68,10 +71,11 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { String sliceServiceInstanceName = execution.getVariable("servicename") execution.setVariable("sliceServiceInstanceName", sliceServiceInstanceName) - String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("modelUuid") - //here modelVersion is not set, we use modelUuid to decompose the service. + if (isEmpty(modelUuid)) { + modelUuid = tnNssmfUtils.getModelUuidFromServiceInstance(execution.getVariable("serviceInstanceID")) + } def isDebugLogEnabled = true execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) String serviceModelInfo = """{ @@ -81,7 +85,13 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { }""" execution.setVariable("serviceModelInfo", serviceModelInfo) - tnNssmfUtils.setEnableSdncConfig(execution) + String additionalPropJsonStr = execution.getVariable("sliceParams") + if (isBlank(additionalPropJsonStr) || + isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution, + additionalPropJsonStr, + "enableSdnc", "enableSdnc"))) { + tnNssmfUtils.setEnableSdncConfig(execution) + } logger.debug("Finish preProcessRequest") } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy index 4ff15a58c5..45af88d253 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy @@ -120,6 +120,11 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { } else { execution.setVariable("nsiInfo", nsiInfo) } + + if (isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution, additionalPropJsonStr, + "enableSdnc", "enableSdnc"))) { + tnNssmfUtils.setEnableSdncConfig(execution) + } } catch (BpmnError e) { throw e } catch (Exception ex) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy index deeec94b74..019e836514 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy @@ -116,10 +116,10 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { execution.setVariable("nsiInfo", nsiInfoStr) } - //nsiId is passed in from caller bpmn - //String nsiIdStr = jsonUtil.getJsonValue(nsiInfo, "nsiId") - //execution.setVariable("nsiId", nsiIdStr) - + if (isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution, additionalPropJsonStr, + "enableSdnc", "enableSdnc"))) { + tnNssmfUtils.setEnableSdncConfig(execution) + } } catch (BpmnError e) { throw e } catch (Exception ex) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy index 009b0a1941..4877a236f3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy @@ -23,8 +23,11 @@ package org.onap.so.bpmn.infrastructure.scripts import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.ServiceInstance import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils @@ -368,4 +371,62 @@ class TnNssmfUtils { execution.setVariable("enableSdnc", enableSdnc) } -} + + String setExecVarFromJsonIfExists(DelegateExecution execution, + String jsonStr, String jsonKey, String varName) { + return setExecVarFromJsonStr(execution, jsonStr, jsonKey, varName, false) + } + + String setExecVarFromJsonStr(DelegateExecution execution, + String jsonStr, String jsonKey, String varName, + boolean exceptionOnErr) { + String msg = "" + String valueStr = jsonUtil.getJsonValue(jsonStr, jsonKey) + if (isBlank(valueStr)) { + if (exceptionOnErr) { + msg = "cannot find " + jsonKey + " in " + jsonStr + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + } else { + execution.setVariable(varName, valueStr) + } + + return valueStr + } + + ServiceInstance getServiceInstanceFromAai(String serviceInstanceId) { + if (isBlank(serviceInstanceId)) { + logger.error("ERROR: getServiceInstanceFromAai: serviceInstanceId is blank") + return null + } + + ServiceInstance nssi = null + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.Types.SERVICE_INSTANCE + .getFragment(serviceInstanceId)) + Optional<ServiceInstance> nssiOpt = client.get(ServiceInstance.class, uri) + + if (nssiOpt.isPresent()) { + nssi = nssiOpt.get() + return nssi + } else { + String msg = String.format("ERROR: getServiceInstanceFromAai: NSSI %s not found in AAI", serviceInstanceId) + logger.error(msg) + } + + return nssi; + } + + String getModelUuidFromServiceInstance(String serviceInstanceId) { + ServiceInstance si = getServiceInstanceFromAai(serviceInstanceId) + if (si == null) { + String msg = String.format("ERROR: getModelUuidFromServiceInstance: getServiceInstanceFromAai() failed. " + + "serviceInstanceId=%s", serviceInstanceId) + logger.error(msg) + return null + } + + return si.modelVersionId() + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn index 124b75cbe8..82efc97e92 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn @@ -131,6 +131,7 @@ css.prepareOofSelection(execution)</bpmn:script> <camunda:in source="operationId" target="operationId" /> <camunda:in source="sliceProfile" target="sliceProfile" /> <camunda:in source="transportSliceNetworks" target="transportSliceNetworks" /> + <camunda:in source="enableSdnc" target="enableSdnc" /> <camunda:in source="nsiInfo" target="nsiInfo" /> <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:out source="rollbackData" target="rollbackData" /> |