blob: 246c39e91c2000c0f426e7164ae706991f7b63bf [file] [log] [blame]
tom13cb4852014-09-11 12:44:17 -07001package org.onlab.onos.cli.net;
2
3import org.apache.karaf.shell.commands.Argument;
4import org.apache.karaf.shell.commands.Command;
5import org.onlab.onos.net.Link;
6import org.onlab.onos.net.topology.TopologyCluster;
7
8import static org.onlab.onos.cli.net.LinksListCommand.linkString;
9import static org.onlab.onos.net.topology.ClusterId.clusterId;
10
11/**
12 * Lists links of the specified topology cluster in the current topology.
13 */
14@Command(scope = "onos", name = "cluster-links",
15 description = "Lists links of the specified topology cluster in the current topology")
16public class ClusterLinksCommand extends ClustersListCommand {
17
18 @Argument(index = 0, name = "id", description = "Cluster ID",
tom613d8142014-09-11 15:09:37 -070019 required = true, multiValued = false)
tom13cb4852014-09-11 12:44:17 -070020 String id = null;
21
22 @Override
23 protected Object doExecute() throws Exception {
24 int cid = Integer.parseInt(id);
25 init();
26 TopologyCluster cluster = service.getCluster(topology, clusterId(cid));
27 for (Link link : service.getClusterLinks(topology, cluster)) {
28 print(linkString(link));
29 }
30 return null;
31 }
32
tom13cb4852014-09-11 12:44:17 -070033}