Thomas Vachuska | 7d693f5 | 2014-10-21 19:17:57 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
Thomas Vachuska | 7d693f5 | 2014-10-21 19:17:57 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
Thomas Vachuska | 7d693f5 | 2014-10-21 19:17:57 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
Thomas Vachuska | 7d693f5 | 2014-10-21 19:17:57 -0700 | [diff] [blame] | 15 | */ |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 16 | package org.onlab.onos.cli.net; |
| 17 | |
| 18 | import org.apache.karaf.shell.commands.Argument; |
| 19 | import org.apache.karaf.shell.commands.Command; |
| 20 | import org.onlab.onos.cli.AbstractShellCommand; |
| 21 | import org.onlab.onos.net.HostId; |
| 22 | import org.onlab.onos.net.flow.DefaultTrafficSelector; |
| 23 | import org.onlab.onos.net.flow.DefaultTrafficTreatment; |
| 24 | import org.onlab.onos.net.flow.TrafficSelector; |
| 25 | import org.onlab.onos.net.flow.TrafficTreatment; |
| 26 | import org.onlab.onos.net.intent.HostToHostIntent; |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 27 | import org.onlab.onos.net.intent.IntentService; |
| 28 | |
| 29 | /** |
| 30 | * Installs host-to-host connectivity intent. |
| 31 | */ |
| 32 | @Command(scope = "onos", name = "add-host-intent", |
| 33 | description = "Installs host-to-host connectivity intent") |
| 34 | public class AddHostToHostIntentCommand extends AbstractShellCommand { |
| 35 | |
| 36 | @Argument(index = 0, name = "one", description = "One host ID", |
| 37 | required = true, multiValued = false) |
| 38 | String one = null; |
| 39 | |
| 40 | @Argument(index = 1, name = "two", description = "Another host ID", |
| 41 | required = true, multiValued = false) |
| 42 | String two = null; |
| 43 | |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 44 | @Override |
| 45 | protected void execute() { |
| 46 | IntentService service = get(IntentService.class); |
| 47 | |
| 48 | HostId oneId = HostId.hostId(one); |
| 49 | HostId twoId = HostId.hostId(two); |
| 50 | |
| 51 | TrafficSelector selector = DefaultTrafficSelector.builder().build(); |
| 52 | TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); |
| 53 | |
Thomas Vachuska | b97cf28 | 2014-10-20 23:31:12 -0700 | [diff] [blame] | 54 | HostToHostIntent intent = new HostToHostIntent(appId(), oneId, twoId, |
| 55 | selector, treatment); |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 56 | service.submit(intent); |
| 57 | } |
| 58 | |
| 59 | } |