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", |
| 19 | required = false, multiValued = false) |
| 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)); |
| 27 | for (Link link : service.getClusterLinks(topology, cluster)) { |
| 28 | print(linkString(link)); |
| 29 | } |
| 30 | return null; |
| 31 | } |
| 32 | |
| 33 | |
| 34 | } |