Minor improvement dealing with Port
- include annotations in DefaultPort#toString()
- add method to retrieve a Port using ConnectPoint
Change-Id: I75f24e53235f46fa8deeb62b55bec2ecafae907c
diff --git a/core/api/src/main/java/org/onosproject/net/DefaultPort.java b/core/api/src/main/java/org/onosproject/net/DefaultPort.java
index 85e2de1..70023cc 100644
--- a/core/api/src/main/java/org/onosproject/net/DefaultPort.java
+++ b/core/api/src/main/java/org/onosproject/net/DefaultPort.java
@@ -121,6 +121,7 @@
.add("isEnabled", isEnabled)
.add("type", type)
.add("portSpeed", portSpeed)
+ .add("annotations", annotations())
.toString();
}
diff --git a/core/api/src/main/java/org/onosproject/net/device/DeviceService.java b/core/api/src/main/java/org/onosproject/net/device/DeviceService.java
index ce988c5..290f7d7 100644
--- a/core/api/src/main/java/org/onosproject/net/device/DeviceService.java
+++ b/core/api/src/main/java/org/onosproject/net/device/DeviceService.java
@@ -16,6 +16,7 @@
package org.onosproject.net.device;
import org.onosproject.event.ListenerService;
+import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.MastershipRole;
@@ -144,6 +145,16 @@
Port getPort(DeviceId deviceId, PortNumber portNumber);
/**
+ * Returns the port with the specified connect point.
+ *
+ * @param cp connect point
+ * @return device port
+ */
+ default Port getPort(ConnectPoint cp) {
+ return getPort(cp.deviceId(), cp.port());
+ }
+
+ /**
* Indicates whether or not the device is presently online and available.
* Availability, unlike reachability, denotes whether ANY node in the
* cluster can discover that this device is in an operational state,