tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 1 | package org.onlab.onos.cli.net; |
| 2 | |
| 3 | import org.apache.karaf.shell.commands.Command; |
| 4 | import org.onlab.onos.cli.AbstractShellCommand; |
| 5 | import org.onlab.onos.net.intent.Intent; |
| 6 | import org.onlab.onos.net.intent.IntentService; |
Brian O'Connor | a4cab07 | 2014-10-03 18:46:39 -0700 | [diff] [blame^] | 7 | import org.onlab.onos.net.intent.IntentState; |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 8 | |
| 9 | /** |
| 10 | * Lists the inventory of intents and their states. |
| 11 | */ |
| 12 | @Command(scope = "onos", name = "intents", |
| 13 | description = "Lists the inventory of intents and their states") |
| 14 | public class IntentsListCommand extends AbstractShellCommand { |
| 15 | |
| 16 | @Override |
| 17 | protected void execute() { |
| 18 | IntentService service = get(IntentService.class); |
| 19 | for (Intent intent : service.getIntents()) { |
Brian O'Connor | a4cab07 | 2014-10-03 18:46:39 -0700 | [diff] [blame^] | 20 | IntentState state = service.getIntentState(intent.getId()); |
| 21 | print("%s %s %s", intent.getId(), state, intent); |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 22 | } |
| 23 | } |
| 24 | |
| 25 | } |