Transport Slicing Fixes 80/117380/2
authorhyu2010 <hyu2010b@gmail.com>
Tue, 2 Feb 2021 21:35:26 +0000 (16:35 -0500)
committerhyu2010 <hyu2010b@gmail.com>
Tue, 23 Feb 2021 15:20:20 +0000 (10:20 -0500)
This update contains for the fixes for the following JIRAs:

SO-3512: update logical-link name and logical-link id in
         TN NSSI
SO-3544: Transport Slicing problems found in RAN NSSMF and
         TN NSSMF integration

Issue-ID: SO-3512
Issue-ID: SO-3544
Signed-off-by: hyu2010 <hyu2010b@gmail.com>
Change-Id: I075bf76da635365260bfc52b0fe13ac3cb69c3c7
Signed-off-by: hyu2010 <hyu2010b@gmail.com>
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy
bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn

index ff7b0a3..515990a 100644 (file)
@@ -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")
     }
index 04f07b6..c06e313 100644 (file)
@@ -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
index a715e77..b09161d 100644 (file)
@@ -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")
     }
index 4ff15a5..45af88d 100644 (file)
@@ -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) {
index deeec94..019e836 100644 (file)
@@ -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) {
index 009b0a1..4877a23 100644 (file)
@@ -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
index 124b75c..82efc97 100644 (file)
@@ -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" />