blob: 92b148d1218244dade1747c67b7bcba0241a32ca [file] [log] [blame]
Brian O'Connor66630c82014-10-02 21:08:19 -07001package org.onlab.onos.net.intent;
2
toma1d16b62014-10-02 23:45:11 -07003import com.google.common.base.MoreObjects;
Thomas Vachuskac96058a2014-10-20 23:00:16 -07004import org.onlab.onos.ApplicationId;
Brian O'Connor66630c82014-10-02 21:08:19 -07005import org.onlab.onos.net.HostId;
6import org.onlab.onos.net.flow.TrafficSelector;
7import org.onlab.onos.net.flow.TrafficTreatment;
8
toma1d16b62014-10-02 23:45:11 -07009import static com.google.common.base.Preconditions.checkNotNull;
Brian O'Connor66630c82014-10-02 21:08:19 -070010
11/**
tomf5c9d922014-10-03 15:22:03 -070012 * Abstraction of end-station to end-station bidirectional connectivity.
Brian O'Connor66630c82014-10-02 21:08:19 -070013 */
Ray Milkeye6684082014-10-16 16:59:47 -070014public final class HostToHostIntent extends ConnectivityIntent {
Brian O'Connor66630c82014-10-02 21:08:19 -070015
tomf5c9d922014-10-03 15:22:03 -070016 private final HostId one;
17 private final HostId two;
Brian O'Connor66630c82014-10-02 21:08:19 -070018
19 /**
20 * Creates a new point-to-point intent with the supplied ingress/egress
21 * ports.
22 *
Thomas Vachuskac96058a2014-10-20 23:00:16 -070023 * @param appId application identifier
tomf5c9d922014-10-03 15:22:03 -070024 * @param one first host
25 * @param two second host
toma1d16b62014-10-02 23:45:11 -070026 * @param selector action
27 * @param treatment ingress port
Brian O'Connor66630c82014-10-02 21:08:19 -070028 * @throws NullPointerException if {@code ingressPort} or {@code egressPort}
toma1d16b62014-10-02 23:45:11 -070029 * is null.
Brian O'Connor66630c82014-10-02 21:08:19 -070030 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070031 public HostToHostIntent(ApplicationId appId, HostId one, HostId two,
tomf5c9d922014-10-03 15:22:03 -070032 TrafficSelector selector,
33 TrafficTreatment treatment) {
Thomas Vachuskac96058a2014-10-20 23:00:16 -070034 super(id(HostToHostIntent.class, one, two, selector, treatment),
35 appId, null, selector, treatment);
tomf5c9d922014-10-03 15:22:03 -070036 this.one = checkNotNull(one);
37 this.two = checkNotNull(two);
Brian O'Connor66630c82014-10-02 21:08:19 -070038 }
39
40 /**
tomf5c9d922014-10-03 15:22:03 -070041 * Returns identifier of the first host.
Brian O'Connor66630c82014-10-02 21:08:19 -070042 *
tomf5c9d922014-10-03 15:22:03 -070043 * @return first host identifier
Brian O'Connor66630c82014-10-02 21:08:19 -070044 */
tomf5c9d922014-10-03 15:22:03 -070045 public HostId one() {
46 return one;
Brian O'Connor66630c82014-10-02 21:08:19 -070047 }
48
49 /**
tomf5c9d922014-10-03 15:22:03 -070050 * Returns identifier of the second host.
Brian O'Connor66630c82014-10-02 21:08:19 -070051 *
tomf5c9d922014-10-03 15:22:03 -070052 * @return second host identifier
Brian O'Connor66630c82014-10-02 21:08:19 -070053 */
tomf5c9d922014-10-03 15:22:03 -070054 public HostId two() {
55 return two;
Brian O'Connor66630c82014-10-02 21:08:19 -070056 }
57
58 @Override
Brian O'Connor66630c82014-10-02 21:08:19 -070059 public String toString() {
60 return MoreObjects.toStringHelper(getClass())
tom85258ee2014-10-07 00:10:02 -070061 .add("id", id())
62 .add("selector", selector())
63 .add("treatment", treatment())
tomf5c9d922014-10-03 15:22:03 -070064 .add("one", one)
65 .add("two", two)
Brian O'Connor66630c82014-10-02 21:08:19 -070066 .toString();
67 }
68
69}