Changed LOCAL port number in the CLI to "local".
Change-Id: Ic24442446a225bbc52613ce6c26b5ecaf7697193
Showing
1 changed file
with
8 additions
and
2 deletions
... | @@ -25,6 +25,7 @@ import org.apache.karaf.shell.commands.Option; | ... | @@ -25,6 +25,7 @@ import org.apache.karaf.shell.commands.Option; |
25 | import org.onlab.onos.cli.Comparators; | 25 | import org.onlab.onos.cli.Comparators; |
26 | import org.onlab.onos.net.Device; | 26 | import org.onlab.onos.net.Device; |
27 | import org.onlab.onos.net.Port; | 27 | import org.onlab.onos.net.Port; |
28 | +import org.onlab.onos.net.PortNumber; | ||
28 | import org.onlab.onos.net.device.DeviceService; | 29 | import org.onlab.onos.net.device.DeviceService; |
29 | 30 | ||
30 | import java.util.ArrayList; | 31 | import java.util.ArrayList; |
... | @@ -108,7 +109,7 @@ public class DevicePortsListCommand extends DevicesListCommand { | ... | @@ -108,7 +109,7 @@ public class DevicePortsListCommand extends DevicesListCommand { |
108 | for (Port port : service.getPorts(device.id())) { | 109 | for (Port port : service.getPorts(device.id())) { |
109 | if (isIncluded(port)) { | 110 | if (isIncluded(port)) { |
110 | ports.add(mapper.createObjectNode() | 111 | ports.add(mapper.createObjectNode() |
111 | - .put("port", port.number().toString()) | 112 | + .put("port", portName(port.number())) |
112 | .put("isEnabled", port.isEnabled()) | 113 | .put("isEnabled", port.isEnabled()) |
113 | .put("type", port.type().toString().toLowerCase()) | 114 | .put("type", port.type().toString().toLowerCase()) |
114 | .put("portSpeed", port.portSpeed()) | 115 | .put("portSpeed", port.portSpeed()) |
... | @@ -120,6 +121,10 @@ public class DevicePortsListCommand extends DevicesListCommand { | ... | @@ -120,6 +121,10 @@ public class DevicePortsListCommand extends DevicesListCommand { |
120 | return result; | 121 | return result; |
121 | } | 122 | } |
122 | 123 | ||
124 | + private String portName(PortNumber port) { | ||
125 | + return port.equals(PortNumber.LOCAL) ? "local" : port.toString(); | ||
126 | + } | ||
127 | + | ||
123 | // Determines if a port should be included in output. | 128 | // Determines if a port should be included in output. |
124 | private boolean isIncluded(Port port) { | 129 | private boolean isIncluded(Port port) { |
125 | return enabled && port.isEnabled() || disabled && !port.isEnabled() || | 130 | return enabled && port.isEnabled() || disabled && !port.isEnabled() || |
... | @@ -133,7 +138,8 @@ public class DevicePortsListCommand extends DevicesListCommand { | ... | @@ -133,7 +138,8 @@ public class DevicePortsListCommand extends DevicesListCommand { |
133 | Collections.sort(ports, Comparators.PORT_COMPARATOR); | 138 | Collections.sort(ports, Comparators.PORT_COMPARATOR); |
134 | for (Port port : ports) { | 139 | for (Port port : ports) { |
135 | if (isIncluded(port)) { | 140 | if (isIncluded(port)) { |
136 | - print(FMT, port.number(), port.isEnabled() ? "enabled" : "disabled", | 141 | + print(FMT, portName(port.number()), |
142 | + port.isEnabled() ? "enabled" : "disabled", | ||
137 | port.type().toString().toLowerCase(), port.portSpeed(), | 143 | port.type().toString().toLowerCase(), port.portSpeed(), |
138 | annotations(port.annotations())); | 144 | annotations(port.annotations())); |
139 | } | 145 | } | ... | ... |
-
Please register or login to post a comment