Calculate spanloss crashes when OTS is not present
[transportpce.git] / olm / src / main / java / org / opendaylight / transportpce / olm / service / OlmPowerServiceImpl.java
index 15a37d94e0f7acd192e93b2a11b946f9b224b0dc..0dcf6f1481e9529d64cd607eb3518096250cfda8 100644 (file)
@@ -523,6 +523,10 @@ public class OlmPowerServiceImpl implements OlmPowerService {
             String destTpId = link.getDestTpid();
             OtsPmHolder srcOtsPmHoler = getPmMeasurements(sourceNodeId, sourceTpId, "OpticalPowerOutput");
             OtsPmHolder destOtsPmHoler = getPmMeasurements(destNodeId, destTpId, "OpticalPowerInput");
+            if (srcOtsPmHoler.getOtsInterfaceName() == null || destOtsPmHoler.getOtsInterfaceName() == null) {
+                LOG.warn("OTS is not present for the link {}", link);
+                continue;
+            }
             spanLoss = new BigDecimal(srcOtsPmHoler.getOtsParameterVal() - destOtsPmHoler.getOtsParameterVal())
                 .setScale(0, RoundingMode.HALF_UP);
             LOG.info("Spanloss Calculated as :{}={}-{}",