tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame^] | 1 | package org.onlab.onos.cli.net; |
| 2 | |
| 3 | import org.apache.karaf.shell.commands.Argument; |
| 4 | import org.apache.karaf.shell.commands.Command; |
| 5 | import org.onlab.onos.net.Path; |
| 6 | |
| 7 | import java.util.Set; |
| 8 | |
| 9 | import 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") |
| 17 | public 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 | } |