blob: 6c141ae47ab613e7cd1cf96358b837bc057ede9a [file] [log] [blame]
tom13cb4852014-09-11 12:44:17 -07001package org.onlab.onos.cli.net;
2
3import org.apache.karaf.shell.commands.Command;
4import org.onlab.onos.cli.AbstractShellCommand;
5import org.onlab.onos.net.topology.Topology;
6import 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")
13public class TopologyCommand extends AbstractShellCommand {
14
tom613d8142014-09-11 15:09:37 -070015 // TODO: format the time-stamp
tom13cb4852014-09-11 12:44:17 -070016 private static final String FMT =
17 "time=%s, devices=%d, links=%d, clusters=%d, paths=%d";
18
19 protected TopologyService service;
20 protected Topology topology;
21
22 /**
23 * Initializes the context for all cluster commands.
24 */
25 protected void init() {
26 service = getService(TopologyService.class);
27 topology = service.currentTopology();
28 }
29
30 @Override
31 protected Object doExecute() throws Exception {
32 init();
33 print(FMT, topology.time(), topology.deviceCount(), topology.linkCount(),
34 topology.clusterCount(), topology.pathCount());
35 return null;
36 }
37
38}