blob: a4a3a7cec73bda4fcd08f674b82c8b2a91123fe4 [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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.cli.net;
tomf5c9d922014-10-03 15:22:03 -070017
18import org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.net.HostId;
21import org.onosproject.net.flow.DefaultTrafficSelector;
22import org.onosproject.net.flow.DefaultTrafficTreatment;
23import org.onosproject.net.flow.TrafficSelector;
24import org.onosproject.net.flow.TrafficTreatment;
25import org.onosproject.net.intent.Constraint;
26import org.onosproject.net.intent.HostToHostIntent;
27import org.onosproject.net.intent.IntentService;
tomf5c9d922014-10-03 15:22:03 -070028
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
Brian O'Connor6b528132015-03-10 16:39:52 -070053 TrafficSelector selector = DefaultTrafficSelector.emptySelector();
54 TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
Ray Milkey460f4022014-11-05 15:41:43 -080055 List<Constraint> constraints = buildConstraints();
tomf5c9d922014-10-03 15:22:03 -070056
Ray Milkey5b3717e2015-02-05 11:44:08 -080057 HostToHostIntent intent = new HostToHostIntent(appId(), key(),
58 oneId, twoId,
Ray Milkey460f4022014-11-05 15:41:43 -080059 selector, treatment,
Ray Milkey50a9b722015-03-12 10:38:55 -070060 constraints, priority());
tomf5c9d922014-10-03 15:22:03 -070061 service.submit(intent);
Ray Milkeycb33a132015-02-02 10:05:12 -080062 print("Host to Host intent submitted:\n%s", intent.toString());
tomf5c9d922014-10-03 15:22:03 -070063 }
64
65}