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