blob: 5a75a17af4899c713eafb603ec257d2a4ceee10f [file] [log] [blame]
tomf5c9d922014-10-03 15:22:03 -07001package org.onlab.onos.cli.net;
2
3import org.apache.karaf.shell.commands.Argument;
4import org.apache.karaf.shell.commands.Command;
5import org.onlab.onos.cli.AbstractShellCommand;
6import org.onlab.onos.net.HostId;
7import org.onlab.onos.net.flow.DefaultTrafficSelector;
8import org.onlab.onos.net.flow.DefaultTrafficTreatment;
9import org.onlab.onos.net.flow.TrafficSelector;
10import org.onlab.onos.net.flow.TrafficTreatment;
11import org.onlab.onos.net.intent.HostToHostIntent;
tomf5c9d922014-10-03 15:22:03 -070012import org.onlab.onos.net.intent.IntentService;
13
14/**
15 * Installs host-to-host connectivity intent.
16 */
17@Command(scope = "onos", name = "add-host-intent",
18 description = "Installs host-to-host connectivity intent")
19public class AddHostToHostIntentCommand extends AbstractShellCommand {
20
21 @Argument(index = 0, name = "one", description = "One host ID",
22 required = true, multiValued = false)
23 String one = null;
24
25 @Argument(index = 1, name = "two", description = "Another host ID",
26 required = true, multiValued = false)
27 String two = null;
28
tomf5c9d922014-10-03 15:22:03 -070029 @Override
30 protected void execute() {
31 IntentService service = get(IntentService.class);
32
33 HostId oneId = HostId.hostId(one);
34 HostId twoId = HostId.hostId(two);
35
36 TrafficSelector selector = DefaultTrafficSelector.builder().build();
37 TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
38
Thomas Vachuskab97cf282014-10-20 23:31:12 -070039 HostToHostIntent intent = new HostToHostIntent(appId(), oneId, twoId,
40 selector, treatment);
tomf5c9d922014-10-03 15:22:03 -070041 service.submit(intent);
42 }
43
44}