blob: 17d9729a5c558b31b68ba7425072745b21fb3b11 [file] [log] [blame]
Thomas Vachuska7d693f52014-10-21 19:17:57 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 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
Ray Milkeyebc5d222015-03-18 15:45:36 -070018import java.util.List;
19
tomf5c9d922014-10-03 15:22:03 -070020import org.apache.karaf.shell.commands.Argument;
21import org.apache.karaf.shell.commands.Command;
Brian O'Connorabafb502014-12-02 22:26:20 -080022import org.onosproject.net.HostId;
Brian O'Connorabafb502014-12-02 22:26:20 -080023import org.onosproject.net.intent.Constraint;
24import org.onosproject.net.intent.HostToHostIntent;
25import org.onosproject.net.intent.IntentService;
tomf5c9d922014-10-03 15:22:03 -070026
27/**
28 * Installs host-to-host connectivity intent.
29 */
30@Command(scope = "onos", name = "add-host-intent",
31 description = "Installs host-to-host connectivity intent")
Ray Milkey460f4022014-11-05 15:41:43 -080032public class AddHostToHostIntentCommand extends ConnectivityIntentCommand {
tomf5c9d922014-10-03 15:22:03 -070033
34 @Argument(index = 0, name = "one", description = "One host ID",
35 required = true, multiValued = false)
36 String one = null;
37
38 @Argument(index = 1, name = "two", description = "Another host ID",
39 required = true, multiValued = false)
40 String two = null;
41
tomf5c9d922014-10-03 15:22:03 -070042 @Override
43 protected void execute() {
44 IntentService service = get(IntentService.class);
45
46 HostId oneId = HostId.hostId(one);
47 HostId twoId = HostId.hostId(two);
48
Ray Milkey460f4022014-11-05 15:41:43 -080049 List<Constraint> constraints = buildConstraints();
tomf5c9d922014-10-03 15:22:03 -070050
Ray Milkeyebc5d222015-03-18 15:45:36 -070051 HostToHostIntent intent = HostToHostIntent.builder()
52 .appId(appId())
53 .key(key())
54 .one(oneId)
55 .two(twoId)
56 .constraints(constraints)
57 .priority(priority())
58 .build();
tomf5c9d922014-10-03 15:22:03 -070059 service.submit(intent);
Ray Milkeycb33a132015-02-02 10:05:12 -080060 print("Host to Host intent submitted:\n%s", intent.toString());
tomf5c9d922014-10-03 15:22:03 -070061 }
62
63}