tom | 13cb485 | 2014-09-11 12:44:17 -0700 | [diff] [blame] | 1 | package org.onlab.onos.cli.net; |
| 2 | |
| 3 | import org.apache.karaf.shell.commands.Argument; |
| 4 | import org.apache.karaf.shell.commands.Command; |
| 5 | import org.onlab.onos.net.Link; |
| 6 | import org.onlab.onos.net.topology.TopologyCluster; |
| 7 | |
| 8 | import static org.onlab.onos.cli.net.LinksListCommand.linkString; |
| 9 | import 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") |
| 16 | public class ClusterLinksCommand extends ClustersListCommand { |
| 17 | |
| 18 | @Argument(index = 0, name = "id", description = "Cluster ID", |
tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame] | 19 | required = true, multiValued = false) |
tom | 13cb485 | 2014-09-11 12:44:17 -0700 | [diff] [blame] | 20 | 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)); |
tom | 9eb57fb | 2014-09-11 19:42:38 -0700 | [diff] [blame^] | 27 | 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 | } |
tom | 13cb485 | 2014-09-11 12:44:17 -0700 | [diff] [blame] | 33 | } |
| 34 | return null; |
| 35 | } |
| 36 | |
tom | 13cb485 | 2014-09-11 12:44:17 -0700 | [diff] [blame] | 37 | } |