weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.intent; |
| 2 | |
| 3 | import java.util.Collection; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 4 | |
Thomas Vachuska | e0f804a | 2014-10-27 23:40:48 -0700 | [diff] [blame^] | 5 | import org.onlab.onos.core.ApplicationId; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 6 | import org.onlab.onos.net.ConnectPoint; |
| 7 | import org.onlab.onos.net.Link; |
Brian O'Connor | 4908d60 | 2014-10-23 15:58:20 -0700 | [diff] [blame] | 8 | import org.onlab.onos.net.NetworkResource; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 9 | import org.onlab.onos.net.Path; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 10 | |
| 11 | import com.google.common.base.MoreObjects; |
Brian O'Connor | 4908d60 | 2014-10-23 15:58:20 -0700 | [diff] [blame] | 12 | import com.google.common.collect.ImmutableSet; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 13 | |
Brian O'Connor | 4908d60 | 2014-10-23 15:58:20 -0700 | [diff] [blame] | 14 | public class OpticalPathIntent extends Intent { |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 15 | |
| 16 | private final ConnectPoint src; |
| 17 | private final ConnectPoint dst; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 18 | private final Path path; |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 19 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 20 | |
weibit | 7e58346 | 2014-10-23 10:14:05 -0700 | [diff] [blame] | 21 | public OpticalPathIntent(ApplicationId appId, |
| 22 | ConnectPoint src, |
| 23 | ConnectPoint dst, |
weibit | 7e58346 | 2014-10-23 10:14:05 -0700 | [diff] [blame] | 24 | Path path) { |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 25 | super(id(OpticalPathIntent.class, src, dst), |
Brian O'Connor | 4908d60 | 2014-10-23 15:58:20 -0700 | [diff] [blame] | 26 | appId, |
| 27 | ImmutableSet.<NetworkResource>copyOf(path.links())); |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 28 | this.src = src; |
| 29 | this.dst = dst; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 30 | this.path = path; |
| 31 | } |
| 32 | |
weibit | 9e622ac | 2014-10-23 13:45:44 -0700 | [diff] [blame] | 33 | protected OpticalPathIntent() { |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 34 | this.src = null; |
| 35 | this.dst = null; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 36 | this.path = null; |
| 37 | } |
| 38 | |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 39 | public ConnectPoint src() { |
| 40 | return src; |
| 41 | } |
| 42 | |
| 43 | public ConnectPoint dst() { |
| 44 | return dst; |
| 45 | } |
| 46 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 47 | public Path path() { |
| 48 | return path; |
| 49 | } |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 50 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 51 | @Override |
weibit | 7e58346 | 2014-10-23 10:14:05 -0700 | [diff] [blame] | 52 | public boolean isInstallable() { |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 53 | return true; |
| 54 | } |
| 55 | |
| 56 | @Override |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 57 | public String toString() { |
| 58 | return MoreObjects.toStringHelper(getClass()) |
| 59 | .add("id", id()) |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 60 | .add("ingressPort", src) |
| 61 | .add("egressPort", dst) |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 62 | .add("path", path) |
| 63 | .toString(); |
| 64 | } |
| 65 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 66 | public Collection<Link> requiredLinks() { |
| 67 | return path.links(); |
| 68 | } |
| 69 | } |