[SDFAB-615] Inconsistent format of port number in links
This is affecting also the gui which is not able to
recognize links as bidirectional
Change-Id: Ic93cd93efb82485daed4f1cdc6d9e2e6262e6d99
(cherry picked from commit e46c4acbdfd832f1f1c099086a49ae9d06a5411a)
diff --git a/providers/lldpcommon/src/main/java/org/onosproject/provider/lldpcommon/LinkDiscovery.java b/providers/lldpcommon/src/main/java/org/onosproject/provider/lldpcommon/LinkDiscovery.java
index 630b30d..eb8df9d 100644
--- a/providers/lldpcommon/src/main/java/org/onosproject/provider/lldpcommon/LinkDiscovery.java
+++ b/providers/lldpcommon/src/main/java/org/onosproject/provider/lldpcommon/LinkDiscovery.java
@@ -223,7 +223,7 @@
DeviceId srcDeviceId = DeviceId.deviceId(idString);
DeviceId dstDeviceId = packetContext.inPacket().receivedFrom().deviceId();
- ConnectPoint src = new ConnectPoint(srcDeviceId, srcPort);
+ ConnectPoint src = translateSwitchPort(srcDeviceId, srcPort);
ConnectPoint dst = new ConnectPoint(dstDeviceId, dstPort);
LinkDescription ld = new DefaultLinkDescription(src, dst, lt);
@@ -477,4 +477,14 @@
public boolean containsPort(long portNumber) {
return portMap.containsKey(portNumber);
}
+
+ /* Port number created from ONOS lldp does not have port name
+ we use the device service as translation service */
+ private ConnectPoint translateSwitchPort(DeviceId deviceId, PortNumber portNumber) {
+ Port devicePort = this.context.deviceService().getPort(deviceId, portNumber);
+ if (devicePort != null) {
+ return new ConnectPoint(deviceId, devicePort.number());
+ }
+ return new ConnectPoint(deviceId, portNumber);
+ }
}