blob: 5c8310ff62365c433fc97f4c836cecfe2282aff5 [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() {
tomcaf3bf72014-09-23 13:20:53 -070026 service = get(TopologyService.class);
tom13cb4852014-09-11 12:44:17 -070027 topology = service.currentTopology();
28 }
29
30 @Override
tom0872a172014-09-23 11:24:26 -070031 protected void execute() {
tom13cb4852014-09-11 12:44:17 -070032 init();
33 print(FMT, topology.time(), topology.deviceCount(), topology.linkCount(),
34 topology.clusterCount(), topology.pathCount());
tom13cb4852014-09-11 12:44:17 -070035 }
36
37}