blob: 114d837e3e2421e47dad364a5e5f1163755526fc [file] [log] [blame]
tom613d8142014-09-11 15:09:37 -07001package org.onlab.onos.cli.net;
2
3import org.apache.karaf.shell.commands.Argument;
4import org.apache.karaf.shell.commands.Command;
5import org.onlab.onos.net.Path;
6
7import java.util.Set;
8
9import static org.onlab.onos.net.DeviceId.deviceId;
10
11/**
12 * Lists all shortest-paths paths between the specified source and
13 * destination devices.
14 */
15@Command(scope = "onos", name = "paths",
16 description = "Lists all shortest-paths paths between the specified source and destination devices")
17public class PathListCommand extends TopologyCommand {
18
19 private static final String FMT = "src=%s/%s, dst=%s/%s, type=%s";
20
21 @Argument(index = 0, name = "src", description = "Source device ID",
22 required = true, multiValued = false)
23 String src = null;
24
25 @Argument(index = 0, name = "dst", description = "Destination device ID",
26 required = true, multiValued = false)
27 String dst = null;
28
29 @Override
30 protected Object doExecute() throws Exception {
31 init();
32 Set<Path> paths = service.getPaths(topology, deviceId(src), deviceId(dst));
33 for (Path path : paths) {
34 print(pathString(path));
35 }
36 return null;
37 }
38
39 private String pathString(Path path) {
40 return path.toString();
41 }
42
43}