Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 16 | package org.onlab.onos.net.intent; |
| 17 | |
| 18 | import java.util.Collection; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 19 | |
Thomas Vachuska | e0f804a | 2014-10-27 23:40:48 -0700 | [diff] [blame] | 20 | import org.onlab.onos.core.ApplicationId; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 21 | import org.onlab.onos.net.ConnectPoint; |
| 22 | import org.onlab.onos.net.Link; |
Brian O'Connor | 4908d60 | 2014-10-23 15:58:20 -0700 | [diff] [blame] | 23 | import org.onlab.onos.net.NetworkResource; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 24 | import org.onlab.onos.net.Path; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 25 | |
| 26 | import com.google.common.base.MoreObjects; |
Brian O'Connor | 4908d60 | 2014-10-23 15:58:20 -0700 | [diff] [blame] | 27 | import com.google.common.collect.ImmutableSet; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 28 | |
Brian O'Connor | 4908d60 | 2014-10-23 15:58:20 -0700 | [diff] [blame] | 29 | public class OpticalPathIntent extends Intent { |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 30 | |
| 31 | private final ConnectPoint src; |
| 32 | private final ConnectPoint dst; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 33 | private final Path path; |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 34 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 35 | |
weibit | 7e58346 | 2014-10-23 10:14:05 -0700 | [diff] [blame] | 36 | public OpticalPathIntent(ApplicationId appId, |
| 37 | ConnectPoint src, |
| 38 | ConnectPoint dst, |
weibit | 7e58346 | 2014-10-23 10:14:05 -0700 | [diff] [blame] | 39 | Path path) { |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 40 | super(id(OpticalPathIntent.class, src, dst), |
Brian O'Connor | 4908d60 | 2014-10-23 15:58:20 -0700 | [diff] [blame] | 41 | appId, |
| 42 | ImmutableSet.<NetworkResource>copyOf(path.links())); |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 43 | this.src = src; |
| 44 | this.dst = dst; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 45 | this.path = path; |
| 46 | } |
| 47 | |
weibit | 9e622ac | 2014-10-23 13:45:44 -0700 | [diff] [blame] | 48 | protected OpticalPathIntent() { |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 49 | this.src = null; |
| 50 | this.dst = null; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 51 | this.path = null; |
| 52 | } |
| 53 | |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 54 | public ConnectPoint src() { |
| 55 | return src; |
| 56 | } |
| 57 | |
| 58 | public ConnectPoint dst() { |
| 59 | return dst; |
| 60 | } |
| 61 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 62 | public Path path() { |
| 63 | return path; |
| 64 | } |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 65 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 66 | @Override |
weibit | 7e58346 | 2014-10-23 10:14:05 -0700 | [diff] [blame] | 67 | public boolean isInstallable() { |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 68 | return true; |
| 69 | } |
| 70 | |
| 71 | @Override |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 72 | public String toString() { |
| 73 | return MoreObjects.toStringHelper(getClass()) |
| 74 | .add("id", id()) |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 75 | .add("ingressPort", src) |
| 76 | .add("egressPort", dst) |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 77 | .add("path", path) |
| 78 | .toString(); |
| 79 | } |
| 80 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 81 | public Collection<Link> requiredLinks() { |
| 82 | return path.links(); |
| 83 | } |
| 84 | } |