blob: 642a19f6914ba81374ad8e7ac52ba34afee787dc [file] [log] [blame]
Thomas Vachuska7d693f52014-10-21 19:17:57 -07001/*
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 */
tomf5c9d922014-10-03 15:22:03 -070019package org.onlab.onos.cli.net;
20
21import org.apache.karaf.shell.commands.Argument;
22import org.apache.karaf.shell.commands.Command;
23import org.onlab.onos.cli.AbstractShellCommand;
24import org.onlab.onos.net.HostId;
25import org.onlab.onos.net.flow.DefaultTrafficSelector;
26import org.onlab.onos.net.flow.DefaultTrafficTreatment;
27import org.onlab.onos.net.flow.TrafficSelector;
28import org.onlab.onos.net.flow.TrafficTreatment;
29import org.onlab.onos.net.intent.HostToHostIntent;
tomf5c9d922014-10-03 15:22:03 -070030import 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")
37public 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
tomf5c9d922014-10-03 15:22:03 -070047 @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 Vachuskab97cf282014-10-20 23:31:12 -070057 HostToHostIntent intent = new HostToHostIntent(appId(), oneId, twoId,
58 selector, treatment);
tomf5c9d922014-10-03 15:22:03 -070059 service.submit(intent);
60 }
61
62}