X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=pce%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fpce%2Fnetworkanalyzer%2FPceOtnNode.java;h=2e61eb4bcb01596ec23ad5d7a10daca03fe0b77c;hb=2af24568428a8fdc70c0f56ad71b939c8ce84530;hp=7b9b5cb8cdfaf43ea4147d284a4c165e8e09bb08;hpb=e8b516c52451ad5055529b3e11065546a58394b3;p=transportpce.git diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOtnNode.java b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOtnNode.java index 7b9b5cb8c..2e61eb4bc 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOtnNode.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOtnNode.java @@ -17,7 +17,6 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.stream.Collectors; -import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.transportpce.common.StringConstants; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates; @@ -31,11 +30,14 @@ 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.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.IfOCHOTU4ODU4; import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOtsiOtsigroup; +import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.SupportedIfCapability; +import org.opendaylight.yang.gen.v1.http.org.openroadm.xponder.rev200529.xpdr.otn.tp.attributes.OdtuTpnPool; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId; @@ -45,13 +47,35 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class PceOtnNode implements PceNode { - /* Logging. */ - private static final Logger LOG = LoggerFactory.getLogger(PceOtnNode.class); ////////////////////////// OTN NODES /////////////////////////// /* * For This Class the node passed shall be at the otn-openroadm Layer */ + private static final Logger LOG = LoggerFactory.getLogger(PceOtnNode.class); + private static final List SERVICE_TYPE_ODU_LIST = List.of( + StringConstants.SERVICE_TYPE_ODU4, + StringConstants.SERVICE_TYPE_ODUC4, + StringConstants.SERVICE_TYPE_ODUC3, + StringConstants.SERVICE_TYPE_ODUC2); + private static final List VALID_NODETYPES_LIST = List.of( + OpenroadmNodeType.MUXPDR, + OpenroadmNodeType.SWITCH, + OpenroadmNodeType.TPDR); + private static final Map> SERVICE_TYPE_ETH_CLASS_MAP = Map.of( + StringConstants.SERVICE_TYPE_1GE, If1GEODU0.class, + StringConstants.SERVICE_TYPE_10GE, If10GEODU2e.class, + StringConstants.SERVICE_TYPE_100GE_M, If100GEODU4.class, + StringConstants.SERVICE_TYPE_100GE_S, If100GEODU4.class); + private static final Map SERVICE_TYPE_ETH_TS_NB_MAP = Map.of( + StringConstants.SERVICE_TYPE_1GE, 1, + StringConstants.SERVICE_TYPE_10GE, 10, + StringConstants.SERVICE_TYPE_100GE_M, 20); + private static final Map SERVICE_TYPE_ETH_ODU_STRING_MAP = 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; @@ -76,8 +100,10 @@ public class PceOtnNode implements PceNode { private List outgoingLinks = new ArrayList<>(); private Map clientPerNwTp = new HashMap<>(); + private String clientPort; - public PceOtnNode(Node node, OpenroadmNodeType nodeType, NodeId nodeId, String pceNodeType, String serviceType) { + public PceOtnNode(Node node, OpenroadmNodeType nodeType, NodeId nodeId, String pceNodeType, String serviceType, + String clientPort) { this.node = node; this.nodeId = nodeId; this.nodeType = nodeType; @@ -90,158 +116,172 @@ public class PceOtnNode implements PceNode { this.usedXpdrClientTps.clear(); this.availableXpdrClientTps = new ArrayList<>(); this.usableXpdrClientTps = new ArrayList<>(); - this.adminStates = node.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529 - .Node1.class).getAdministrativeState(); - this.state = node.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529 - .Node1.class).getOperationalState(); + this.adminStates = node + .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1.class) + .getAdministrativeState(); + this.state = node + .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1.class) + .getOperationalState(); this.tpAvailableTribPort.clear(); checkAvailableTribPort(); this.tpAvailableTribSlot.clear(); checkAvailableTribSlot(); - if ((node == null) || (nodeId == null) || (nodeType != OpenroadmNodeType.MUXPDR) - && (nodeType != OpenroadmNodeType.SWITCH) && (nodeType != OpenroadmNodeType.TPDR)) { + this.clientPort = clientPort; + if (node == null || nodeId == null || nodeType == null || !VALID_NODETYPES_LIST.contains(nodeType)) { LOG.error("PceOtnNode: one of parameters is not populated : nodeId, node type"); this.valid = false; } + if (!SERVICE_TYPE_ETH_CLASS_MAP.containsKey(serviceType) + && !SERVICE_TYPE_ODU_LIST.contains(serviceType)) { + LOG.error("PceOtnNode: unsupported OTN Service Type {}", serviceType); + this.valid = false; + } } public void initXndrTps(String 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 allTps = new ArrayList<>(nodeTp.nonnullTerminationPoint().values()); + List 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; } - - for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network - .node.TerminationPoint tp : allTps) { - org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.@Nullable TerminationPoint1 ocnTp1 + 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); - //TODO many nested if-structures below, this needs to be reworked - if (OpenroadmTpType.XPONDERNETWORK.equals(ocnTp1.getTpType())) { - TerminationPoint1 ontTp1; - if (tp.augmentation(TerminationPoint1.class) != null) { - ontTp1 = tp.augmentation(TerminationPoint1.class); - } else { - continue; - } - switch (this.otnServiceType) { - case StringConstants.SERVICE_TYPE_ODU4: - case StringConstants.SERVICE_TYPE_ODUC4: + .TerminationPoint1.class); + if (ocnTp1 == null) { + LOG.warn("null ocn TP {}", tp); + continue; + } + //TODO many nested structures below, this needs to be reworked + switch (ocnTp1.getTpType()) { + case XPONDERNETWORK: + if (tp.augmentation(TerminationPoint1.class) == null) { + continue; + } + TerminationPoint1 ontTp1 = tp.augmentation(TerminationPoint1.class); + if (SERVICE_TYPE_ODU_LIST.contains(this.otnServiceType) + || StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType)) { + // TODO verify the capability of network port to support ODU4 CTP interface creation 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 OD2e termination creation", - tp.getTpId().getValue(), node.getNodeId().getValue()); + } else if (SERVICE_TYPE_ETH_TS_NB_MAP.containsKey(this.otnServiceType)) { + if (!checkOdtuTTPforLoOduCreation( + ontTp1, SERVICE_TYPE_ETH_TS_NB_MAP.get(this.otnServiceType))) { + LOG.error("TP {} of {} does not allow {} termination creation", + tp.getTpId().getValue(), + SERVICE_TYPE_ETH_ODU_STRING_MAP.get(this.otnServiceType), + 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()); + } 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: + if (SERVICE_TYPE_ETH_CLASS_MAP.containsKey(otnServiceType)) { + if (tp.augmentation(TerminationPoint1.class) == null) { continue; } - break; - case StringConstants.SERVICE_TYPE_1GE: - if (!checkOdtuTTPforLoOduCreation(ontTp1, 1)) { - LOG.error("TP {} of {} does not allow ODU0 termination creation", + if (checkClientTp(tp.augmentation(TerminationPoint1.class))) { + LOG.info("TP {} of XPONDER {} is validated", tp.getTpId(), node.getNodeId().getValue()); + this.availableXpdrClientTps.add(tp.getTpId()); + } else { + LOG.error("TP {} of {} does not allow lo-ODU (ODU2e or ODU0) termination creation", tp.getTpId().getValue(), node.getNodeId().getValue()); - continue; } - break; + } + break; - default: - 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()); - } else if (OpenroadmTpType.XPONDERCLIENT.equals(ocnTp1.getTpType()) - && (StringConstants.SERVICE_TYPE_10GE.equals(this.otnServiceType) - || StringConstants.SERVICE_TYPE_100GE_M.equals(this.otnServiceType) - || StringConstants.SERVICE_TYPE_1GE.equals(this.otnServiceType))) { - TerminationPoint1 ontTp1; - if (tp.augmentation(TerminationPoint1.class) != null) { - ontTp1 = tp.augmentation(TerminationPoint1.class); - } else { - continue; - } - if (checkClientTp(ontTp1)) { - LOG.info("TP {} of XPONDER {} is validated", tp.getTpId(), node.getNodeId().getValue()); - this.availableXpdrClientTps.add(tp.getTpId()); - } else { - LOG.error("TP {} of {} does not allow lo-ODU (ODU2e or ODU0) termination creation", - tp.getTpId().getValue(), node.getNodeId().getValue()); - } + default: + LOG.debug("unsupported ocn TP type {}", ocnTp1.getTpType()); } } + this.valid = SERVICE_TYPE_ODU_LIST.contains(this.otnServiceType) + || SERVICE_TYPE_ETH_CLASS_MAP.containsKey(this.otnServiceType) + && checkSwPool(availableXpdrNWTps, availableXpdrClientTps); + } - if (((StringConstants.SERVICE_TYPE_ODU4.equals(this.otnServiceType) - || StringConstants.SERVICE_TYPE_ODUC4.equals(this.otnServiceType)) && mode.equals("AZ")) - || ((StringConstants.SERVICE_TYPE_10GE.equals(this.otnServiceType) - || StringConstants.SERVICE_TYPE_100GE_M.equals(this.otnServiceType) - || StringConstants.SERVICE_TYPE_1GE.equals(this.otnServiceType)) - && ((mode.equals("AZ") && checkSwPool(availableXpdrClientTps, availableXpdrNWTps, 1, 1)) - || (mode.equals("intermediate") && checkSwPool(null, availableXpdrNWTps, 0, 2))) - )) { - this.valid = true; - } else { - this.valid = false; + private boolean checkSwPool(List netwTps, List clientTps) { + + if (netwTps == null) { + return false; + } + Node1 node1 = node.augmentation(Node1.class); + if (node1 == null) { + return false; + } + List nblList = new ArrayList<>( + node1.getSwitchingPools().nonnullOduSwitchingPools() + .values().stream().findFirst().get() + .getNonBlockingList().values()); + if (nblList == null) { + return false; + } + netwTps.sort(Comparator.comparing(TpId::getValue)); + + switch (modeType) { + + case "intermediate": + return checkIntermediateSwPool(nblList, netwTps); + + case "AZ": + if (clientTps == null) { + return false; + } + clientTps.sort(Comparator.comparing(TpId::getValue)); + return checkAzSwPool(nblList, netwTps, clientTps); + + default: + LOG.error("Unsupported mode type {}", modeType); + return false; } } - private boolean checkSwPool(List clientTps, List netwTps, int nbClient, int nbNetw) { - if (clientTps != null && netwTps != null && nbClient == 1 && nbNetw == 1) { - clientTps.sort(Comparator.comparing(TpId::getValue)); - netwTps.sort(Comparator.comparing(TpId::getValue)); + + private boolean checkIntermediateSwPool(List nblList, List netwTps) { + for (NonBlockingList nbl: nblList) { for (TpId nwTp : netwTps) { - for (TpId clTp : clientTps) { - @Nullable - List nblList = new ArrayList<>(node.augmentation(Node1.class).getSwitchingPools() - .nonnullOduSwitchingPools().values().stream().findFirst().get().getNonBlockingList().values()); - for (NonBlockingList nbl : nblList) { - if (nbl.getTpList().contains(clTp) && nbl.getTpList().contains(nwTp)) { - usableXpdrClientTps.add(clTp); - usableXpdrNWTps.add(nwTp); - } - if (usableXpdrClientTps.size() >= nbClient && usableXpdrNWTps.size() >= nbNetw) { - clientPerNwTp.put(nwTp.getValue(), clTp.getValue()); - return true; - } - } + if (nbl.getTpList().contains(nwTp)) { + usableXpdrNWTps.add(nwTp); + } + if (usableXpdrNWTps.size() >= 2) { + return true; } } - } - if (clientTps == null && netwTps != null && nbClient == 0 && nbNetw == 2) { - netwTps.sort(Comparator.comparing(TpId::getValue)); - @Nullable - List nblList = new ArrayList<>(node.augmentation(Node1.class).getSwitchingPools() - .nonnullOduSwitchingPools().values().stream().findFirst().get().getNonBlockingList().values()); - for (NonBlockingList nbl : nblList) { - for (TpId nwTp : netwTps) { - if (nbl.getTpList().contains(nwTp)) { + return false; + } + + + private boolean checkAzSwPool(List nblList, List netwTps, List clientTps) { + for (NonBlockingList nbl: nblList) { + for (TpId nwTp : netwTps) { + for (TpId clTp : clientTps) { + if (nbl.getTpList().contains(clTp) && nbl.getTpList().contains(nwTp)) { + usableXpdrClientTps.add(clTp); usableXpdrNWTps.add(nwTp); } - if (usableXpdrNWTps.size() >= nbNetw) { + if (usableXpdrClientTps.size() >= 1 && usableXpdrNWTps.size() >= 1 + && (this.clientPort == null || this.clientPort.equals(clTp.getValue()))) { + clientPerNwTp.put(nwTp.getValue(), clTp.getValue()); return true; } } @@ -264,48 +304,30 @@ public class PceOtnNode implements PceNode { } private boolean checkOdtuTTPforLoOduCreation(TerminationPoint1 ontTp1, int tsNb) { - if (ontTp1.getXpdrTpPortConnectionAttributes() != null - && ontTp1.getXpdrTpPortConnectionAttributes().getTsPool() != null - && ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool() != null - && (ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values() - .stream().findFirst().get().getOdtuType() - .equals(ODTU4TsAllocated.class) - || - ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values() - .stream().findFirst().get().getOdtuType() - .equals(ODTUCnTs.class)) - && !ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values() - .stream().findFirst().get().getTpnPool().isEmpty() - && (ontTp1.getXpdrTpPortConnectionAttributes().getTsPool().size() >= tsNb)) { - return true; + XpdrTpPortConnectionAttributes portConAttr = ontTp1.getXpdrTpPortConnectionAttributes(); + if (portConAttr == null + || portConAttr.getTsPool() == null + || portConAttr.getTsPool().size() < tsNb + || portConAttr.getOdtuTpnPool() == null) { + return false; } - return false; + return checkFirstOdtuTpn(portConAttr.getOdtuTpnPool().values().stream().findFirst().get()); + } + + private boolean checkFirstOdtuTpn(OdtuTpnPool otPool) { + return (otPool.getOdtuType().equals(ODTU4TsAllocated.class) + || otPool.getOdtuType().equals(ODTUCnTs.class)) + && !otPool.getTpnPool().isEmpty(); } 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: - if (sic.getIfCapType().equals(If100GEODU4.class)) { - return true; - } - break; - default: - break; + // we could also check the administrative status of the tp + if (SERVICE_TYPE_ETH_CLASS_MAP.containsKey(otnServiceType) + && sic.getIfCapType().equals(SERVICE_TYPE_ETH_CLASS_MAP.get(otnServiceType))) { + return true; } } return false; @@ -315,29 +337,21 @@ public class PceOtnNode implements PceNode { if (!isValid()) { return; } - if (OpenroadmNodeType.SWITCH.equals(this.nodeType)) { - initXndrTps("intermediate"); - } if (this.nodeId.getValue().equals(anodeId) || (this.nodeId.getValue().equals(znodeId))) { initXndrTps("AZ"); + } else if (OpenroadmNodeType.SWITCH.equals(this.nodeType)) { + initXndrTps("intermediate"); } else { LOG.info("validateAZxponder: XPONDER is ignored == {}", nodeId.getValue()); valid = false; } } - 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; } - 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 osp = new ArrayList<>(sp.nonnullOduSwitchingPools().values()); for (OduSwitchingPools ospx : osp) { @@ -351,11 +365,9 @@ public class PceOtnNode implements PceNode { } } } - LOG.debug("validateSwitchingPoolBandwidth: No valid Switching pool for crossconnecting tp {} and {}", tp1.getTpId(), tp2.getTpId()); return false; - } public void validateIntermediateSwitch() { @@ -367,124 +379,65 @@ public class PceOtnNode implements PceNode { } // Validate switch for use as an intermediate XPONDER on the path initXndrTps("intermediate"); - if (!this.valid) { - LOG.debug("validateIntermediateSwitch: Switch unusable for transit == {}", nodeId.getValue()); - } else { + if (this.valid) { LOG.info("validateIntermediateSwitch: Switch usable for transit == {}", nodeId.getValue()); + } else { + LOG.debug("validateIntermediateSwitch: Switch unusable for transit == {}", nodeId.getValue()); } } public void checkAvailableTribPort() { - List 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))) { - @Nullable - List tpnPool = tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().values().stream().findFirst().get().getTpnPool(); - if (tpnPool != null) { - tpAvailableTribPort.put(tp.getTpId().getValue(), tpnPool); + 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) { + OdtuTpnPool otPool = portConAttr.getOdtuTpnPool().values().stream().findFirst().get(); + if (checkFirstOdtuTpn(otPool)) { + tpAvailableTribPort.put(tp.getTpId().getValue(), otPool.getTpnPool()); } } } } public void checkAvailableTribSlot() { - List 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)) - .collect(Collectors.toList()); - - for (TerminationPoint tp : networkTpList) { - if (tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes() != null - && tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes().getTsPool() != null) { - @Nullable - List 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()); } } } public boolean isValid() { - if ((node == null) || (nodeId == null) || (nodeType == null) || (this.getSupNetworkNodeId() == null) - || (this.getSupClliNodeId() == null)) { + if (nodeId == null || nodeType == null + || this.getSupNetworkNodeId() == null || this.getSupClliNodeId() == null) { LOG.error("PceNode: one of parameters is not populated : nodeId, node type, supporting nodeId"); valid = false; } return valid; } - 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) { - 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; - } - - return isOtnServiceTypeValid(pceOtnNode); - } - - private boolean isOtnServiceTypeValid(PceOtnNode pceOtnNode) { - if (pceOtnNode.modeType == null) { - return false; - } - - //Todo refactor Strings (mode and otnServiceType ) to enums - if ((pceOtnNode.otnServiceType.equals(StringConstants.SERVICE_TYPE_ODU4) - && pceOtnNode.modeType.equals("AZ"))) { - return true; - } - - if ((pceOtnNode.otnServiceType.equals(StringConstants.SERVICE_TYPE_10GE) - || pceOtnNode.otnServiceType.equals(StringConstants.SERVICE_TYPE_1GE)) - && (isAz(pceOtnNode) || isIntermediate(pceOtnNode))) { - return true; - } - - return false; - } - - private boolean isIntermediate(PceOtnNode pceOtnNode) { - return pceOtnNode.modeType.equals("intermediate") - && checkSwPool(null, pceOtnNode.availableXpdrNWTps, 0, 2); - } - - private boolean isAz(PceOtnNode pceOtnNode) { - return pceOtnNode.modeType.equals("AZ") - && checkSwPool(pceOtnNode.availableXpdrClientTps, pceOtnNode.availableXpdrNWTps, 1, 1); - } - - private boolean isNodeTypeValid(final PceOtnNode pceOtnNode) { - return (pceOtnNode.nodeType == OpenroadmNodeType.MUXPDR) - || (pceOtnNode.nodeType == OpenroadmNodeType.SWITCH) - || (pceOtnNode.nodeType == OpenroadmNodeType.TPDR); - } - @Override public void addOutgoingLink(PceLink outLink) { this.outgoingLinks.add(outLink); @@ -553,7 +506,7 @@ public class PceOtnNode implements PceNode { } @Override - public String getRdmSrgClient(String tp) { + public String getRdmSrgClient(String tp, String direction) { return null; }