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