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.Argument; |
| 4 | import org.apache.karaf.shell.commands.Command; |
| 5 | import org.onlab.onos.cli.AbstractShellCommand; |
| 6 | import org.onlab.onos.net.HostId; |
| 7 | import org.onlab.onos.net.flow.DefaultTrafficSelector; |
| 8 | import org.onlab.onos.net.flow.DefaultTrafficTreatment; |
| 9 | import org.onlab.onos.net.flow.TrafficSelector; |
| 10 | import org.onlab.onos.net.flow.TrafficTreatment; |
| 11 | import org.onlab.onos.net.intent.HostToHostIntent; |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 12 | import org.onlab.onos.net.intent.IntentService; |
| 13 | |
| 14 | /** |
| 15 | * Installs host-to-host connectivity intent. |
| 16 | */ |
| 17 | @Command(scope = "onos", name = "add-host-intent", |
| 18 | description = "Installs host-to-host connectivity intent") |
| 19 | public class AddHostToHostIntentCommand extends AbstractShellCommand { |
| 20 | |
| 21 | @Argument(index = 0, name = "one", description = "One host ID", |
| 22 | required = true, multiValued = false) |
| 23 | String one = null; |
| 24 | |
| 25 | @Argument(index = 1, name = "two", description = "Another host ID", |
| 26 | required = true, multiValued = false) |
| 27 | String two = null; |
| 28 | |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 29 | @Override |
| 30 | protected void execute() { |
| 31 | IntentService service = get(IntentService.class); |
| 32 | |
| 33 | HostId oneId = HostId.hostId(one); |
| 34 | HostId twoId = HostId.hostId(two); |
| 35 | |
| 36 | TrafficSelector selector = DefaultTrafficSelector.builder().build(); |
| 37 | TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); |
| 38 | |
Thomas Vachuska | b97cf28 | 2014-10-20 23:31:12 -0700 | [diff] [blame^] | 39 | HostToHostIntent intent = new HostToHostIntent(appId(), oneId, twoId, |
| 40 | selector, treatment); |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 41 | service.submit(intent); |
| 42 | } |
| 43 | |
| 44 | } |