Changed LOCAL port number in the CLI to "local".
Change-Id: Ic24442446a225bbc52613ce6c26b5ecaf7697193
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/DevicePortsListCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/DevicePortsListCommand.java
index 1d32aa5..29452f7 100644
--- a/cli/src/main/java/org/onlab/onos/cli/net/DevicePortsListCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/net/DevicePortsListCommand.java
@@ -25,6 +25,7 @@
import org.onlab.onos.cli.Comparators;
import org.onlab.onos.net.Device;
import org.onlab.onos.net.Port;
+import org.onlab.onos.net.PortNumber;
import org.onlab.onos.net.device.DeviceService;
import java.util.ArrayList;
@@ -108,7 +109,7 @@
for (Port port : service.getPorts(device.id())) {
if (isIncluded(port)) {
ports.add(mapper.createObjectNode()
- .put("port", port.number().toString())
+ .put("port", portName(port.number()))
.put("isEnabled", port.isEnabled())
.put("type", port.type().toString().toLowerCase())
.put("portSpeed", port.portSpeed())
@@ -120,6 +121,10 @@
return result;
}
+ private String portName(PortNumber port) {
+ return port.equals(PortNumber.LOCAL) ? "local" : port.toString();
+ }
+
// Determines if a port should be included in output.
private boolean isIncluded(Port port) {
return enabled && port.isEnabled() || disabled && !port.isEnabled() ||
@@ -133,7 +138,8 @@
Collections.sort(ports, Comparators.PORT_COMPARATOR);
for (Port port : ports) {
if (isIncluded(port)) {
- print(FMT, port.number(), port.isEnabled() ? "enabled" : "disabled",
+ print(FMT, portName(port.number()),
+ port.isEnabled() ? "enabled" : "disabled",
port.type().toString().toLowerCase(), port.portSpeed(),
annotations(port.annotations()));
}