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_"
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 = """{
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")
}
import org.slf4j.LoggerFactory
import static org.apache.commons.lang3.StringUtils.isBlank
+import static org.apache.commons.lang3.StringUtils.isNotBlank
class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor {
}"""
execution.setVariable("serviceModelInfo", serviceModelInfo)
- tnNssmfUtils.setEnableSdncConfig(execution)
+ if (isBlank(execution.getVariable("enableSdnc"))) {
+ tnNssmfUtils.setEnableSdncConfig(execution)
+ }
logger.trace("Exit preProcessRequest")
}
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")
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()
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
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_"
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 = """{
}"""
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")
}
} else {
execution.setVariable("nsiInfo", nsiInfo)
}
+
+ if (isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution, additionalPropJsonStr,
+ "enableSdnc", "enableSdnc"))) {
+ tnNssmfUtils.setEnableSdncConfig(execution)
+ }
} catch (BpmnError e) {
throw e
} catch (Exception ex) {
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) {
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
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
<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" />