Added commands to list paths.
Added protection against bad input on some command-lines.
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/PathListCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/PathListCommand.java
index 114d837..cdede0b 100644
--- a/cli/src/main/java/org/onlab/onos/cli/net/PathListCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/net/PathListCommand.java
@@ -2,10 +2,12 @@
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
+import org.onlab.onos.net.Link;
import org.onlab.onos.net.Path;
import java.util.Set;
+import static org.onlab.onos.cli.net.LinksListCommand.compactLinkString;
import static org.onlab.onos.net.DeviceId.deviceId;
/**
@@ -16,13 +18,13 @@
description = "Lists all shortest-paths paths between the specified source and destination devices")
public class PathListCommand extends TopologyCommand {
- private static final String FMT = "src=%s/%s, dst=%s/%s, type=%s";
+ private static final String SEP = "==>";
@Argument(index = 0, name = "src", description = "Source device ID",
required = true, multiValued = false)
String src = null;
- @Argument(index = 0, name = "dst", description = "Destination device ID",
+ @Argument(index = 1, name = "dst", description = "Destination device ID",
required = true, multiValued = false)
String dst = null;
@@ -36,8 +38,20 @@
return null;
}
- private String pathString(Path path) {
- return path.toString();
+ /**
+ * Produces a formatted string representing the specified path.
+ *
+ * @param path network path
+ * @return formatted path string
+ */
+ protected String pathString(Path path) {
+ StringBuilder sb = new StringBuilder();
+ for (Link link : path.links()) {
+ sb.append(compactLinkString(link)).append(SEP);
+ }
+ sb.delete(sb.lastIndexOf(SEP), sb.length());
+ sb.append("; cost=").append(path.cost());
+ return sb.toString();
}
}