Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.intent; |
| 2 | |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 3 | import com.google.common.base.MoreObjects; |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 4 | import org.onlab.onos.ApplicationId; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 5 | import org.onlab.onos.net.Path; |
| 6 | import org.onlab.onos.net.flow.TrafficSelector; |
| 7 | import org.onlab.onos.net.flow.TrafficTreatment; |
| 8 | |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 9 | /** |
| 10 | * Abstraction of explicitly path specified connectivity intent. |
| 11 | */ |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 12 | public class PathIntent extends ConnectivityIntent { |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 13 | |
| 14 | private final Path path; |
| 15 | |
| 16 | /** |
| 17 | * Creates a new point-to-point intent with the supplied ingress/egress |
| 18 | * ports and using the specified explicit path. |
| 19 | * |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 20 | * @param appId application identifier |
| 21 | * @param selector traffic selector |
| 22 | * @param treatment treatment |
| 23 | * @param path traversed links |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 24 | * @throws NullPointerException {@code path} is null |
| 25 | */ |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 26 | public PathIntent(ApplicationId appId, TrafficSelector selector, |
| 27 | TrafficTreatment treatment, Path path) { |
| 28 | super(id(PathIntent.class, selector, treatment, path), appId, |
| 29 | resources(path.links()), selector, treatment); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 30 | this.path = path; |
| 31 | } |
| 32 | |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 33 | /** |
| 34 | * Constructor for serializer. |
| 35 | */ |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 36 | protected PathIntent() { |
| 37 | super(); |
| 38 | this.path = null; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Returns the links which the traffic goes along. |
| 43 | * |
| 44 | * @return traversed links |
| 45 | */ |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 46 | public Path path() { |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 47 | return path; |
| 48 | } |
| 49 | |
| 50 | @Override |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 51 | public boolean isInstallable() { |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 52 | return true; |
| 53 | } |
| 54 | |
| 55 | @Override |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 56 | public String toString() { |
| 57 | return MoreObjects.toStringHelper(getClass()) |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 58 | .add("id", id()) |
Thomas Vachuska | e291c84 | 2014-10-21 02:52:38 -0700 | [diff] [blame^] | 59 | .add("appId", appId()) |
| 60 | .add("selector", selector()) |
| 61 | .add("treatment", treatment()) |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 62 | .add("path", path) |
| 63 | .toString(); |
| 64 | } |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 65 | |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 66 | } |