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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.cli.net; |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 17 | |
| 18 | import org.apache.karaf.shell.commands.Argument; |
| 19 | import org.apache.karaf.shell.commands.Command; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 20 | import org.onosproject.net.HostId; |
| 21 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 22 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 23 | import org.onosproject.net.flow.TrafficSelector; |
| 24 | import org.onosproject.net.flow.TrafficTreatment; |
| 25 | import org.onosproject.net.intent.Constraint; |
| 26 | import org.onosproject.net.intent.HostToHostIntent; |
| 27 | import org.onosproject.net.intent.IntentService; |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 28 | |
Thomas Vachuska | dea45ff | 2014-11-12 18:35:46 -0800 | [diff] [blame] | 29 | import java.util.List; |
| 30 | |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 31 | /** |
| 32 | * Installs host-to-host connectivity intent. |
| 33 | */ |
| 34 | @Command(scope = "onos", name = "add-host-intent", |
| 35 | description = "Installs host-to-host connectivity intent") |
Ray Milkey | 460f402 | 2014-11-05 15:41:43 -0800 | [diff] [blame] | 36 | public class AddHostToHostIntentCommand extends ConnectivityIntentCommand { |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 37 | |
| 38 | @Argument(index = 0, name = "one", description = "One host ID", |
| 39 | required = true, multiValued = false) |
| 40 | String one = null; |
| 41 | |
| 42 | @Argument(index = 1, name = "two", description = "Another host ID", |
| 43 | required = true, multiValued = false) |
| 44 | String two = null; |
| 45 | |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 46 | @Override |
| 47 | protected void execute() { |
| 48 | IntentService service = get(IntentService.class); |
| 49 | |
| 50 | HostId oneId = HostId.hostId(one); |
| 51 | HostId twoId = HostId.hostId(two); |
| 52 | |
| 53 | TrafficSelector selector = DefaultTrafficSelector.builder().build(); |
| 54 | TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); |
Ray Milkey | 460f402 | 2014-11-05 15:41:43 -0800 | [diff] [blame] | 55 | List<Constraint> constraints = buildConstraints(); |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 56 | |
Thomas Vachuska | b97cf28 | 2014-10-20 23:31:12 -0700 | [diff] [blame] | 57 | HostToHostIntent intent = new HostToHostIntent(appId(), oneId, twoId, |
Ray Milkey | 460f402 | 2014-11-05 15:41:43 -0800 | [diff] [blame] | 58 | selector, treatment, |
| 59 | constraints); |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 60 | service.submit(intent); |
| 61 | } |
| 62 | |
| 63 | } |