blob: be5105c9c84a57155719f933d52a8a29bacf06ef [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));
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 }
34 return null;
35 }
36
tom13cb4852014-09-11 12:44:17 -070037}