PCE OTN layer support init
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / networkanalyzer / PceLink.java
index 58215e8f29513d170fe34ed6c1ef8c934869ef8d..9929b4dc02ba90e0e6052372056dc41b2ca33c8e 100644 (file)
@@ -30,6 +30,8 @@ public class PceLink {
      */
     double weight = 0;
     private boolean isValid = true;
+    private boolean isOtnValid = true;
+
     // this member is for XPONDER INPUT/OUTPUT links.
     // it keeps name of client corresponding to NETWORK TP
     private String client = "";
@@ -41,10 +43,13 @@ public class PceLink {
     private final Object destTP;
     private final String sourceSupNodeId;
     private final String destSupNodeId;
+    private final String sourceNetworkSupNodeId;
+    private final String destNetworkSupNodeId;
     private final String sourceCLLI;
     private final String destCLLI;
     private final LinkId oppositeLink;
     private final Long latency;
+    private final Long availableBandwidth;
     private final List<Long> srlgList;
     private final double osnr;
     private final Span omsAttributesSpan;
@@ -67,9 +72,11 @@ public class PceLink {
 
         this.sourceSupNodeId = source.getSupNodeIdPceNode();
         this.destSupNodeId = dest.getSupNodeIdPceNode();
+        this.sourceNetworkSupNodeId = source.getSupNetworkNodeIdPceNode();
+        this.destNetworkSupNodeId = dest.getSupNetworkNodeIdPceNode();
 
-        this.sourceCLLI = source.getCLLI();
-        this.destCLLI = dest.getCLLI();
+        this.sourceCLLI = source.getClliSupNodeId();
+        this.destCLLI = dest.getClliSupNodeId();
 
         this.linkType = MapUtils.calcType(link);
 
@@ -80,13 +87,20 @@ public class PceLink {
             this.srlgList = MapUtils.getSRLG(link);
             this.latency = calcLatency(link);
             this.osnr = calcSpanOSNR();
+            this.availableBandwidth = 0L;
+        } else if (this.linkType == OpenroadmLinkType.OTNLINK) {
+            this.availableBandwidth = MapUtils.getAvailableBandwidth(link);
+            this.srlgList = MapUtils.getSRLGfromLink(link);
+            this.osnr = 0.0;
+            this.latency = 0L;
+            this.omsAttributesSpan = null;
         } else {
             this.omsAttributesSpan = null;
             this.srlgList = null;
             this.latency = 0L;
             this.osnr = 100L; //infinite OSNR in DB
+            this.availableBandwidth = 0L;
         }
-
         LOG.debug("PceLink: created PceLink  {}", toString());
     }
 
@@ -210,14 +224,27 @@ public class PceLink {
         return latency.doubleValue();
     }
 
+    public Long getAvailableBandwidth() {
+        return availableBandwidth;
+    }
+
+
     public String getsourceSupNodeId() {
         return sourceSupNodeId;
     }
 
+    public String getsourceNetworkSupNodeId() {
+        return sourceNetworkSupNodeId;
+    }
+
     public String getdestSupNodeId() {
         return destSupNodeId;
     }
 
+    public String getdestNetworkSupNodeId() {
+        return destNetworkSupNodeId;
+    }
+
     public List<Long> getsrlgList() {
         return srlgList;
     }
@@ -265,6 +292,62 @@ public class PceLink {
         return isValid;
     }
 
+    public boolean isOtnValid(Link link, String oduType) {
+        if (this.linkType == OpenroadmLinkType.OTNLINK) {
+            isOtnValid = false;
+            Long availableBW = MapUtils.getAvailableBandwidth(link);
+            if ((availableBW == 0L) || (availableBW == null)) {
+                LOG.error("PceLink: No bandwidth available or not valid OTN Link, Link {}  is ignored ", linkId);
+            } else if (("ODU4".equals(oduType)) && (availableBW == 100000L)) {
+                isOtnValid = true;
+                LOG.debug("PceLink: Selected OTU4 Link {} is eligible for ODU creation OTN Link", linkId);
+            } else if (("ODU2".equals(oduType)) || ("ODU2e".equals(oduType)) && (availableBW >= 12500L)) {
+                isOtnValid = true;
+                LOG.debug("PceLink: Selected ODU4 Link {} has available bandwidth and is eligible for {} creation ",
+                    linkId, oduType);
+            } else if (("ODU0".equals(oduType)) && (availableBW >= 1250L)) {
+                isOtnValid = true;
+                LOG.debug("PceLink: Selected ODU4 Link {} has available bandwidth and is eligible for {} creation ",
+                    linkId, oduType);
+            } else if (("ODU1".equals(oduType)) && (availableBW >= 2500L)) {
+                isOtnValid = true;
+                LOG.debug("PceLink: Selected ODU4 Link {} has available bandwidth and is eligible for {} creation ",
+                    linkId, oduType);
+            } else {
+                isOtnValid = false;
+                LOG.error(
+                    "PceLink: Selected OTN Link {} is not eligible for ODU creation: not enough available bandwidth",
+                    linkId);
+            }
+
+        } else {
+            isOtnValid = false;
+            LOG.error("PceLink: Not an OTN link. Link is ignored {}", linkId);
+        }
+
+        if ((this.linkId == null) || (this.linkType == null)
+                || (this.oppositeLink == null)) {
+            isOtnValid = false;
+            LOG.error("PceLink: No Link type or opposite link is available. Link is ignored {}", linkId);
+        }
+        if ((this.sourceId == null) || (this.destId == null)
+                || (this.sourceTP == null) || (this.destTP == null)) {
+            isOtnValid = false;
+            LOG.error("PceLink: No Link source or destination is available. Link is ignored {}", linkId);
+        }
+        if ((this.sourceNetworkSupNodeId.equals("")) || (this.destNetworkSupNodeId.equals(""))) {
+            isOtnValid = false;
+            LOG.error("PceLink: No Link source SuppNodeID or destination SuppNodeID is available. Link is ignored {}",
+                linkId);
+        }
+        if ((this.sourceCLLI.equals("")) || (this.destCLLI.equals(""))) {
+            isOtnValid = false;
+            LOG.error("PceLink: No Link source CLLI or destination CLLI is available. Link is ignored {}", linkId);
+        }
+
+        return isOtnValid;
+    }
+
     public String toString() {
         return "PceLink type=" + linkType + " ID=" + linkId.getValue() + " latency=" + latency;
     }