blob: c137b9af178ff1f3d2393083e9751199224e65b3 [file] [log] [blame]
Thomas Vachuska7d693f52014-10-21 19:17:57 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska7d693f52014-10-21 19:17:57 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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 Vachuska7d693f52014-10-21 19:17:57 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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 Vachuska7d693f52014-10-21 19:17:57 -070015 */
tomf5c9d922014-10-03 15:22:03 -070016package org.onlab.onos.cli.net;
17
18import org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
tomf5c9d922014-10-03 15:22:03 -070020import org.onlab.onos.net.HostId;
21import org.onlab.onos.net.flow.DefaultTrafficSelector;
22import org.onlab.onos.net.flow.DefaultTrafficTreatment;
23import org.onlab.onos.net.flow.TrafficSelector;
24import org.onlab.onos.net.flow.TrafficTreatment;
Ray Milkey460f4022014-11-05 15:41:43 -080025import org.onlab.onos.net.intent.Constraint;
tomf5c9d922014-10-03 15:22:03 -070026import org.onlab.onos.net.intent.HostToHostIntent;
tomf5c9d922014-10-03 15:22:03 -070027import org.onlab.onos.net.intent.IntentService;
28
Thomas Vachuskadea45ff2014-11-12 18:35:46 -080029import java.util.List;
30
tomf5c9d922014-10-03 15:22:03 -070031/**
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 Milkey460f4022014-11-05 15:41:43 -080036public class AddHostToHostIntentCommand extends ConnectivityIntentCommand {
tomf5c9d922014-10-03 15:22:03 -070037
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
tomf5c9d922014-10-03 15:22:03 -070046 @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 Milkey460f4022014-11-05 15:41:43 -080055 List<Constraint> constraints = buildConstraints();
tomf5c9d922014-10-03 15:22:03 -070056
Thomas Vachuskab97cf282014-10-20 23:31:12 -070057 HostToHostIntent intent = new HostToHostIntent(appId(), oneId, twoId,
Ray Milkey460f4022014-11-05 15:41:43 -080058 selector, treatment,
59 constraints);
tomf5c9d922014-10-03 15:22:03 -070060 service.submit(intent);
61 }
62
63}