X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=transportpce.git;a=blobdiff_plain;f=pce%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fpce%2Fnetworkanalyzer%2FPceOtnNode.java;h=1b423dec0428e8110eb4fbd5be893ad3bdb27adf;hp=9da697f99961a5a519c6d9f137c79b55989c6d1f;hb=bc7b5481d47817d52dbb49ea2a481cc9c4685be1;hpb=aafa2ea596dc9ea93b5ce5a7156ae68acf4b403f 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 9da697f99..1b423dec0 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,360 +8,396 @@ 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.Optional; import java.util.TreeMap; - -//import org.eclipse.jdt.annotation.Nullable; -import org.opendaylight.transportpce.common.NetworkUtils; -//import org.opendaylight.transportpce.pce.SortPortsByName; -//import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.Node1; -//import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.TerminationPoint1; -//import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.networks -//.network.node.termination.point.pp.attributes.UsedWavelength; -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.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.xponder.rev181130.xpdr.otn.tp.attributes.OdtuTpnPool; +import java.util.stream.Collectors; +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.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; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint; +import org.opendaylight.yangtools.yang.common.Uint16; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PceOtnNode extends PceNode { - /* Logging. */ - private static final Logger LOG = LoggerFactory.getLogger(PceCalculation.class); +public class PceOtnNode implements PceNode { ////////////////////////// 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 static final String INTERMEDIATE_MODETYPE = "intermediate"; + private static final String AZ_MODETYPE = "AZ"; + private boolean valid = true; - private final String supNetworkNodeId; - private final String supTopoNodeId; - private final String clli; + private final Node node; + private final NodeId nodeId; + private final OpenroadmNodeType nodeType; + private final String pceNodeType; private final String otnServiceType; - - private Map> tpAvailableTribPort = new TreeMap>(); - private Map> tpAvailableTribSlot = new TreeMap>(); - private Map availableXponderTp = new TreeMap(); - private List usedXpdrNWTps = new ArrayList(); - private List unusableXpdrNWTps = new ArrayList(); - private List usedXpdrClientTps = new ArrayList(); - private List unusableXpdrClientTps = new ArrayList(); - private List outgoingLinks = new ArrayList(); - private Map clientPerNwTp = new HashMap(); - - public PceOtnNode(Node node, OpenroadmNodeType nodeType, NodeId nodeId, String serviceType) { - super(node, nodeType, nodeId); - this.supNetworkNodeId = getNetworkSupNodeId(node); - this.supTopoNodeId = getTopoSupNodeId(node); - this.clli = getClliSupNodeId(node); + 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<>(); + private Map availableXponderTp = new TreeMap<>(); + private List usedXpdrNWTps = new ArrayList<>(); + private List availableXpdrNWTps; + private List usableXpdrNWTps; + private List usedXpdrClientTps = new ArrayList<>(); + private List availableXpdrClientTps; + private List usableXpdrClientTps; + + 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, + String clientPort) { + this.node = node; + this.nodeId = nodeId; + this.nodeType = nodeType; + this.pceNodeType = pceNodeType; this.otnServiceType = serviceType; - this.tpAvailableTribPort.clear(); this.tpAvailableTribSlot.clear(); this.usedXpdrNWTps.clear(); - this.unusableXpdrNWTps.clear(); + this.availableXpdrNWTps = new ArrayList<>(); + this.usableXpdrNWTps = new ArrayList<>(); this.usedXpdrClientTps.clear(); - this.unusableXpdrClientTps.clear(); - - if ((node == null) || (nodeId == null) || (nodeType == null)) { + 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(); + 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("initXndrTps for node : {}", this.nodeId); - int availableNetworkTpNumber = 0; - int availableClientTpNumber = 0; - + LOG.info("PceOtnNode: initXndrTps for node {}", this.nodeId.getValue()); this.availableXponderTp.clear(); - - if (!isValid()) { - return; - } - 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) { - LOG.error("initXndrTps: XPONDER TerminationPoint list is empty for node {}", this.toString()); + 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) { - TerminationPoint1 otnTp1 = tp.augmentation(TerminationPoint1.class); - //TODO many nested if-structures below, this needs to be reworked - if (otnTp1.getTpType() == OpenroadmTpType.XPONDERNETWORK) { - if (otnTp1.getXpdrTpPortConnectionAttributes().getWavelength() != null) { - this.usedXpdrNWTps.add(tp.getTpId().getValue()); - } else { - // find server of this network TP - String server = otnTp1.getXpdrTpPortConnectionAttributes().getTailEquipmentId(); - if ((server.equals("")) || (server == null)) { - this.unusableXpdrNWTps.add(tp.getTpId().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; + } + TerminationPoint1 ontTp1 = tp.augmentation(TerminationPoint1.class); + if (ontTp1 == null) { + continue; + } + //TODO many nested structures below, this needs to be reworked + switch (ocnTp1.getTpType()) { + case XPONDERNETWORK: + String notCreatedServiceType = xpdrNetTpCreation(ontTp1); + if (notCreatedServiceType == null) { + LOG.info("TP {} of XPONDER {} is validated", + tp.getTpId(), + node.getNodeId().getValue()); + this.availableXpdrNWTps.add(tp.getTpId()); } else { - // tp is not used and as a tail to server WDM layer - if (("10GE".equals(this.otnServiceType)) || ("1GE".equals(this.otnServiceType))) { - // LO-ODU needs to be created on a parent HO-ODU - // interface - List presenceOdtu = - otnTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool(); - if (presenceOdtu == null) { - this.unusableXpdrNWTps.add(tp.getTpId().getValue()); - } else { - List sic = - otnTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability(); - if ((findNetworkCompliantInterface(sic)) & (checkAvailableTribPort(tp)) - & (checkAvailableTribSlot(tp))) { - this.availableXponderTp.put(tp.getTpId().getValue(), - OpenroadmTpType.XPONDERNETWORK); - availableNetworkTpNumber++; - } - /* - * Add the retrieval of outgoing ingoing links - * through an external function - */ - } - } else { - // service is HO service - List sic = - otnTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability(); - if (findNetworkCompliantInterface(sic)) { - this.availableXponderTp.put(tp.getTpId().getValue(), OpenroadmTpType.XPONDERNETWORK); - availableNetworkTpNumber++; - /* - * Add the retrieval of outgoing ingoing links - * through an external function - */ - } else { - this.unusableXpdrNWTps.add(tp.getTpId().getValue()); - - } - - } - + LOG.error("TP {} of {} does not allow {} termination creation", + tp.getTpId().getValue(), + node.getNodeId().getValue(), + notCreatedServiceType); } + break; - } + case XPONDERCLIENT: + if (!SERVICE_TYPE_ETH_CLASS_MAP.containsKey(this.otnServiceType)) { + 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()); + } + break; - // The port is not a network port - } else if (otnTp1.getTpType() == OpenroadmTpType.XPONDERCLIENT) { - // For Client port we verify that it supports needed interfaces - // TBD : How shall we check a client port is available and not - // in use? - List sic = - otnTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability(); - if (findClientCompliantInterface(sic)) { - this.availableXponderTp.put(tp.getTpId().getValue(), OpenroadmTpType.XPONDERCLIENT); - availableClientTpNumber++; - } + default: + LOG.debug("unsupported ocn TP type {}", ocnTp1.getTpType()); } - LOG.debug("initXndrTps: XPONDER tp = {} is used", tp.getTpId().getValue()); - LOG.error("initXndrTps: XPONDER {} NW TP doesn't have defined server ROADM SRG {}", this.toString(), tp - .getTpId().getValue()); } - if ("AZ".equals(mode)) { - if ((availableClientTpNumber >= 1) || (availableNetworkTpNumber >= 1)) { - // for A and Z node we need to have one valid client port & one - // valid network port - this.valid = true; + this.valid = checkSwPool(availableXpdrNWTps, availableXpdrClientTps); + } + + private String xpdrNetTpCreation(TerminationPoint1 ontTp1) { + 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)) { + //success + return null; } - } else if ("intermediate".equals(mode)) { - if ((availableNetworkTpNumber >= 2)) { - // for OTN switching node used in transit we need to have two - // valid network ports - this.valid = true; + return "ODU4"; + } + if (SERVICE_TYPE_ETH_TS_NB_MAP.containsKey(this.otnServiceType)) { + if (checkOdtuTTPforLoOduCreation( + ontTp1, + SERVICE_TYPE_ETH_TS_NB_MAP.get(this.otnServiceType))) { + //success + return null; } + return SERVICE_TYPE_ETH_ODU_STRING_MAP.get(this.otnServiceType); } + //failure + return "any"; + } - if (!isValid()) { - LOG.debug("initXndrTps: XPONDER doesn't have the required ports available {}", this.toString()); - return; - } else { - LOG.debug("initXndrTps: XPONDER {} is elligible", this.toString()); + private boolean checkSwPool(List netwTps, List clientTps) { + + if (SERVICE_TYPE_ODU_LIST.contains(this.otnServiceType)) { + return true; + } + if (!SERVICE_TYPE_ETH_CLASS_MAP.containsKey(this.otnServiceType)) { + return false; + } + 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_MODETYPE: + return checkIntermediateSwPool(nblList, netwTps); + + case AZ_MODETYPE: + 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 findClientCompliantInterface(List sic) { - boolean compliant = false; - for (SupportedInterfaceCapability sit : sic) { - String interfacetype = sit.getIfCapType().toString(); - 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; - } + private boolean checkIntermediateSwPool(List nblList, List netwTps) { + for (NonBlockingList nbl: nblList) { + for (TpId nwTp : netwTps) { + if (nbl.getTpList().contains(nwTp)) { + usableXpdrNWTps.add(nwTp); + } + if (usableXpdrNWTps.size() >= 2) { + return true; + } + } } - return compliant; + return false; } - 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; + + 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); } - break; - // add all use case with higher rate interfaces when it shows up - default: - compliant = false; - break; + if (usableXpdrClientTps.size() >= 1 + && usableXpdrNWTps.size() >= 1 + && (this.clientPort == null || this.clientPort.equals(clTp.getValue()))) { + clientPerNwTp.put(nwTp.getValue(), clTp.getValue()); + return true; + } + } } - } - return compliant; + return false; } - private String getClliSupNodeId(Node inputNode) { - TreeMap allSupNodes = new TreeMap(); - String tempNetworkSupNodeId = ""; - allSupNodes = MapUtils.getAllSupNode(inputNode); - if (allSupNodes.get(NetworkUtils.CLLI_NETWORK_ID) == null) { - LOG.error("getClliSupNodeId: No Supporting node at CLLI layer for node: [{}].", inputNode.getNodeId()); - } else { - tempNetworkSupNodeId = allSupNodes.get(NetworkUtils.CLLI_NETWORK_ID); + private boolean checkTpForOdtuTermination(TerminationPoint1 ontTp1) { + 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; + } } - return tempNetworkSupNodeId; + return false; } - private String getNetworkSupNodeId(Node inputNode) { - TreeMap allSupNodes = new TreeMap(); - String tempNetworkSupNodeId = ""; - allSupNodes = MapUtils.getAllSupNode(inputNode); - if (allSupNodes.get(NetworkUtils.UNDERLAY_NETWORK_ID) == null) { - LOG.error( - "getNetworkSupNodeId: No Supporting node at NETWORK layer for node: [{}].", inputNode.getNodeId()); - } else { - tempNetworkSupNodeId = allSupNodes.get(NetworkUtils.UNDERLAY_NETWORK_ID); + private boolean checkOdtuTTPforLoOduCreation(TerminationPoint1 ontTp1, int tsNb) { + XpdrTpPortConnectionAttributes portConAttr = ontTp1.getXpdrTpPortConnectionAttributes(); + if (portConAttr == null + || portConAttr.getTsPool() == null + || portConAttr.getTsPool().size() < tsNb + || portConAttr.getOdtuTpnPool() == null) { + return false; } - return tempNetworkSupNodeId; + return checkFirstOdtuTpn(portConAttr.getOdtuTpnPool().values().stream().findFirst().get()); } - private String getTopoSupNodeId(Node inputNode) { - TreeMap allSupNodes = new TreeMap(); - String tempTopoSupNodeId = ""; - allSupNodes = MapUtils.getAllSupNode(inputNode); - if (allSupNodes.get(NetworkUtils.OVERLAY_NETWORK_ID) == null) { - LOG.error( - "getTopologySupNodeId: No Supporting node at TOPOLOGY layer for node: [{}].", inputNode.getNodeId()); - } else { - tempTopoSupNodeId = allSupNodes.get(NetworkUtils.OVERLAY_NETWORK_ID); + 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()); + // we could also check the administrative status of the tp + if (sic.getIfCapType().equals(SERVICE_TYPE_ETH_CLASS_MAP.get(otnServiceType))) { + return true; + } } - return tempTopoSupNodeId; + return false; } - public void validateAZxponder(String anodeId, String znodeId) { + public void validateXponder(String anodeId, String znodeId) { if (!isValid()) { return; } - if ((this.nodeType != OpenroadmNodeType.MUXPDR) & (this.nodeType != OpenroadmNodeType.SWITCH) - & (this.nodeType != OpenroadmNodeType.TPDR)) { - return; - } - // Detect A and Z, a/znodeId correspond to otn layer, supporting node - // might be of Network or Topology layer - if (this.nodeId.equals(anodeId) || (this.nodeId.equals(znodeId))) { - initXndrTps("AZ"); - if (!this.valid) { - LOG.debug("validateAZxponder: XPONDER unusable for A or Z == {}", nodeId.getValue()); - } else { - LOG.info("validateAZxponder: A or Z node detected and validated == {}", nodeId.getValue()); - } - return; + if (this.nodeId.getValue().equals(anodeId) + || (this.nodeId.getValue().equals(znodeId))) { + initXndrTps(AZ_MODETYPE); + } else if (OpenroadmNodeType.SWITCH.equals(this.nodeType)) { + initXndrTps(INTERMEDIATE_MODETYPE); } else { - LOG.debug("validateAZxponder: XPONDER is ignored == {}", nodeId.getValue()); + LOG.info("validateAZxponder: XPONDER is ignored == {}", nodeId.getValue()); valid = false; } - } - public boolean validateSwitchingPoolBandwidth( - Node node, - 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) { - Long availableBW = 0L; + public boolean validateSwitchingPoolBandwidth(TerminationPoint tp1, TerminationPoint tp2, Long neededBW) { if (this.nodeType != OpenroadmNodeType.TPDR) { return true; - } else { - 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); - SwitchingPools sp = node1.getSwitchingPools(); - List osp = new ArrayList(); - osp = sp.getOduSwitchingPools(); - for (OduSwitchingPools ospx : osp) { - List nbl = ospx.getNonBlockingList(); - for (NonBlockingList nbll : nbl) { - if (nbll.getAvailableInterconnectBandwidth() >= neededBW) { - List tplist = new ArrayList(nbll.getTpList()); - if ((tplist.contains(tp1.getTpId())) & (tplist.contains(tp2.getTpId()))) { - LOG.debug("validateSwitchingPoolBandwidth: couple of tp {} x {} valid for crossconnection", - tp1.getTpId().toString(), tp2.getTpId().toString()); - return true; - } - } + } + for (OduSwitchingPools ospx : + node.augmentation(Node1.class) + .getSwitchingPools() + .nonnullOduSwitchingPools().values()) { + for (NonBlockingList nbll : ospx.nonnullNonBlockingList().values()) { + if (nbll.getAvailableInterconnectBandwidth().toJava() >= neededBW + && nbll.getTpList() != null + && nbll.getTpList().contains(tp1.getTpId()) + && nbll.getTpList().contains(tp2.getTpId())) { + LOG.debug("validateSwitchingPoolBandwidth: couple of tp {} x {} valid for crossconnection", + tp1.getTpId(), tp2.getTpId()); + return true; } - } - LOG.debug("validateSwitchingPoolBandwidth: No valid Switching pool for crossconnecting tp {} and {}", - tp1.getTpId().toString(), tp2.getTpId().toString()); - return false; } - + LOG.debug("validateSwitchingPoolBandwidth: No valid Switching pool for crossconnecting tp {} and {}", + tp1.getTpId(), tp2.getTpId()); + return false; } public void validateIntermediateSwitch() { @@ -372,135 +408,186 @@ public class PceOtnNode extends PceNode { return; } // 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 { + initXndrTps(INTERMEDIATE_MODETYPE); + if (this.valid) { LOG.info("validateIntermediateSwitch: Switch usable for transit == {}", nodeId.getValue()); + } else { + LOG.debug("validateIntermediateSwitch: Switch unusable for transit == {}", nodeId.getValue()); } - return; - } - public boolean checkAvailableTribPort( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks - .network.node.TerminationPoint tp) { - boolean compatibleSupInt = false; - TerminationPoint1 otnTp1 = tp.augmentation(TerminationPoint1.class); - if (otnTp1.getTpType() == OpenroadmTpType.XPONDERNETWORK) { - try { - List otpp = otnTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool(); - - for (OdtuTpnPool otppi : otpp) { - if (otppi.getOdtuType().getClass().equals(ODTU4TsAllocated.class)) { - this.tpAvailableTribPort.put(tp.getTpId().getValue(), otppi.getTpnPool()); - LOG.debug("checkAvailableTribPort: tp {} and his trib Ports have been added to " - + "tpAvailableTribPortMap", tp.getTpId().getValue()); - compatibleSupInt = true; - - } + public void checkAvailableTribPort() { + 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()); } - } catch (NullPointerException e) { - LOG.debug("checkAvailableTribPort: OdtuTpnPool not present for tp {} ", tp.getTpId().toString()); } - - } else { - LOG.debug("checkAvailableTribPort: tp {} has no odtu tpn Pool", tp.getTpId().getValue()); } - return compatibleSupInt; - } - - public boolean checkAvailableTribSlot( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks - .network.node.TerminationPoint tp) { - boolean compatibleSupInt = false; - TerminationPoint1 otnTp1 = tp.augmentation(TerminationPoint1.class); - if (otnTp1.getTpType() == OpenroadmTpType.XPONDERNETWORK) { - List otpp; - try { - otpp = otnTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool(); - - for (OdtuTpnPool otppi : otpp) { - if (otppi.getOdtuType().getClass().equals(ODTU4TsAllocated.class)) { - this.tpAvailableTribSlot.put( - tp.getTpId().getValue(), - otnTp1.getXpdrTpPortConnectionAttributes().getTsPool()); - LOG.debug( - "checkAvailableTribPort: tp {} and its trib Slots were added to tpAvailableTribSlotMap", - tp.getTpId().getValue()); - compatibleSupInt = true; - - } - } + } - } catch (NullPointerException e) { - LOG.debug("checkAvailableTribSlot: OdtuTpnPool not present for tp {} ", tp.getTpId().toString()); + public void checkAvailableTribSlot() { + 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.getTsPool() != null) { + tpAvailableTribSlot.put(tp.getTpId().getValue(), portConAttr.getTsPool()); } - } else { - LOG.debug("checkAvailableTribPort: tp {} is not a network Port", tp.getTpId().getValue()); } - return compatibleSupInt; - } - - public String getXpdrClient(String tp) { - return this.clientPerNwTp.get(tp); - } - - public boolean checkTP(String tp) { - return !((this.usedXpdrNWTps.contains(tp)) || (this.usedXpdrClientTps.contains(tp)) - || (this.unusableXpdrNWTps.contains(tp)) || (this.unusableXpdrClientTps.contains(tp))); } public boolean isValid() { - if ((node == null) || (nodeId == null) || (nodeType == null) || (supNetworkNodeId == null) || (clli == 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 Map getAvailableTps() { - return availableXponderTp; - } - + @Override public void addOutgoingLink(PceLink outLink) { this.outgoingLinks.add(outLink); } + @Override public List getOutgoingLinks() { return outgoingLinks; } - public String getClient(String tp) { - return clientPerNwTp.get(tp); + @Override + public AdminStates getAdminStates() { + return adminStates; } - public String getTopoSupNodeIdPceNode() { - return supTopoNodeId; + @Override + public State getState() { + return state; } - public String getNetworkSupNodeIdPceNode() { - return supNetworkNodeId; - } - - public String getCLLI() { - return clli; + @Override + public String getXpdrClient(String tp) { + return this.clientPerNwTp.get(tp); } + @Override public String toString() { - return "PceNode type=" + nodeType + " ID=" + nodeId.getValue() + " CLLI=" + clli; + return "PceNode type=" + nodeType + " ID=" + nodeId.getValue() + " CLLI=" + this.getSupClliNodeId(); } public void printLinksOfNode() { - LOG.info(" outgoing links of node {} : {} ", nodeId.getValue(), this.getOutgoingLinks().toString()); + LOG.info(" outgoing links of node {} : {} ", nodeId.getValue(), this.getOutgoingLinks()); } - public Map> getAvailableTribPorts() { + @Override + public Map> getAvailableTribPorts() { return tpAvailableTribPort; } - public Map> getAvailableTribSlots() { + @Override + public Map> getAvailableTribSlots() { return tpAvailableTribSlot; } + public List getUsableXpdrNWTps() { + return usableXpdrNWTps; + } + + public List getUsableXpdrClientTps() { + return usableXpdrClientTps; + } + + @Override + public String getPceNodeType() { + return this.pceNodeType; + } + + @Override + public String getSupNetworkNodeId() { + return MapUtils.getSupNetworkNode(this.node); + } + + @Override + public String getSupClliNodeId() { + return MapUtils.getSupClliNode(this.node); + } + + @Override + public String getRdmSrgClient(String tp, String direction) { + return null; + } + + @Override + public NodeId getNodeId() { + return nodeId; + } + + @Override + public boolean checkTP(String tp) { + return false; + } + + /* + * (non-Javadoc) + * + * @see org.opendaylight.transportpce.pce.networkanalyzer.PceNode#getVersion() + */ + @Override + 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; + } }