blob: a390025902198ac4263494981d9fc325b3146f2d [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
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}