[ONOS-7740] Support lldp-port-description message during link discovery with Juniper
Change-Id: I6f399eb2565ac3a7ba5b41d0e1ea25ab59986bc5
diff --git a/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/JuniperUtils.java b/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/JuniperUtils.java
index e283f3a..60baded 100644
--- a/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/JuniperUtils.java
+++ b/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/JuniperUtils.java
@@ -105,6 +105,7 @@
private static final String LLDP_LO_PORT = "lldp-local-port-id";
private static final String LLDP_REM_CHASS = "lldp-remote-chassis-id";
private static final String LLDP_REM_PORT = "lldp-remote-port-id";
+ private static final String LLDP_REM_PORT_DES = "lldp-remote-port-description";
private static final String REGEX_ADD =
".*Private base address\\s*([:,0-9,a-f,A-F]*).*";
private static final Pattern ADD_PATTERN =
@@ -525,11 +526,13 @@
MacAddress mac = MacAddress.valueOf(
neighbor.getString(LLDP_REM_CHASS));
long remotePortIndex =
- neighbor.getInt(LLDP_REM_PORT);
+ neighbor.getInt(LLDP_REM_PORT, -1);
+ String remotePortDescription = neighbor.getString(LLDP_REM_PORT_DES, null);
LinkAbstraction link = new LinkAbstraction(
localPortName,
mac.toLong(),
- remotePortIndex);
+ remotePortIndex,
+ remotePortDescription);
neighbour.add(link);
}
}
@@ -543,11 +546,13 @@
protected String localPortName;
protected ChassisId remoteChassisId;
protected long remotePortIndex;
+ protected String remotePortDescription;
- protected LinkAbstraction(String pName, long chassisId, long pIndex) {
+ protected LinkAbstraction(String pName, long chassisId, long pIndex, String pDescription) {
this.localPortName = pName;
this.remoteChassisId = new ChassisId(chassisId);
this.remotePortIndex = pIndex;
+ this.remotePortDescription = pDescription;
}
}
diff --git a/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/LinkDiscoveryJuniperImpl.java b/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/LinkDiscoveryJuniperImpl.java
index 613f6d4..af93653 100644
--- a/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/LinkDiscoveryJuniperImpl.java
+++ b/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/LinkDiscoveryJuniperImpl.java
@@ -19,6 +19,7 @@
import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
+import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Port;
@@ -109,15 +110,18 @@
//find destination port by interface index
Optional<Port> remotePort = deviceService.getPorts(remoteDevice.id())
.stream().filter(port -> {
- if (port.number().toLong()
- == linkAbs.remotePortIndex) {
+ if (port.number().toLong() == linkAbs.remotePortIndex) {
+ return true;
+ }
+ if (port.annotations().value(AnnotationKeys.PORT_NAME) != null
+ && port.annotations().value(AnnotationKeys.PORT_NAME).equals(linkAbs.remotePortDescription)) {
return true;
}
return false;
}).findAny();
if (!remotePort.isPresent()) {
- log.warn("Port number {} does not exist in device {}",
- linkAbs.remotePortIndex, remoteDevice.id());
+ log.warn("Port number {} and Port description {} do not exist in device {}",
+ linkAbs.remotePortIndex, linkAbs.remotePortDescription, remoteDevice.id());
continue;
}