X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=pce%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fpce%2Fnetworkanalyzer%2FPceOpticalNode.java;h=2c94225b9598d0f2ffa6da7984a8a877242999b7;hb=268165cb2822b6ce4c55f00cac63eed2bb222ec7;hp=63f2bffe0a518ec7ed49a27174695535396b22e4;hpb=07f70fbb64a92a32631820b4f142430bc511c4c9;p=transportpce.git diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOpticalNode.java b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOpticalNode.java index 63f2bffe0..2c94225b9 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOpticalNode.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOpticalNode.java @@ -8,19 +8,31 @@ package org.opendaylight.transportpce.pce.networkanalyzer; +import java.math.BigDecimal; import java.util.ArrayList; +import java.util.Arrays; +import java.util.BitSet; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.TreeMap; +import org.opendaylight.transportpce.common.fixedflex.GridConstant; +import org.opendaylight.transportpce.common.mapping.PortMapping; import org.opendaylight.transportpce.pce.SortPortsByName; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.TerminationPoint1; -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.networks.network.node.termination.point.pp.attributes.UsedWavelength; -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.service.format.rev190531.ServiceFormat; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.Mapping; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.TerminationPoint1; +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.rev211210.Node1; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmNodeType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmTpType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.available.freq.map.AvailFreqMapsKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.IfOCH; +import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.IfOCHOTU4ODU4; +import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.IfOtsiOtsigroup; +import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.SupportedIfCapability; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev191129.ServiceFormat; 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.yangtools.yang.common.Uint16; @@ -32,30 +44,53 @@ public class PceOpticalNode implements PceNode { private boolean valid = true; - private final Node node; - private final NodeId nodeId; - private final OpenroadmNodeType nodeType; - private final ServiceFormat serviceFormat; - private final String pceNodeType; + private Node node; + private NodeId nodeId; + private String deviceNodeId; + private OpenroadmNodeType nodeType; + private AdminStates adminStates; + private State state; + private String serviceType; + private PortMapping portMapping; - // wavelength calculation per node type - private List availableWLindex = new ArrayList<>(); private Map availableSrgPp = new TreeMap<>(); private Map availableSrgCp = new TreeMap<>(); private List usedXpndrNWTps = new ArrayList<>(); private List outgoingLinks = new ArrayList<>(); private Map clientPerNwTp = new HashMap<>(); + private final AvailFreqMapsKey freqMapKey = new AvailFreqMapsKey(GridConstant.C_BAND); + private BitSet frequenciesBitSet; + private String version; + private BigDecimal slotWidthGranularity; + private BigDecimal centralFreqGranularity; - public PceOpticalNode(Node node, OpenroadmNodeType nodeType, NodeId nodeId, ServiceFormat serviceFormat, - String pceNodeType) { - this.node = node; - this.nodeId = nodeId; - this.nodeType = nodeType; - this.serviceFormat = serviceFormat; - this.pceNodeType = pceNodeType; + public PceOpticalNode(String deviceNodeId, String serviceType, PortMapping portMapping, Node node, + OpenroadmNodeType nodeType, String version, BigDecimal slotWidthGranularity, + BigDecimal centralFreqGranularity) { - if ((node == null) || (nodeId == null) || (nodeType == null)) { - LOG.error("PceNode: one of parameters is not populated : nodeId, node type"); + if (deviceNodeId != null + && serviceType != null + && portMapping != null + && node != null + && node.getNodeId() != null + && nodeType != null + && version != null + && slotWidthGranularity != null) { + this.deviceNodeId = deviceNodeId; + this.serviceType = serviceType; + this.portMapping = portMapping; + this.node = node; + this.nodeId = node.getNodeId(); + this.nodeType = nodeType; + this.version = version; + this.slotWidthGranularity = slotWidthGranularity; + this.centralFreqGranularity = centralFreqGranularity; + this.adminStates = node.augmentation(org.opendaylight.yang.gen.v1.http + .org.openroadm.common.network.rev211210.Node1.class).getAdministrativeState(); + this.state = node.augmentation(org.opendaylight.yang.gen.v1.http + .org.openroadm.common.network.rev211210.Node1.class).getOperationalState(); + } else { + LOG.error("PceNode: one of parameters is not populated : nodeId, node type, slot width granularity"); this.valid = false; } } @@ -71,8 +106,8 @@ public class PceOpticalNode implements PceNode { this.node.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang .ietf.network.topology.rev180226.Node1.class); List allTps = nodeTp.getTerminationPoint(); - if (allTps == null) { + .node.TerminationPoint> allTps = new ArrayList<>(nodeTp.nonnullTerminationPoint().values()); + if (allTps.isEmpty()) { LOG.error("initSrgTpList: ROADM TerminationPoint list is empty for node {}", this); this.valid = false; return; @@ -80,9 +115,9 @@ public class PceOpticalNode implements PceNode { for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network .node.TerminationPoint tp : allTps) { TerminationPoint1 cntp1 = tp.augmentation(TerminationPoint1.class); - org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.TerminationPoint1 nttp1 = tp - .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130 - .TerminationPoint1.class); + org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.TerminationPoint1 nttp1 = tp + .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210 + .TerminationPoint1.class); OpenroadmTpType type = cntp1.getTpType(); LOG.info("type = {} for tp {}", type.getName(), tp); @@ -90,26 +125,22 @@ public class PceOpticalNode implements PceNode { case SRGTXRXCP: case SRGRXCP: case SRGTXCP: - LOG.info("initSrgTpList: adding SRG-CP tp = {} ", tp.getTpId().getValue()); - this.availableSrgCp.put(tp.getTpId().getValue(), cntp1.getTpType()); + if (State.InService.equals(cntp1.getOperationalState())) { + LOG.info("initSrgTpList: adding SRG-CP tp = {} ", tp.getTpId().getValue()); + this.availableSrgCp.put(tp.getTpId().getValue(), cntp1.getTpType()); + } break; case SRGRXPP: case SRGTXPP: case SRGTXRXPP: - boolean used = true; LOG.info("initSrgTpList: SRG-PP tp = {} found", tp.getTpId().getValue()); - try { - List usedWavelengths = nttp1.getPpAttributes().getUsedWavelength(); - if (usedWavelengths.isEmpty()) { - used = false; - } - } catch (NullPointerException e) { - LOG.warn("initSrgTpList: 'usedWavelengths' for tp={} is null !", tp.getTpId().getValue()); - used = false; - } - if (!used) { + if (isTerminationPointAvailable(nttp1)) { LOG.info("initSrgTpList: adding SRG-PP tp '{}'", tp.getTpId().getValue()); this.availableSrgPp.put(tp.getTpId().getValue(), cntp1.getTpType()); + if (State.InService.equals(cntp1.getOperationalState())) { + LOG.info("initSrgTpList: adding SRG-PP tp '{}'", tp.getTpId().getValue()); + this.availableSrgPp.put(tp.getTpId().getValue(), cntp1.getTpType()); + } } else { LOG.warn("initSrgTpList: SRG-PP tp = {} found is busy !!", tp.getTpId().getValue()); } @@ -127,60 +158,100 @@ public class PceOpticalNode implements PceNode { this.availableSrgPp.size(), this.availableSrgCp.size(), this); } - public void initWLlist() { - this.availableWLindex.clear(); + private boolean isTerminationPointAvailable( + org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.TerminationPoint1 nttp1) { + byte[] availableByteArray = new byte[GridConstant.NB_OCTECTS]; + Arrays.fill(availableByteArray, (byte) GridConstant.AVAILABLE_SLOT_VALUE); + return nttp1 == null || nttp1.getPpAttributes() == null + || nttp1.getPpAttributes().getAvailFreqMaps() == null + || !nttp1.getPpAttributes().getAvailFreqMaps().containsKey(freqMapKey) + || nttp1.getPpAttributes().getAvailFreqMaps().get(freqMapKey).getFreqMap() == null + || Arrays.equals(nttp1.getPpAttributes().getAvailFreqMaps().get(freqMapKey).getFreqMap(), + availableByteArray); + } + + private boolean isTpWithGoodCapabilities( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node + .TerminationPoint tp) { + Mapping mapping = this.portMapping.getMapping(deviceNodeId, tp.getTpId().getValue()); + if (mapping == null || mapping.getSupportedInterfaceCapability() == null) { + return true; + } + switch (this.serviceType) { + case "400GE": + for (Class ifCap : mapping.getSupportedInterfaceCapability()) { + if (ifCap.equals(IfOtsiOtsigroup.class)) { + return true; + } + } + return false; + case "100GE": + if (mapping.getSupportedInterfaceCapability().contains(IfOCH.class) + || mapping.getSupportedInterfaceCapability().contains(IfOCHOTU4ODU4.class)) { + return true; + } else { + return false; + } + default: + return true; + } + } + + public void initFrequenciesBitSet() { if (!isValid()) { return; } Node1 node1 = this.node.augmentation(Node1.class); + org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Node1 node11 = + this.node.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Node1 + .class); switch (this.nodeType) { case SRG : - List srgAvailableWL = - node1.getSrgAttributes().getAvailableWavelengths(); - if (srgAvailableWL == null) { + if (!State.InService.equals(node11.getOperationalState())) { this.valid = false; - LOG.error("initWLlist: SRG AvailableWavelengths is empty for node {}", this); + LOG.error("initWLlist: SRG node {} is OOS/degraded", this); return; } - for (org.opendaylight.yang.gen.v1.http.org.openroadm.srg.rev181130.srg.node.attributes - .AvailableWavelengths awl : srgAvailableWL) { - this.availableWLindex.add(awl.getIndex().toJava()); - LOG.debug("initWLlist: SRG next = {} in {}", awl.getIndex(), this); + if (!node1.getSrgAttributes().nonnullAvailFreqMaps().containsKey(freqMapKey)) { + LOG.error("initFrequenciesBitSet: SRG no cband available freq maps for node {}", this); + this.valid = false; + return; } + this.frequenciesBitSet = BitSet.valueOf(node1.getSrgAttributes() + .nonnullAvailFreqMaps().get(freqMapKey).getFreqMap()); break; case DEGREE : - List degAvailableWL = node1.getDegreeAttributes().getAvailableWavelengths(); - if (degAvailableWL == null) { + if (!State.InService.equals(node11.getOperationalState())) { this.valid = false; - LOG.error("initWLlist: DEG AvailableWavelengths is empty for node {}", this); + LOG.error("initWLlist: Degree node {} is OOS/degraded", this); return; } - for (org.opendaylight.yang.gen.v1.http.org.openroadm.degree.rev181130.degree.node.attributes - .AvailableWavelengths awl : degAvailableWL) { - this.availableWLindex.add(awl.getIndex().toJava()); - LOG.debug("initWLlist: DEGREE next = {} in {}", awl.getIndex(), this); + if (!node1.getDegreeAttributes().nonnullAvailFreqMaps().containsKey(freqMapKey)) { + LOG.error("initFrequenciesBitSet: DEG no cband available freq maps for node {}", this); + this.valid = false; + return; } + this.frequenciesBitSet = BitSet.valueOf(node1.getDegreeAttributes() + .nonnullAvailFreqMaps().get(freqMapKey).getFreqMap()); break; case XPONDER : - // HARD CODED 96 - for (long i = 1; i <= 96; i++) { - this.availableWLindex.add(i); + // at init all bits are set to false (unavailable) + this.frequenciesBitSet = new BitSet(GridConstant.EFFECTIVE_BITS); + //set all bits to true (available) + this.frequenciesBitSet.set(0, GridConstant.EFFECTIVE_BITS); + if (!State.InService.equals(node11.getOperationalState())) { + this.valid = false; + LOG.error("initWLlist: XPDR node {} is OOS/degraded", this); + return; } break; default: - LOG.error("initWLlist: unsupported node type {} in node {}", this.nodeType, this); + LOG.error("initFrequenciesBitSet: unsupported node type {} in node {}", this.nodeType, this); break; } - if (this.availableWLindex.isEmpty()) { - LOG.debug("initWLlist: There are no available wavelengths in node {}", this); - this.valid = false; - } - LOG.debug("initWLlist: availableWLindex size = {} in {}", this.availableWLindex.size(), this); } - public void initXndrTps() { + public void initXndrTps(ServiceFormat serviceFormat) { LOG.info("PceNod: initXndrTps for node : {}", this.nodeId); if (!isValid()) { return; @@ -189,8 +260,8 @@ public class PceOpticalNode implements PceNode { this.node.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang .ietf.network.topology.rev180226.Node1.class); List allTps = nodeTp.getTerminationPoint(); - if (allTps == null) { + .node.TerminationPoint> allTps = new ArrayList<>(nodeTp.nonnullTerminationPoint().values()); + if (allTps.isEmpty()) { this.valid = false; LOG.error("initXndrTps: XPONDER TerminationPoint list is empty for node {}", this); return; @@ -199,35 +270,40 @@ public class PceOpticalNode implements PceNode { for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network .node.TerminationPoint tp : allTps) { TerminationPoint1 cntp1 = tp.augmentation(TerminationPoint1.class); - org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.TerminationPoint1 nttp1 = tp - .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130 + if (cntp1.getTpType() != OpenroadmTpType.XPONDERNETWORK) { + LOG.warn("initXndrTps: {} is not an Xponder network port", cntp1.getTpType().getName()); + continue; + } + if (!isTpWithGoodCapabilities(tp)) { + LOG.warn("initXndrTps: {} network port has not correct if-capabilities", tp.getTpId().getValue()); + continue; + } + if (!State.InService.equals(cntp1.getOperationalState())) { + LOG.warn("initXndrTps: XPONDER tp = {} is OOS/degraded", tp.getTpId().getValue()); + this.valid = false; + continue; + } + org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.TerminationPoint1 nttp1 = tp + .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210 .TerminationPoint1.class); - if (cntp1.getTpType() == OpenroadmTpType.XPONDERNETWORK) { - if (nttp1 != null && nttp1.getXpdrNetworkAttributes().getWavelength() != null) { - this.usedXpndrNWTps.add(tp.getTpId().getValue()); - LOG.info("initXndrTps: XPONDER tp = {} is used", tp.getTpId().getValue()); - } else { - this.valid = true; - } - // find Client of this network TP - String client; - org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.TerminationPoint1 tpceTp1 = - tp.augmentation(org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129 - .TerminationPoint1.class); - if (tpceTp1 != null) { - client = tpceTp1.getAssociatedConnectionMapPort(); - if (client != null) { - this.clientPerNwTp.put(tp.getTpId().getValue(), client); - this.valid = true; - } else { - LOG.error("initXndrTps: XPONDER {} NW TP doesn't have defined Client {}", - this, tp.getTpId().getValue()); - } - } else if (ServiceFormat.OTU.equals(this.serviceFormat)) { - LOG.info("Infrastructure OTU4 connection"); + if (nttp1 != null && nttp1.getXpdrNetworkAttributes().getWavelength() != null) { + this.usedXpndrNWTps.add(tp.getTpId().getValue()); + LOG.info("initXndrTps: XPONDER tp = {} is used", tp.getTpId().getValue()); + } else { + this.valid = true; + } + // find Client of this network TP + String client; + org.opendaylight.yang.gen.v1.http.transportpce.topology.rev220123.TerminationPoint1 tpceTp1 = + tp.augmentation(org.opendaylight.yang.gen.v1.http.transportpce.topology.rev220123 + .TerminationPoint1.class); + if (tpceTp1 != null) { + client = tpceTp1.getAssociatedConnectionMapPort(); + if (client != null) { + this.clientPerNwTp.put(tp.getTpId().getValue(), client); this.valid = true; } else { - LOG.error("Service Format {} not managed yet", this.serviceFormat.getName()); + LOG.error("Service Format {} not managed yet", serviceFormat.getName()); } } } @@ -237,7 +313,7 @@ public class PceOpticalNode implements PceNode { } @Override - public String getRdmSrgClient(String tp) { + public String getRdmSrgClient(String tp, String direction) { LOG.info("getRdmSrgClient: Getting PP client for tp '{}' on node : {}", tp, this.nodeId); OpenroadmTpType srgType = null; OpenroadmTpType cpType = this.availableSrgCp.get(tp); @@ -248,7 +324,16 @@ public class PceOpticalNode implements PceNode { switch (cpType) { case SRGTXRXCP: LOG.info("getRdmSrgClient: Getting BI Directional PP port ..."); - srgType = OpenroadmTpType.SRGTXRXPP; + // Take the first-element in the available PP key set + if (availableSrgPp.entrySet().iterator().next().getKey() + // and check if the port is bidirectional + .contains("TXRX")) { + srgType = OpenroadmTpType.SRGTXRXPP; + } else if (direction.equalsIgnoreCase("aToz")) { + srgType = OpenroadmTpType.SRGRXPP; + } else { + srgType = OpenroadmTpType.SRGTXPP; + } break; case SRGTXCP: LOG.info("getRdmSrgClient: Getting UNI Rx PP port ..."); @@ -283,7 +368,7 @@ public class PceOpticalNode implements PceNode { } - public void validateAZxponder(String anodeId, String znodeId) { + public void validateAZxponder(String anodeId, String znodeId, ServiceFormat serviceFormat) { if (!isValid()) { return; } @@ -291,9 +376,9 @@ public class PceOpticalNode implements PceNode { return; } // Detect A and Z - if (this.getSupNetworkNodeId().equals(anodeId) || (this.getSupNetworkNodeId().equals(znodeId))) { + if (anodeId.contains(this.getSupNetworkNodeId()) || (znodeId.contains(this.getSupNetworkNodeId()))) { LOG.info("validateAZxponder: A or Z node detected == {}", nodeId.getValue()); - initXndrTps(); + initXndrTps(serviceFormat); return; } LOG.debug("validateAZxponder: XPONDER is ignored == {}", nodeId.getValue()); @@ -305,15 +390,11 @@ public class PceOpticalNode implements PceNode { return !this.usedXpndrNWTps.contains(tp); } - @Override - public boolean checkWL(long index) { - return (this.availableWLindex.contains(index)); - } - public boolean isValid() { 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"); + || this.getSupClliNodeId() == null || adminStates == null || state == null) { + LOG.error("PceNode: one of parameters is not populated : nodeId, node type, supporting nodeId, " + + "admin state, operational state"); valid = false; } return valid; @@ -324,6 +405,16 @@ public class PceOpticalNode implements PceNode { return outgoingLinks; } + @Override + public AdminStates getAdminStates() { + return adminStates; + } + + @Override + public State getState() { + return state; + } + @Override public NodeId getNodeId() { return nodeId; @@ -336,7 +427,7 @@ public class PceOpticalNode implements PceNode { @Override public String getPceNodeType() { - return this.pceNodeType; + return "optical"; } @Override @@ -368,4 +459,45 @@ public class PceOpticalNode implements PceNode { public Map> getAvailableTribSlots() { return null; } + + /* + * (non-Javadoc) + * + * @see org.opendaylight.transportpce.pce.networkanalyzer.PceNode#getBitSetData() + */ + @Override + public BitSet getBitSetData() { + return this.frequenciesBitSet; + } + + /* + * (non-Javadoc) + * + * @see org.opendaylight.transportpce.pce.networkanalyzer.PceNode#getVersion() + */ + @Override + public String getVersion() { + return this.version; + } + + /* + * (non-Javadoc) + * + * @see org.opendaylight.transportpce.pce.networkanalyzer.PceNode#getSlotWidthGranularity() + */ + @Override + public BigDecimal getSlotWidthGranularity() { + return slotWidthGranularity; + } + + /* + * (non-Javadoc) + * + * @see org.opendaylight.transportpce.pce.networkanalyzer.PceNode#getCentralFreqGranularity() + */ + @Override + public BigDecimal getCentralFreqGranularity() { + return centralFreqGranularity; + } + }