blob: e9bf826b12dab117b74db3d4629d7f224a0305d2 [file] [log] [blame]
weibitf32383b2014-10-22 10:17:31 -07001package org.onlab.onos.net.intent;
2
3import java.util.Collection;
weibitf32383b2014-10-22 10:17:31 -07004
Thomas Vachuskae0f804a2014-10-27 23:40:48 -07005import org.onlab.onos.core.ApplicationId;
weibitf32383b2014-10-22 10:17:31 -07006import org.onlab.onos.net.ConnectPoint;
7import org.onlab.onos.net.Link;
Brian O'Connor4908d602014-10-23 15:58:20 -07008import org.onlab.onos.net.NetworkResource;
weibitf32383b2014-10-22 10:17:31 -07009import org.onlab.onos.net.Path;
weibitf32383b2014-10-22 10:17:31 -070010
11import com.google.common.base.MoreObjects;
Brian O'Connor4908d602014-10-23 15:58:20 -070012import com.google.common.collect.ImmutableSet;
weibitf32383b2014-10-22 10:17:31 -070013
Brian O'Connor4908d602014-10-23 15:58:20 -070014public class OpticalPathIntent extends Intent {
Brian O'Connor086724e2014-10-23 15:47:32 -070015
16 private final ConnectPoint src;
17 private final ConnectPoint dst;
weibitf32383b2014-10-22 10:17:31 -070018 private final Path path;
Brian O'Connor086724e2014-10-23 15:47:32 -070019
weibitf32383b2014-10-22 10:17:31 -070020
weibit7e583462014-10-23 10:14:05 -070021 public OpticalPathIntent(ApplicationId appId,
22 ConnectPoint src,
23 ConnectPoint dst,
weibit7e583462014-10-23 10:14:05 -070024 Path path) {
Brian O'Connor086724e2014-10-23 15:47:32 -070025 super(id(OpticalPathIntent.class, src, dst),
Brian O'Connor4908d602014-10-23 15:58:20 -070026 appId,
27 ImmutableSet.<NetworkResource>copyOf(path.links()));
Brian O'Connor086724e2014-10-23 15:47:32 -070028 this.src = src;
29 this.dst = dst;
weibitf32383b2014-10-22 10:17:31 -070030 this.path = path;
31 }
32
weibit9e622ac2014-10-23 13:45:44 -070033 protected OpticalPathIntent() {
Brian O'Connor086724e2014-10-23 15:47:32 -070034 this.src = null;
35 this.dst = null;
weibitf32383b2014-10-22 10:17:31 -070036 this.path = null;
37 }
38
Brian O'Connor086724e2014-10-23 15:47:32 -070039 public ConnectPoint src() {
40 return src;
41 }
42
43 public ConnectPoint dst() {
44 return dst;
45 }
46
weibitf32383b2014-10-22 10:17:31 -070047 public Path path() {
48 return path;
49 }
weibitf32383b2014-10-22 10:17:31 -070050
weibitf32383b2014-10-22 10:17:31 -070051 @Override
weibit7e583462014-10-23 10:14:05 -070052 public boolean isInstallable() {
weibitf32383b2014-10-22 10:17:31 -070053 return true;
54 }
55
56 @Override
weibitf32383b2014-10-22 10:17:31 -070057 public String toString() {
58 return MoreObjects.toStringHelper(getClass())
59 .add("id", id())
Brian O'Connor086724e2014-10-23 15:47:32 -070060 .add("ingressPort", src)
61 .add("egressPort", dst)
weibitf32383b2014-10-22 10:17:31 -070062 .add("path", path)
63 .toString();
64 }
65
weibitf32383b2014-10-22 10:17:31 -070066 public Collection<Link> requiredLinks() {
67 return path.links();
68 }
69}