SO changes for CCVPN enhancement in Jakarta 72/128072/1
authorhyu2010 <hyu2010b@gmail.com>
Thu, 24 Mar 2022 13:35:24 +0000 (09:35 -0400)
committerhyu2010 <hyu2010b@gmail.com>
Thu, 24 Mar 2022 13:40:43 +0000 (09:40 -0400)
This update contains for the fixes for the following JIRA:

SO-3913: CCVPN enhancement for cloud leased line protection
         and bandwidth modification

Issue-ID: SO-3913
Change-Id: I8d82ef0f939efb5a94045a6d1117c692667eb554
Signed-off-by: hyu2010 <hyu2010b@gmail.com>
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineCreate.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineModify.groovy

index 2e0f3cf..4681713 100644 (file)
@@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory
 import org.springframework.web.util.UriUtils
 
 import static org.apache.commons.lang3.StringUtils.isBlank
+import static org.apache.commons.lang3.StringUtils.isNotBlank
 
 class DoCloudLeasedLineCreate extends AbstractServiceTaskProcessor {
 
@@ -333,6 +334,7 @@ class DoCloudLeasedLineCreate extends AbstractServiceTaskProcessor {
 
                 String epA = jsonUtil.getJsonValue(linkStr, "transportEndpointA")
                 String epB = jsonUtil.getJsonValue(linkStr, "transportEndpointB")
+                String epBProtect = jsonUtil.getJsonValue(linkStr, "transportEndpointBProtection")
                 String modelInvariantId = execution.getVariable("modelInvariantUuid")
                 String modelVersionId = execution.getVariable("modelUuid")
 
@@ -340,6 +342,9 @@ class DoCloudLeasedLineCreate extends AbstractServiceTaskProcessor {
                 resource.setLinkId(linkId)
                 resource.setLinkName(epA)
                 resource.setLinkName2(epB)
+                if (isNotBlank(epBProtect)) {
+                    resource.setSegmentId(epBProtect)
+                }
                 resource.setLinkType("TsciConnectionLink")
                 resource.setInMaint(false)
 
index 5c98778..bfd5ac8 100644 (file)
@@ -109,6 +109,14 @@ public class DoCloudLeasedLineModify extends AbstractServiceTaskProcessor {
                     "transportNetworks", "transportNetworks", true)
             logger.debug("transportNetworks: " + execution.getVariable("transportNetworks"))
 
+            serviceIntentUtils.setExecVarFromJsonIfExists(execution, additionalPropJsonStr,
+                    "modifyAction", "modifyAction");
+            if (isNotBlank(execution.getVariable("modifyAction"))) {
+                logger.debug("modifyAction: " + execution.getVariable("modifyAction"))
+            } else {
+                logger.debug("modifyAction is not set")
+            }
+
             if (isBlank(serviceIntentUtils.setExecVarFromJsonIfExists(execution, additionalPropJsonStr,
                     "enableSdnc", "enableSdnc"))) {
                 serviceIntentUtils.setEnableSdncConfig(execution)
@@ -266,12 +274,16 @@ public class DoCloudLeasedLineModify extends AbstractServiceTaskProcessor {
 
     void updateTsciNetworks(DelegateExecution execution) {
         try {
+            if (modifyBandwidthGlobal(execution)) {
+                String netStr = jsonUtil.StringArrayToList(execution.getVariable("transportNetworks")).get(0)
+                int maxBw = getMaxBwFromNetworkJsonStr(execution, netStr)
+                updateNetworkPolicyGlobal(execution, maxBw)
+                return
+            }
             List<String> networkStrList = jsonUtil.StringArrayToList(execution.getVariable("transportNetworks"))
             for (String networkStr : networkStrList) {
-                updateLogicalLinksInNetwork(execution, networkStr)
-                updateNetworkPolicy(execution, networkStr)
+                updateTsciNetwork(execution, networkStr)
             }
-
         } catch (BpmnError e) {
             throw e
         } catch (Exception ex) {
@@ -280,6 +292,20 @@ public class DoCloudLeasedLineModify extends AbstractServiceTaskProcessor {
         }
     }
 
+    boolean modifyBandwidthGlobal(DelegateExecution execution) {
+        String modifyAction = execution.getVariable("modifyAction")
+        if (isNotBlank(modifyAction) && modifyAction.equals("bandwidth")) {
+            return true
+        }
+
+        return false
+    }
+
+    void updateTsciNetwork(DelegateExecution execution, String networkStr) {
+        updateLogicalLinksInNetwork(execution, networkStr)
+        updateNetworkPolicy(execution, networkStr)
+    }
+
     int getMaxBwFromNetworkJsonStr(DelegateExecution execution, String networkJsonStr) {
         int maxBw = 0
         try {
@@ -327,6 +353,28 @@ public class DoCloudLeasedLineModify extends AbstractServiceTaskProcessor {
         }
     }
 
+    void updateNetworkPolicyGlobal(DelegateExecution execution, int maxBw) {
+        try {
+            List<String> arIdList = execution.getVariable("arIdList")
+            for (String arId : arIdList) {
+                Map<String, String> policyMap = execution.getVariable("arPolicyMap")
+                String policyId = policyMap.get(arId)
+                if (isBlank(policyId)) {
+                    String msg = String.format("ERROR: updateNetworkPolicy: policyId not found. arId=%s", arId)
+                    logger.error(msg)
+                    exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+                }
+                updatePolicyMaxBandwidthInAAI(execution, policyId, maxBw)
+            }
+        } catch (BpmnError e) {
+            throw e
+        } catch (Exception ex) {
+            String msg = String.format("ERROR: updateNetworkPolicy: exception: %s", ex.getMessage())
+            logger.error(msg)
+            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
+        }
+    }
+
     void updateNetworkPolicy(DelegateExecution execution, String networkJsonStr) {
         try {
             int maxBw = getMaxBwFromNetworkJsonStr(execution, networkJsonStr)