blob: 7d3bfc29c207f58e323d7c00e6103d53c99a1fe4 [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;
20import org.onlab.onos.cli.AbstractShellCommand;
21import org.onlab.onos.net.HostId;
22import org.onlab.onos.net.flow.DefaultTrafficSelector;
23import org.onlab.onos.net.flow.DefaultTrafficTreatment;
24import org.onlab.onos.net.flow.TrafficSelector;
25import org.onlab.onos.net.flow.TrafficTreatment;
26import org.onlab.onos.net.intent.HostToHostIntent;
tomf5c9d922014-10-03 15:22:03 -070027import 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")
34public 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
tomf5c9d922014-10-03 15:22:03 -070044 @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 Vachuskab97cf282014-10-20 23:31:12 -070054 HostToHostIntent intent = new HostToHostIntent(appId(), oneId, twoId,
55 selector, treatment);
tomf5c9d922014-10-03 15:22:03 -070056 service.submit(intent);
57 }
58
59}