blob: 4138172982e5e2c51978c35ea3dd14960d88d1a0 [file] [log] [blame]
Brian O'Connorb876bf12014-10-02 14:59:37 -07001package org.onlab.onos.net.intent;
2
tom95329eb2014-10-06 08:40:06 -07003import com.google.common.base.MoreObjects;
Thomas Vachuskac96058a2014-10-20 23:00:16 -07004import org.onlab.onos.ApplicationId;
Brian O'Connorb876bf12014-10-02 14:59:37 -07005import org.onlab.onos.net.Path;
6import org.onlab.onos.net.flow.TrafficSelector;
7import org.onlab.onos.net.flow.TrafficTreatment;
8
Brian O'Connorb876bf12014-10-02 14:59:37 -07009/**
10 * Abstraction of explicitly path specified connectivity intent.
11 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070012public class PathIntent extends ConnectivityIntent {
Brian O'Connorb876bf12014-10-02 14:59:37 -070013
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 Vachuskac96058a2014-10-20 23:00:16 -070020 * @param appId application identifier
21 * @param selector traffic selector
22 * @param treatment treatment
23 * @param path traversed links
Brian O'Connorb876bf12014-10-02 14:59:37 -070024 * @throws NullPointerException {@code path} is null
25 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070026 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'Connorb876bf12014-10-02 14:59:37 -070030 this.path = path;
31 }
32
Thomas Vachuskac96058a2014-10-20 23:00:16 -070033 /**
34 * Constructor for serializer.
35 */
Brian O'Connorb876bf12014-10-02 14:59:37 -070036 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 */
tom85258ee2014-10-07 00:10:02 -070046 public Path path() {
Brian O'Connorb876bf12014-10-02 14:59:37 -070047 return path;
48 }
49
50 @Override
Thomas Vachuskac96058a2014-10-20 23:00:16 -070051 public boolean isInstallable() {
Brian O'Connorb876bf12014-10-02 14:59:37 -070052 return true;
53 }
54
55 @Override
Brian O'Connorb876bf12014-10-02 14:59:37 -070056 public String toString() {
57 return MoreObjects.toStringHelper(getClass())
tom85258ee2014-10-07 00:10:02 -070058 .add("id", id())
59 .add("match", selector())
60 .add("action", treatment())
Brian O'Connorb876bf12014-10-02 14:59:37 -070061 .add("path", path)
62 .toString();
63 }
tom95329eb2014-10-06 08:40:06 -070064
Brian O'Connorb876bf12014-10-02 14:59:37 -070065}