Adding JSON format to the CLI. Intents and flows still need to be done.
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/ClusterDevicesCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/ClusterDevicesCommand.java
index f09b185..e03af45 100644
--- a/cli/src/main/java/org/onlab/onos/cli/net/ClusterDevicesCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/net/ClusterDevicesCommand.java
@@ -1,5 +1,6 @@
package org.onlab.onos.cli.net;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
@@ -10,6 +11,7 @@
import java.util.Collections;
import java.util.List;
+import static org.onlab.onos.cli.MastersListCommand.json;
import static org.onlab.onos.net.topology.ClusterId.clusterId;
/**
@@ -33,11 +35,14 @@
} else {
List<DeviceId> ids = Lists.newArrayList(service.getClusterDevices(topology, cluster));
Collections.sort(ids, Comparators.ELEMENT_ID_COMPARATOR);
- for (DeviceId deviceId : ids) {
- print("%s", deviceId);
+ if (outputJson()) {
+ print("%s", json(new ObjectMapper(), ids));
+ } else {
+ for (DeviceId deviceId : ids) {
+ print("%s", deviceId);
+ }
}
}
}
-
}