tom | 13cb485 | 2014-09-11 12:44:17 -0700 | [diff] [blame^] | 1 | package org.onlab.onos.cli.net; |
| 2 | |
| 3 | import org.apache.karaf.shell.commands.Command; |
| 4 | import org.onlab.onos.cli.AbstractShellCommand; |
| 5 | import org.onlab.onos.net.topology.Topology; |
| 6 | import org.onlab.onos.net.topology.TopologyService; |
| 7 | |
| 8 | /** |
| 9 | * Lists summary of the current topology. |
| 10 | */ |
| 11 | @Command(scope = "onos", name = "topology", |
| 12 | description = "Lists summary of the current topology") |
| 13 | public class TopologyCommand extends AbstractShellCommand { |
| 14 | |
| 15 | private static final String FMT = |
| 16 | "time=%s, devices=%d, links=%d, clusters=%d, paths=%d"; |
| 17 | |
| 18 | protected TopologyService service; |
| 19 | protected Topology topology; |
| 20 | |
| 21 | /** |
| 22 | * Initializes the context for all cluster commands. |
| 23 | */ |
| 24 | protected void init() { |
| 25 | service = getService(TopologyService.class); |
| 26 | topology = service.currentTopology(); |
| 27 | } |
| 28 | |
| 29 | @Override |
| 30 | protected Object doExecute() throws Exception { |
| 31 | init(); |
| 32 | print(FMT, topology.time(), topology.deviceCount(), topology.linkCount(), |
| 33 | topology.clusterCount(), topology.pathCount()); |
| 34 | return null; |
| 35 | } |
| 36 | |
| 37 | } |