VOL-2904 : Getting NNI port from device services which matches with 'NNI-' string
Change-Id: I2b335e5555a359879d76075021ada9cfadd50d99
diff --git a/app/src/main/java/org/opencord/olt/impl/Olt.java b/app/src/main/java/org/opencord/olt/impl/Olt.java
index 1e103e2..df4b4db 100644
--- a/app/src/main/java/org/opencord/olt/impl/Olt.java
+++ b/app/src/main/java/org/opencord/olt/impl/Olt.java
@@ -850,11 +850,13 @@
return null;
}
// Return the port that has been configured as the uplink port of this OLT in Sadis
- for (Port p : deviceService.getPorts(dev.id())) {
- if (p.number().toLong() == deviceInfo.uplinkPort()) {
- log.trace("getUplinkPort: Found port {}", p);
- return p;
- }
+ Optional<Port> optionalPort = deviceService.getPorts(dev.id()).stream()
+ .filter(port -> isNniPort(port) ||
+ (port.number().toLong() == deviceInfo.uplinkPort()))
+ .findFirst();
+ if (optionalPort.isPresent()) {
+ log.trace("getUplinkPort: Found port {}", optionalPort.get());
+ return optionalPort.get();
}
log.warn("getUplinkPort: " + NO_UPLINK_PORT, dev.id());
@@ -923,6 +925,13 @@
return nodeId.equals(clusterService.getLocalNode().id());
}
+ private boolean isNniPort(Port port) {
+ if (port.annotations().keys().contains(AnnotationKeys.PORT_NAME)) {
+ return port.annotations().value(AnnotationKeys.PORT_NAME).contains(NNI);
+ }
+ return false;
+ }
+
private class InternalDeviceListener implements DeviceListener {
private Set<DeviceId> programmedDevices = Sets.newConcurrentHashSet();