X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=pce%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fpce%2Fnetworkanalyzer%2FPceOtnNode.java;h=4cd7c943775c746e4108bee082eaf58a02ad6c2b;hb=7f3a52c2753fa58723e4f061b97ac1bb1df91992;hp=4966b9a4405263be5463ff5399fa994a08343dc5;hpb=7ea354677f9b8ee0b160a7b636c51bb0bedfcd7b;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 4966b9a44..4cd7c9437 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 @@ -8,28 +8,34 @@ package org.opendaylight.transportpce.pce.networkanalyzer; +import java.math.BigDecimal; import java.util.ArrayList; +import java.util.BitSet; import java.util.Comparator; import java.util.HashMap; 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.yang.gen.v1.http.org.openroadm.network.topology.types.rev181130.xpdr.odu.switching.pools.OduSwitchingPools; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev181130.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmNodeType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmTpType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.xpdr.tp.supported.interfaces.SupportedInterfaceCapability; -import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev181130.ODTU4TsAllocated; -import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1; -import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.TerminationPoint1; -import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.networks.network.node.SwitchingPools; -import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.If100GEODU4; -import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.If10GEODU2e; -import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.If1GEODU0; -import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.IfOCHOTU4ODU4; +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; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPools; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmNodeType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmTpType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapability; +import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODTU4TsAllocated; +import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODTUCnTs; +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.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; @@ -46,6 +52,28 @@ public class PceOtnNode implements PceNode { * For This Class the node passed shall be at the otn-openroadm Layer */ + private static List serviceTypeOduList = List.of( + StringConstants.SERVICE_TYPE_ODU4, + StringConstants.SERVICE_TYPE_ODUC4, + StringConstants.SERVICE_TYPE_ODUC3, + StringConstants.SERVICE_TYPE_ODUC2); + private static Map> + 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 serviceTypeEthTsNbMap = Map.of( + StringConstants.SERVICE_TYPE_1GE, 1, + StringConstants.SERVICE_TYPE_10GE, 10, + StringConstants.SERVICE_TYPE_100GE_M, 20); + private static Map 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; @@ -53,6 +81,10 @@ public class PceOtnNode implements PceNode { private final OpenroadmNodeType nodeType; private final String pceNodeType; private final String otnServiceType; + private String modeType; + // TODO: not adding state check in this class as otn topology has not been modified + private final AdminStates adminStates; + private final State state; private Map> tpAvailableTribPort = new TreeMap<>(); private Map> tpAvailableTribSlot = new TreeMap<>(); @@ -66,8 +98,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; @@ -80,12 +114,19 @@ 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.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 != OpenroadmNodeType.MUXPDR + && nodeType != OpenroadmNodeType.SWITCH && nodeType != OpenroadmNodeType.TPDR) { LOG.error("PceOtnNode: one of parameters is not populated : nodeId, node type"); this.valid = false; } @@ -94,89 +135,92 @@ public class PceOtnNode implements PceNode { public void initXndrTps(String mode) { LOG.info("PceOtnNode: initXndrTps for node {}", this.nodeId.getValue()); this.availableXponderTp.clear(); - - 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 = nodeTp.getTerminationPoint(); + this.modeType = mode; + 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 == null) { + 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.rev181130.@Nullable TerminationPoint1 ocnTp1 - = tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130 - .TerminationPoint1.class); - //TODO many nested if-structures below, this needs to be reworked - if (OpenroadmTpType.XPONDERNETWORK.equals(ocnTp1.getTpType()) && this.otnServiceType.equals("ODU4")) { - TerminationPoint1 ontTp1; - if (tp.augmentation(TerminationPoint1.class) != null) { - ontTp1 = tp.augmentation(TerminationPoint1.class); - } else { - continue; - } - if (checkTpForOdtuTermination(ontTp1)) { - LOG.info("TP {} of XPONDER {} is validated", tp.getTpId(), node.getNodeId().getValue()); - this.availableXpdrNWTps.add(tp.getTpId()); - } else { - LOG.error("TP {} of {} does not allow ODU4 termination creation", tp.getTpId().getValue(), - node.getNodeId().getValue()); - } - } else if (OpenroadmTpType.XPONDERNETWORK.equals(ocnTp1.getTpType()) - && (this.otnServiceType.equals("10GE") || this.otnServiceType.equals("1GE"))) { - TerminationPoint1 ontTp1; - if (tp.augmentation(TerminationPoint1.class) != null) { - ontTp1 = tp.augmentation(TerminationPoint1.class); - } else { - continue; - } - if ("10GE".equals(otnServiceType) && checkOdtuTTPforLoOduCreation(ontTp1, 10) - || "1GE".equals(otnServiceType) && checkOdtuTTPforLoOduCreation(ontTp1, 1)) { - LOG.info("TP {} of XPONDER {} is validated", tp.getTpId(), node.getNodeId().getValue()); - this.availableXpdrNWTps.add(tp.getTpId()); - } else { - if ("10GE".equals(otnServiceType)) { - LOG.error("TP {} of {} does not allow OD2e termination creation", tp.getTpId().getValue(), - node.getNodeId().getValue()); - } else if ("1GE".equals(otnServiceType)) { - LOG.error("TP {} of {} does not allow ODU0 termination creation", tp.getTpId().getValue(), - node.getNodeId().getValue()); + 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); + 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 (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 + if (!checkTpForOdtuTermination(ontTp1)) { + LOG.error("TP {} of {} does not allow ODU4 termination creation", + 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()); + LOG.error("TP {} of {} does not allow any termination creation", + tp.getTpId().getValue(), node.getNodeId().getValue()); + continue; } - } - } else if (OpenroadmTpType.XPONDERCLIENT.equals(ocnTp1.getTpType()) - && (this.otnServiceType.equals("10GE") || this.otnServiceType.equals("1GE"))) { - 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()); - } - } - } + this.availableXpdrNWTps.add(tp.getTpId()); + break; - if ((this.otnServiceType.equals("ODU4") && mode.equals("AZ")) - || ((this.otnServiceType.equals("10GE") || this.otnServiceType.equals("1GE")) - && mode.equals("AZ") && checkSwPool(availableXpdrClientTps, availableXpdrNWTps, 1, 1)) - || ((this.otnServiceType.equals("10GE") || this.otnServiceType.equals("1GE")) - && mode.equals("intermediate") && checkSwPool(null, availableXpdrNWTps, 0, 2))) { - this.valid = true; - } else { - this.valid = false; + case XPONDERCLIENT: + 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 (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()); + } + } + break; + + default: + LOG.debug("unsupported ocn TP type {}", ocnTp1.getTpType()); + } } + 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(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 clientTps, List netwTps, int nbClient, int nbNetw) { @@ -185,29 +229,28 @@ public class PceOtnNode implements PceNode { netwTps.sort(Comparator.comparing(TpId::getValue)); for (TpId nwTp : netwTps) { for (TpId clTp : clientTps) { - @Nullable - List nblList = node.augmentation(Node1.class).getSwitchingPools() - .getOduSwitchingPools().get(0).getNonBlockingList(); - for (NonBlockingList nbl : nblList) { + for (NonBlockingList nbl : new ArrayList<>(node.augmentation(Node1.class).getSwitchingPools() + .nonnullOduSwitchingPools().values().stream().findFirst().get() + .getNonBlockingList().values())) { 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 (this.clientPort == null || this.clientPort.equals(clTp.getValue())) { + clientPerNwTp.put(nwTp.getValue(), clTp.getValue()); + return true; + } } } } } - } - if (clientTps == null && netwTps != null && nbClient == 0 && nbNetw == 2) { + if (netwTps != null && nbClient == 0 && nbNetw == 2) { netwTps.sort(Comparator.comparing(TpId::getValue)); - @Nullable - List nblList = node.augmentation(Node1.class).getSwitchingPools().getOduSwitchingPools() - .get(0).getNonBlockingList(); - for (NonBlockingList nbl : nblList) { + for (NonBlockingList nbl : new ArrayList<>(node.augmentation(Node1.class).getSwitchingPools() + .nonnullOduSwitchingPools().values().stream().findFirst().get() + .getNonBlockingList().values())) { for (TpId nwTp : netwTps) { if (nbl.getTpList().contains(nwTp)) { usableXpdrNWTps.add(nwTp); @@ -222,10 +265,12 @@ public class PceOtnNode implements PceNode { } private boolean checkTpForOdtuTermination(TerminationPoint1 ontTp1) { - for (SupportedInterfaceCapability sic : ontTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability()) { - LOG.debug("in checkTpForOduTermination - sic = {}", sic.getIfCapType()); - if (sic.getIfCapType().equals(IfOCHOTU4ODU4.class) - && ontTp1.getXpdrTpPortConnectionAttributes().getTsPool() == null) { + for (SupportedInterfaceCapability sic : ontTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability() + .values()) { + LOG.info("in checkTpForOduTermination - sic = {}", sic.getIfCapType()); + if ((sic.getIfCapType().equals(IfOCHOTU4ODU4.class) || sic.getIfCapType().equals(IfOtsiOtsigroup.class)) + && (ontTp1.getXpdrTpPortConnectionAttributes() == null + || ontTp1.getXpdrTpPortConnectionAttributes().getTsPool() == null)) { return true; } } @@ -233,137 +278,60 @@ 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().get(0).getOdtuType() - .equals(ODTU4TsAllocated.class) - && ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().get(0).getTpnPool().isEmpty() - && (ontTp1.getXpdrTpPortConnectionAttributes().getTsPool().size() >= tsNb)) { - return true; - } - return false; + 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) + || + portConAttr.getOdtuTpnPool().values() + .stream().findFirst().get().getOdtuType() + .equals(ODTUCnTs.class)) + && !portConAttr.getOdtuTpnPool().values() + .stream().findFirst().get().getTpnPool() + .isEmpty(); + //TODO a dedicated method for OdtuTpnPool first value would probably be welcome } private boolean checkClientTp(TerminationPoint1 ontTp1) { - for (SupportedInterfaceCapability sic : ontTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability()) { + for (SupportedInterfaceCapability sic : ontTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability() + .values()) { LOG.debug("in checkTpForOduTermination - sic = {}", sic.getIfCapType()); - switch (otnServiceType) { - case "1GE": - // we could also check the administrative status of the tp - if (sic.getIfCapType().equals(If1GEODU0.class)) { - return true; - } - break; - case "10GE": - if (sic.getIfCapType().equals(If10GEODU2e.class)) { - return true; - } - break; - case "100GE": - 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; } - private Boolean findClientCompliantInterface(List sic) { - boolean compliant = false; - for (SupportedInterfaceCapability sit : sic) { - String interfacetype = sit.getIfCapType().getName(); - switch (interfacetype) { - case "If1GEODU0": - case "If1GE": - if ("1GE".equals(this.otnServiceType)) { - compliant = true; - } - break; - case "If10GEODU2e": - case "If10GE": - if ("10GE".equals(this.otnServiceType)) { - compliant = true; - } - break; - case "If100GEODU4": - case "If100GE": - if ("100GE".equals(this.otnServiceType)) { - compliant = true; - } - break; - case "IfOTU4ODU4": - case "IfOCHOTU4ODU4": - if ("OTU4".equals(this.otnServiceType) || "ODU4".equals(this.otnServiceType)) { - compliant = true; - } - break; - default: - compliant = false; - break; - } - } - return compliant; - } - - private Boolean findNetworkCompliantInterface(List sic) { - boolean compliant = false; - for (SupportedInterfaceCapability sit : sic) { - String interfacetype = sit.getIfCapType().toString(); - switch (interfacetype) { - case "IfOTU4ODU4": - case "IfOCHOTU4ODU4": - compliant = true; - break; - case "IfOTU2ODU2": - case "IfOCHOTU2ODU2": - if (("1GE".equals(this.otnServiceType)) || ("10GE".equals(this.otnServiceType))) { - compliant = true; - } - break; - // add all use case with higher rate interfaces when it shows up - default: - compliant = false; - break; - } - } - return compliant; - } - public void validateXponder(String anodeId, String znodeId) { 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.rev181130.Node1 node1 = - node.augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class); + Node1 node1 = node.augmentation(Node1.class); SwitchingPools sp = node1.getSwitchingPools(); - List osp = sp.getOduSwitchingPools(); + List osp = new ArrayList<>(sp.nonnullOduSwitchingPools().values()); for (OduSwitchingPools ospx : osp) { - List nbl = ospx.getNonBlockingList(); + List nbl = new ArrayList<>(ospx.nonnullNonBlockingList().values()); for (NonBlockingList nbll : nbl) { if (nbll.getAvailableInterconnectBandwidth().toJava() >= neededBW && nbll.getTpList() != null && nbll.getTpList().contains(tp1.getTpId()) && nbll.getTpList().contains(tp2.getTpId())) { @@ -373,11 +341,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() { @@ -389,30 +355,37 @@ 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().stream() - .filter(type -> type - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.TerminationPoint1.class) - .getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) - .collect(Collectors.toList()); - - for (TerminationPoint tp : networkTpList) { - if (tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes().getOdtuTpnPool() != null - && tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes().getOdtuTpnPool().get(0) - .getOdtuType().equals(ODTU4TsAllocated.class)) { - @Nullable - List tpnPool = tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().get(0).getTpnPool(); + 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 tpnPool = + portConAttr.getOdtuTpnPool().values().stream().findFirst().get().getTpnPool(); if (tpnPool != null) { tpAvailableTribPort.put(tp.getTpId().getValue(), tpnPool); } @@ -421,34 +394,82 @@ public class PceOtnNode implements PceNode { } public void checkAvailableTribSlot() { - List networkTpList = node.augmentation( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class) - .getTerminationPoint().stream() + 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.rev181130.TerminationPoint1.class) + 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().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 (node == null || 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)) { + 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) { + 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; + } + return (pceOtnNode.otnServiceType.equals(StringConstants.SERVICE_TYPE_10GE) + || 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) { + 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); @@ -459,6 +480,16 @@ public class PceOtnNode implements PceNode { return outgoingLinks; } + @Override + public AdminStates getAdminStates() { + return adminStates; + } + + @Override + public State getState() { + return state; + } + @Override public String getXpdrClient(String tp) { return this.clientPerNwTp.get(tp); @@ -507,7 +538,7 @@ public class PceOtnNode implements PceNode { } @Override - public String getRdmSrgClient(String tp) { + public String getRdmSrgClient(String tp, String direction) { return null; } @@ -521,8 +552,40 @@ public class PceOtnNode implements PceNode { return false; } + /* + * (non-Javadoc) + * + * @see org.opendaylight.transportpce.pce.networkanalyzer.PceNode#getVersion() + */ @Override - public boolean checkWL(long index) { - return false; + public String getVersion() { + // TODO Auto-generated method stub + return null; + } + + @Override + public BitSet getBitSetData() { + // TODO Auto-generated method stub + return null; + } + + /* + * (non-Javadoc) + * + * @see org.opendaylight.transportpce.pce.networkanalyzer.PceNode#getSlotWidthGranularity() + */ + @Override + public BigDecimal getSlotWidthGranularity() { + return null; + } + + /* + * (non-Javadoc) + * + * @see org.opendaylight.transportpce.pce.networkanalyzer.PceNode#getCentralFreqGranularity() + */ + @Override + public BigDecimal getCentralFreqGranularity() { + return null; } }