blob: 2bbfb465d32b840a3c76a3d26c42123b45878bbc [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
tom0872a172014-09-23 11:24:26 -070023 protected void execute() {
tom13cb4852014-09-11 12:44:17 -070024 int cid = Integer.parseInt(id);
25 init();
26 TopologyCluster cluster = service.getCluster(topology, clusterId(cid));
tom9eb57fb2014-09-11 19:42:38 -070027 if (cluster == null) {
28 error("No such cluster %s", cid);
29 } else {
30 for (Link link : service.getClusterLinks(topology, cluster)) {
31 print(linkString(link));
32 }
tom13cb4852014-09-11 12:44:17 -070033 }
tom13cb4852014-09-11 12:44:17 -070034 }
35
tom13cb4852014-09-11 12:44:17 -070036}