Refactor PCE network analyzer PceOtnNode step 2 04/99604/7
authorguillaume.lambert <guillaume.lambert@orange.com>
Sun, 6 Feb 2022 23:13:27 +0000 (00:13 +0100)
committerguillaume.lambert <guillaume.lambert@orange.com>
Mon, 14 Feb 2022 08:24:27 +0000 (09:24 +0100)
second pass to prepare deeper refactoring of PceOtnNode class:
- use Map or List to check and manage ODU and Eth service types
  instead of switch/case and if condition blocks with multiple checks
- rationalize namespaces use and import
- refactor a few checks and indentations
- point with TODO comments places where
  * some missing service types might be managed
  * some checks are similar to existing methods
  * some new methods would help

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

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

index 39c7d57dd73f63f67bd49dfc6d0cb84585ea377f..4cd7c943775c746e4108bee082eaf58a02ad6c2b 100644 (file)
@@ -30,6 +30,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev20032
 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.TerminationPoint1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.networks.network.node.SwitchingPools;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.TerminationPoint1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.networks.network.node.SwitchingPools;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.networks.network.node.termination.point.XpdrTpPortConnectionAttributes;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If100GEODU4;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2e;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If1GEODU0;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If100GEODU4;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2e;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If1GEODU0;
@@ -51,6 +52,28 @@ public class PceOtnNode implements PceNode {
      * For This Class the node passed shall be at the otn-openroadm Layer
      */
 
      * For This Class the node passed shall be at the otn-openroadm Layer
      */
 
+    private static List<String> serviceTypeOduList = List.of(
+        StringConstants.SERVICE_TYPE_ODU4,
+        StringConstants.SERVICE_TYPE_ODUC4,
+        StringConstants.SERVICE_TYPE_ODUC3,
+        StringConstants.SERVICE_TYPE_ODUC2);
+    private static Map<String,
+            Class<? extends org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.SupportedIfCapability>>
+                serviceTypeEthClassMap = 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 Map<String, Integer> serviceTypeEthTsNbMap = Map.of(
+        StringConstants.SERVICE_TYPE_1GE, 1,
+        StringConstants.SERVICE_TYPE_10GE, 10,
+        StringConstants.SERVICE_TYPE_100GE_M, 20);
+    private static Map<String, String> serviceTypeEthOduStringMap = Map.of(
+        StringConstants.SERVICE_TYPE_1GE, "ODU0",
+        StringConstants.SERVICE_TYPE_10GE, "ODU2e",
+        StringConstants.SERVICE_TYPE_100GE_M, "ODU4");
+
     private boolean valid = true;
 
     private final Node node;
     private boolean valid = true;
 
     private final Node node;
@@ -113,20 +136,19 @@ public class PceOtnNode implements PceNode {
         LOG.info("PceOtnNode: initXndrTps for node {}", this.nodeId.getValue());
         this.availableXponderTp.clear();
         this.modeType = mode;
         LOG.info("PceOtnNode: initXndrTps for node {}", this.nodeId.getValue());
         this.availableXponderTp.clear();
         this.modeType = mode;
-        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1 nodeTp
-            = this.node
-                .augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
-                    .Node1.class);
-        List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
-                .node.TerminationPoint> allTps =
-            new ArrayList<>(nodeTp.nonnullTerminationPoint().values());
+        List<TerminationPoint> allTps =
+            new ArrayList<>(
+                this.node.augmentation(
+                    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+                        .Node1.class)
+                .nonnullTerminationPoint()
+                .values());
         this.valid = false;
         if (allTps.isEmpty()) {
             LOG.error("PceOtnNode: initXndrTps: XPONDER TerminationPoint list is empty for node {}", this);
             return;
         }
         this.valid = false;
         if (allTps.isEmpty()) {
             LOG.error("PceOtnNode: initXndrTps: XPONDER TerminationPoint list is empty for node {}", this);
             return;
         }
-        for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
-                .node.TerminationPoint tp : allTps) {
+        for (TerminationPoint tp : allTps) {
             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1 ocnTp1
                 = tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
                         .TerminationPoint1.class);
             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1 ocnTp1
                 = tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
                         .TerminationPoint1.class);
@@ -141,56 +163,36 @@ public class PceOtnNode implements PceNode {
                         continue;
                     }
                     TerminationPoint1 ontTp1 = tp.augmentation(TerminationPoint1.class);
                         continue;
                     }
                     TerminationPoint1 ontTp1 = tp.augmentation(TerminationPoint1.class);
-                    switch (this.otnServiceType) {
-                        case StringConstants.SERVICE_TYPE_100GE_S:
+                    if (serviceTypeOduList.contains(this.otnServiceType)
+                            || StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType)) {
                             // TODO verify the capability of network port to support ODU4 CTP interface creation
                             // TODO verify the capability of network port to support ODU4 CTP interface creation
-                        case StringConstants.SERVICE_TYPE_ODU4:
-                        case StringConstants.SERVICE_TYPE_ODUC2:
-                        case StringConstants.SERVICE_TYPE_ODUC3:
-                        case StringConstants.SERVICE_TYPE_ODUC4:
-                            if (!checkTpForOdtuTermination(ontTp1)) {
-                                LOG.error("TP {} of {} does not allow ODU4 termination creation",
-                                    tp.getTpId().getValue(), node.getNodeId().getValue());
-                                continue;
-                            }
-                            break;
-
-                        case StringConstants.SERVICE_TYPE_10GE:
-                            if (!checkOdtuTTPforLoOduCreation(ontTp1, 10)) {
-                                LOG.error("TP {} of {} does not allow ODU2e termination creation",
-                                    tp.getTpId().getValue(), node.getNodeId().getValue());
-                                continue;
-                            }
-                            break;
-                        case StringConstants.SERVICE_TYPE_100GE_M:
-                            if (!checkOdtuTTPforLoOduCreation(ontTp1, 20)) {
-                                LOG.error("TP {} of {} does not allow ODU4 termination creation",
-                                    tp.getTpId().getValue(), node.getNodeId().getValue());
-                                continue;
-                            }
-                            break;
-                        case StringConstants.SERVICE_TYPE_1GE:
-                            if (!checkOdtuTTPforLoOduCreation(ontTp1, 1)) {
-                                LOG.error("TP {} of {} does not allow ODU0 termination creation",
-                                    tp.getTpId().getValue(), node.getNodeId().getValue());
-                                continue;
-                            }
-                            break;
-
-                        default:
-                            LOG.error("TP {} of {} does not allow any termination creation",
+                        if (!checkTpForOdtuTermination(ontTp1)) {
+                            LOG.error("TP {} of {} does not allow ODU4 termination creation",
                                 tp.getTpId().getValue(), node.getNodeId().getValue());
                             continue;
                                 tp.getTpId().getValue(), node.getNodeId().getValue());
                             continue;
+                        }
+                    } else if (serviceTypeEthTsNbMap.containsKey(this.otnServiceType)) {
+                        if (!checkOdtuTTPforLoOduCreation(ontTp1, serviceTypeEthTsNbMap.get(this.otnServiceType))) {
+                            LOG.error("TP {} of {} does not allow {} termination creation",
+                                tp.getTpId().getValue(),
+                                serviceTypeEthOduStringMap.get(this.otnServiceType),
+                                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());
+                        continue;
                     }
                     LOG.info("TP {} of XPONDER {} is validated", tp.getTpId(), node.getNodeId().getValue());
                     this.availableXpdrNWTps.add(tp.getTpId());
                     break;
 
                 case XPONDERCLIENT:
                     }
                     LOG.info("TP {} of XPONDER {} is validated", tp.getTpId(), node.getNodeId().getValue());
                     this.availableXpdrNWTps.add(tp.getTpId());
                     break;
 
                 case XPONDERCLIENT:
-                    if (StringConstants.SERVICE_TYPE_10GE.equals(this.otnServiceType)
-                            || StringConstants.SERVICE_TYPE_100GE_M.equals(this.otnServiceType)
-                            || StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType)
-                            || StringConstants.SERVICE_TYPE_1GE.equals(this.otnServiceType)) {
+                    if (serviceTypeEthClassMap.containsKey(otnServiceType)
+                            && !StringConstants.SERVICE_TYPE_100GE_T.equals(this.otnServiceType)) {
+                            // TODO should we really exclude SERVICE_TYPE_100GE_T ?
                         if (tp.augmentation(TerminationPoint1.class) == null) {
                             continue;
                         }
                         if (tp.augmentation(TerminationPoint1.class) == null) {
                             continue;
                         }
@@ -208,25 +210,17 @@ public class PceOtnNode implements PceNode {
                     LOG.debug("unsupported ocn TP type {}", ocnTp1.getTpType());
             }
         }
                     LOG.debug("unsupported ocn TP type {}", ocnTp1.getTpType());
             }
         }
-        if (StringConstants.SERVICE_TYPE_ODU4.equals(this.otnServiceType)
-                || StringConstants.SERVICE_TYPE_ODUC4.equals(this.otnServiceType)
-                || StringConstants.SERVICE_TYPE_ODUC3.equals(this.otnServiceType)
-                || StringConstants.SERVICE_TYPE_ODUC2.equals(this.otnServiceType)
-                || ((StringConstants.SERVICE_TYPE_10GE.equals(this.otnServiceType)
-                        || StringConstants.SERVICE_TYPE_100GE_M.equals(this.otnServiceType)
-                        || StringConstants.SERVICE_TYPE_1GE.equals(this.otnServiceType))
+        this.valid = serviceTypeOduList.contains(this.otnServiceType)
+                || (serviceTypeEthTsNbMap.containsKey(this.otnServiceType)
                     && ((mode.equals("AZ") && checkSwPool(availableXpdrClientTps, availableXpdrNWTps, 1, 1))
                      || (mode.equals("intermediate") && checkSwPool(null, availableXpdrNWTps, 0, 2)))
                     )
                 || (StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType)
                     && ((mode.equals("AZ") && checkSwPool(availableXpdrClientTps, availableXpdrNWTps, 1, 1))
                      || (mode.equals("intermediate") && checkSwPool(null, availableXpdrNWTps, 0, 2)))
                     )
                 || (StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType)
-                    && (mode.equals("AZ") && checkSwPool(availableXpdrClientTps, availableXpdrNWTps, 1, 1)))
-                || (StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType)
-                    && (mode.equals("intermediate") && checkSwPool(availableXpdrClientTps, availableXpdrNWTps, 0, 2)))
-        ) {
-            this.valid = true;
-        } else {
-            this.valid = false;
-        }
+                    && ((mode.equals("AZ") && checkSwPool(availableXpdrClientTps, availableXpdrNWTps, 1, 1)))
+                     || (mode.equals("intermediate") && checkSwPool(availableXpdrClientTps, availableXpdrNWTps, 0, 2))
+                    );
+                //TODO checks very similar to isIntermediate and isAz methods - they should be mutualized
+                //     perhaps even with isOtnServiceTypeValid method
     }
 
     private boolean checkSwPool(List<TpId> clientTps, List<TpId> netwTps, int nbClient, int nbNetw) {
     }
 
     private boolean checkSwPool(List<TpId> clientTps, List<TpId> netwTps, int nbClient, int nbNetw) {
@@ -284,47 +278,32 @@ public class PceOtnNode implements PceNode {
     }
 
     private boolean checkOdtuTTPforLoOduCreation(TerminationPoint1 ontTp1, int tsNb) {
     }
 
     private boolean checkOdtuTTPforLoOduCreation(TerminationPoint1 ontTp1, int tsNb) {
-        return ontTp1.getXpdrTpPortConnectionAttributes() != null
-            && ontTp1.getXpdrTpPortConnectionAttributes().getTsPool() != null
-            && ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool() != null
-            && (ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values()
+        XpdrTpPortConnectionAttributes portConAttr = ontTp1.getXpdrTpPortConnectionAttributes();
+        return portConAttr != null
+            && portConAttr.getTsPool() != null
+            && portConAttr.getTsPool().size() >= tsNb
+            && portConAttr.getOdtuTpnPool() != null
+            && (portConAttr.getOdtuTpnPool().values()
                         .stream().findFirst().get().getOdtuType()
                     .equals(ODTU4TsAllocated.class)
                 ||
                         .stream().findFirst().get().getOdtuType()
                     .equals(ODTU4TsAllocated.class)
                 ||
-                ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values()
+                portConAttr.getOdtuTpnPool().values()
                         .stream().findFirst().get().getOdtuType()
                     .equals(ODTUCnTs.class))
                         .stream().findFirst().get().getOdtuType()
                     .equals(ODTUCnTs.class))
-            && !ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values()
+            && !portConAttr.getOdtuTpnPool().values()
                         .stream().findFirst().get().getTpnPool()
                         .stream().findFirst().get().getTpnPool()
-                    .isEmpty()
-            && ontTp1.getXpdrTpPortConnectionAttributes().getTsPool().size() >= tsNb;
+                    .isEmpty();
+            //TODO a dedicated method for OdtuTpnPool first value would probably be welcome
     }
 
     private boolean checkClientTp(TerminationPoint1 ontTp1) {
         for (SupportedInterfaceCapability sic : ontTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability()
                 .values()) {
             LOG.debug("in checkTpForOduTermination - sic = {}", sic.getIfCapType());
     }
 
     private boolean checkClientTp(TerminationPoint1 ontTp1) {
         for (SupportedInterfaceCapability sic : ontTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability()
                 .values()) {
             LOG.debug("in checkTpForOduTermination - sic = {}", sic.getIfCapType());
-            switch (otnServiceType) {
-                case StringConstants.SERVICE_TYPE_1GE:
-                // we could also check the administrative status of the tp
-                    if (sic.getIfCapType().equals(If1GEODU0.class)) {
-                        return true;
-                    }
-                    break;
-                case StringConstants.SERVICE_TYPE_10GE:
-                    if (sic.getIfCapType().equals(If10GEODU2e.class)) {
-                        return true;
-                    }
-                    break;
-                case StringConstants.SERVICE_TYPE_100GE_T:
-                case StringConstants.SERVICE_TYPE_100GE_M:
-                case StringConstants.SERVICE_TYPE_100GE_S:
-                    if (sic.getIfCapType().equals(If100GEODU4.class)) {
-                        return true;
-                    }
-                    break;
-                default:
-                    break;
+            // we could also check the administrative status of the tp
+            if (serviceTypeEthClassMap.containsKey(otnServiceType)
+                    && sic.getIfCapType().equals(serviceTypeEthClassMap.get(otnServiceType))) {
+                return true;
             }
         }
         return false;
             }
         }
         return false;
@@ -344,18 +323,11 @@ public class PceOtnNode implements PceNode {
         }
     }
 
         }
     }
 
-    public boolean validateSwitchingPoolBandwidth(
-            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
-                    .ietf.network.topology.rev180226.networks.network.node.TerminationPoint tp1,
-            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
-                    .ietf.network.topology.rev180226.networks.network.node.TerminationPoint tp2,
-            Long neededBW) {
+    public boolean validateSwitchingPoolBandwidth(TerminationPoint tp1, TerminationPoint tp2, Long neededBW) {
         if (this.nodeType != OpenroadmNodeType.TPDR) {
             return true;
         }
         if (this.nodeType != OpenroadmNodeType.TPDR) {
             return true;
         }
-        org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1 node1 =
-            node.augmentation(
-                    org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1.class);
+        Node1 node1 = node.augmentation(Node1.class);
         SwitchingPools sp = node1.getSwitchingPools();
         List<OduSwitchingPools> osp = new ArrayList<>(sp.nonnullOduSwitchingPools().values());
         for (OduSwitchingPools ospx : osp) {
         SwitchingPools sp = node1.getSwitchingPools();
         List<OduSwitchingPools> osp = new ArrayList<>(sp.nonnullOduSwitchingPools().values());
         for (OduSwitchingPools ospx : osp) {
@@ -391,26 +363,29 @@ public class PceOtnNode implements PceNode {
     }
 
     public void checkAvailableTribPort() {
     }
 
     public void checkAvailableTribPort() {
-        List<TerminationPoint> networkTpList = node
-            .augmentation(
-                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
-            .getTerminationPoint().values().stream()
-            .filter(type -> type
-                .augmentation(
-                    org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1.class)
-                .getTpType()
-                .equals(OpenroadmTpType.XPONDERNETWORK))
-            .collect(Collectors.toList());
-        for (TerminationPoint tp : networkTpList) {
-            if (tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes() != null
-                && tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes().getOdtuTpnPool() != null
-                && (tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes().getOdtuTpnPool()
-                    .values().stream().findFirst().get().getOdtuType().equals(ODTU4TsAllocated.class)
-                    || tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes().getOdtuTpnPool()
-                    .values().stream().findFirst().get().getOdtuType().equals(ODTUCnTs.class))) {
+        for (TerminationPoint tp :
+            node.augmentation(
+                    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+                        .Node1.class)
+                .getTerminationPoint().values().stream()
+                .filter(type -> type
+                    .augmentation(
+                        org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
+                            .TerminationPoint1.class)
+                    .getTpType()
+                    .equals(OpenroadmTpType.XPONDERNETWORK))
+                .collect(Collectors.toList())) {
+            XpdrTpPortConnectionAttributes portConAttr =
+                tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes();
+            if (portConAttr != null
+                && portConAttr.getOdtuTpnPool() != null
+                && (portConAttr.getOdtuTpnPool().values().stream().findFirst().get().getOdtuType()
+                        .equals(ODTU4TsAllocated.class)
+                    || portConAttr.getOdtuTpnPool().values().stream().findFirst().get().getOdtuType()
+                        .equals(ODTUCnTs.class))) {
+            //TODO a dedicated method for OdtuTpnPool first value would probably be welcome
                 List<Uint16> tpnPool =
                 List<Uint16> tpnPool =
-                    tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes().getOdtuTpnPool()
-                        .values().stream().findFirst().get().getTpnPool();
+                    portConAttr.getOdtuTpnPool().values().stream().findFirst().get().getTpnPool();
                 if (tpnPool != null) {
                     tpAvailableTribPort.put(tp.getTpId().getValue(), tpnPool);
                 }
                 if (tpnPool != null) {
                     tpAvailableTribPort.put(tp.getTpId().getValue(), tpnPool);
                 }
@@ -419,21 +394,20 @@ public class PceOtnNode implements PceNode {
     }
 
     public void checkAvailableTribSlot() {
     }
 
     public void checkAvailableTribSlot() {
-        List<TerminationPoint> networkTpList = node.augmentation(
-            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
+        for (TerminationPoint tp :
+            node.augmentation(
+                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
             .getTerminationPoint().values().stream()
             .filter(type -> type
                 .augmentation(
                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1.class)
                 .getTpType().equals(OpenroadmTpType.XPONDERNETWORK))
             .getTerminationPoint().values().stream()
             .filter(type -> type
                 .augmentation(
                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1.class)
                 .getTpType().equals(OpenroadmTpType.XPONDERNETWORK))
-            .collect(Collectors.toList());
-        for (TerminationPoint tp : networkTpList) {
-            if (tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes() != null
-                    && tp.augmentation(TerminationPoint1.class)
-                        .getXpdrTpPortConnectionAttributes().getTsPool() != null) {
-                List<Uint16> tsPool =
-                    tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes().getTsPool();
-                tpAvailableTribSlot.put(tp.getTpId().getValue(), tsPool);
+            .collect(Collectors.toList())
+        ) {
+            XpdrTpPortConnectionAttributes portConAttr =
+                tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes();
+            if (portConAttr != null && portConAttr.getTsPool() != null) {
+                tpAvailableTribSlot.put(tp.getTpId().getValue(), portConAttr.getTsPool());
             }
         }
     }
             }
         }
     }
@@ -448,19 +422,19 @@ public class PceOtnNode implements PceNode {
     }
 
     public boolean isPceOtnNodeValid(final PceOtnNode pceOtnNode) {
     }
 
     public boolean isPceOtnNodeValid(final PceOtnNode pceOtnNode) {
-        if (pceOtnNode == null || pceOtnNode.node == null
-            || pceOtnNode.getNodeId() == null || pceOtnNode.nodeType == null || pceOtnNode.getSupNetworkNodeId() == null
-            || pceOtnNode.getSupClliNodeId() == null || pceOtnNode.otnServiceType == null) {
+        if (pceOtnNode == null || pceOtnNode.node == null || pceOtnNode.getNodeId() == null
+                || pceOtnNode.nodeType == null || pceOtnNode.getSupNetworkNodeId() == null
+                || pceOtnNode.getSupClliNodeId() == null || pceOtnNode.otnServiceType == null) {
             LOG.error(
                 "PceOtnNode: one of parameters is not populated : nodeId, node type, supporting nodeId, otnServiceType"
             );
             return false;
         }
             LOG.error(
                 "PceOtnNode: one of parameters is not populated : nodeId, node type, supporting nodeId, otnServiceType"
             );
             return false;
         }
-        if (!isNodeTypeValid(pceOtnNode)) {
-            LOG.error("PceOtnNode node type: node type isn't one of MUXPDR or SWITCH or TPDR");
-            return false;
+        if (isNodeTypeValid(pceOtnNode)) {
+            return isOtnServiceTypeValid(pceOtnNode);
         }
         }
-        return isOtnServiceTypeValid(pceOtnNode);
+        LOG.error("PceOtnNode node type: node type is not one of MUXPDR or SWITCH or TPDR");
+        return false;
     }
 
     private boolean isOtnServiceTypeValid(PceOtnNode pceOtnNode) {
     }
 
     private boolean isOtnServiceTypeValid(PceOtnNode pceOtnNode) {
@@ -476,6 +450,8 @@ public class PceOtnNode implements PceNode {
                 || pceOtnNode.otnServiceType.equals(StringConstants.SERVICE_TYPE_1GE)
                 || pceOtnNode.otnServiceType.equals(StringConstants.SERVICE_TYPE_100GE_S))
                 && (isAz(pceOtnNode) || isIntermediate(pceOtnNode));
                 || pceOtnNode.otnServiceType.equals(StringConstants.SERVICE_TYPE_1GE)
                 || pceOtnNode.otnServiceType.equals(StringConstants.SERVICE_TYPE_100GE_S))
                 && (isAz(pceOtnNode) || isIntermediate(pceOtnNode));
+        //TODO serviceTypeEthTsNbMap.containsKey(this.otnServiceType) might be more appropriate here
+        //     but only SERVICE_TYPE_100GE_S is managed and not SERVICE_TYPE_100GE_M and _T
     }
 
     private boolean isIntermediate(PceOtnNode pceOtnNode) {
     }
 
     private boolean isIntermediate(PceOtnNode pceOtnNode) {