Refactor PCE network analyzer PceOtnNode step 4 22/99622/2
authorguillaume.lambert <guillaume.lambert@orange.com>
Mon, 14 Feb 2022 09:23:32 +0000 (10:23 +0100)
committerChristophe Betoule <christophe.betoule@orange.com>
Thu, 17 Feb 2022 08:31:26 +0000 (09:31 +0100)
SERVICE_TYPE_100GE_T should not occur in PceOtnNode.
- remove it from supported types
- refactor initXndrTps() and isAzOrIntermediateAvl() accordingly

JIRA: TRNSPRTPCE-572
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: Iedfede886aa6fb9f6b122a355755156ec5de0b8c

pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOtnNode.java

index b1ce930e7f8cf1609bc53d6e95f7d174d2f768f3..d31c51ff95a72201d1346f37f150bdc1b2e50762 100644 (file)
@@ -65,7 +65,6 @@ public class PceOtnNode implements PceNode {
     private static final Map<String, Class<? extends SupportedIfCapability>> SERVICE_TYPE_ETH_CLASS_MAP = Map.of(
         StringConstants.SERVICE_TYPE_1GE, If1GEODU0.class,
         StringConstants.SERVICE_TYPE_10GE, If10GEODU2e.class,
-        StringConstants.SERVICE_TYPE_100GE_T, If100GEODU4.class,
         StringConstants.SERVICE_TYPE_100GE_M, If100GEODU4.class,
         StringConstants.SERVICE_TYPE_100GE_S, If100GEODU4.class);
     private static final Map<String, Integer> SERVICE_TYPE_ETH_TS_NB_MAP = Map.of(
@@ -182,7 +181,6 @@ public class PceOtnNode implements PceNode {
                                 node.getNodeId().getValue());
                             continue;
                         }
-                    // TODO what about SERVICE_TYPE_100GE_T ?
                     } else {
                         LOG.error("TP {} of {} does not allow any termination creation",
                             tp.getTpId().getValue(), node.getNodeId().getValue());
@@ -193,9 +191,7 @@ public class PceOtnNode implements PceNode {
                     break;
 
                 case XPONDERCLIENT:
-                    if (SERVICE_TYPE_ETH_CLASS_MAP.containsKey(otnServiceType)
-                            && !StringConstants.SERVICE_TYPE_100GE_T.equals(this.otnServiceType)) {
-                            // TODO should we really exclude SERVICE_TYPE_100GE_T ?
+                    if (SERVICE_TYPE_ETH_CLASS_MAP.containsKey(otnServiceType)) {
                         if (tp.augmentation(TerminationPoint1.class) == null) {
                             continue;
                         }
@@ -214,12 +210,28 @@ public class PceOtnNode implements PceNode {
             }
         }
         this.valid = SERVICE_TYPE_ODU_LIST.contains(this.otnServiceType)
-                || SERVICE_TYPE_ETH_TS_NB_MAP.containsKey(this.otnServiceType)
-                    && isAzOrIntermediateAvl(mode, null, availableXpdrClientTps, availableXpdrNWTps)
-                || StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType)
-                    && isAzOrIntermediateAvl(mode, availableXpdrClientTps, availableXpdrClientTps, availableXpdrNWTps);
-                //TODO very similar to isOtnServiceTypeValid method
-                //     check whether the different treatment for SERVICE_TYPE_100GE_S here is appropriate or not
+                || SERVICE_TYPE_ETH_CLASS_MAP.containsKey(this.otnServiceType)
+                    && isAzOrIntermediateAvl(availableXpdrClientTps, availableXpdrNWTps,
+                        StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType)
+                            ? availableXpdrClientTps
+                            : null);
+                //TODO check whether it makes sense to pass twice availableXpdrClientTps tp isAzOrIntermediateAvl
+                //     and to differentiate SERVICE_TYPE_100GE_S case
+                //     better pass otnServiceType -> this should probably be refactored
+    }
+
+    private boolean isAzOrIntermediateAvl(List<TpId> clientTps, List<TpId> netwTps, List<TpId> clientTps0) {
+        switch (modeType) {
+            case "intermediate":
+                return checkSwPool(clientTps0, netwTps, 0, 2);
+
+            case "AZ":
+                return checkSwPool(clientTps, netwTps, 1, 1);
+
+            default:
+                LOG.error("unknown mode type {}", modeType);
+                return false;
+        }
     }
 
     private boolean checkSwPool(List<TpId> clientTps, List<TpId> netwTps, int nbClient, int nbNetw) {
@@ -417,12 +429,6 @@ public class PceOtnNode implements PceNode {
         return valid;
     }
 
-    private boolean isAzOrIntermediateAvl(
-            String mdType, List<TpId> clientTps0, List<TpId> clientTps, List<TpId> netwTps) {
-        return mdType.equals("intermediate") && checkSwPool(clientTps0, netwTps, 0, 2)
-               || mdType.equals("AZ") && checkSwPool(clientTps, netwTps, 1, 1);
-    }
-
     @Override
     public void addOutgoingLink(PceLink outLink) {
         this.outgoingLinks.add(outLink);