Adding driver information and short version to cli print of devices and hosts
Change-Id: I1ab9e9865c499240256aa72760b225976e0f19d2
diff --git a/cli/src/main/java/org/onosproject/cli/net/HostsListCommand.java b/cli/src/main/java/org/onosproject/cli/net/HostsListCommand.java
index 8fd12ba..e2032c3 100644
--- a/cli/src/main/java/org/onosproject/cli/net/HostsListCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/HostsListCommand.java
@@ -15,18 +15,18 @@
*/
package org.onosproject.cli.net;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.utils.Comparators;
-import org.onosproject.net.Host;
-import org.onosproject.net.host.HostService;
-
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.net.Host;
+import org.onosproject.net.host.HostService;
+import org.onosproject.utils.Comparators;
+
+import java.util.Collections;
+import java.util.List;
import static com.google.common.collect.Lists.newArrayList;
@@ -34,12 +34,19 @@
* Lists all currently-known hosts.
*/
@Command(scope = "onos", name = "hosts",
- description = "Lists all currently-known hosts.")
+ description = "Lists all currently-known hosts.")
public class HostsListCommand extends AbstractShellCommand {
private static final String FMT =
"id=%s, mac=%s, location=%s/%s, vlan=%s, ip(s)=%s%s";
+ private static final String FMT_SHORT =
+ "id=%s, mac=%s, location=%s/%s, vlan=%s, ip(s)=%s";
+
+ @Option(name = "-s", aliases = "--short", description = "Show short output only",
+ required = false, multiValued = false)
+ private boolean shortOnly = false;
+
@Override
protected void execute() {
HostService service = get(HostService.class);
@@ -79,12 +86,14 @@
* @param host end-station host
*/
protected void printHost(Host host) {
- if (host != null) {
+ if (shortOnly) {
+ print(FMT_SHORT, host.id(), host.mac(),
+ host.location().deviceId(), host.location().port(),
+ host.vlan(), host.ipAddresses());
+ } else {
print(FMT, host.id(), host.mac(),
- host.location().deviceId(),
- host.location().port(),
- host.vlan(), host.ipAddresses(),
- annotations(host.annotations()));
+ host.location().deviceId(), host.location().port(),
+ host.vlan(), host.ipAddresses(), annotations(host.annotations()));
}
}
}