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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.intent; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 17 | |
| 18 | import java.util.Collection; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 19 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 20 | import org.onosproject.core.ApplicationId; |
| 21 | import org.onosproject.net.ConnectPoint; |
| 22 | import org.onosproject.net.Link; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 23 | import org.onosproject.net.Path; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 24 | |
| 25 | import com.google.common.base.MoreObjects; |
Brian O'Connor | 4908d60 | 2014-10-23 15:58:20 -0700 | [diff] [blame] | 26 | import com.google.common.collect.ImmutableSet; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 27 | |
Brian O'Connor | 4908d60 | 2014-10-23 15:58:20 -0700 | [diff] [blame] | 28 | public class OpticalPathIntent extends Intent { |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 29 | |
| 30 | private final ConnectPoint src; |
| 31 | private final ConnectPoint dst; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 32 | private final Path path; |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 33 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 34 | |
weibit | 7e58346 | 2014-10-23 10:14:05 -0700 | [diff] [blame] | 35 | public OpticalPathIntent(ApplicationId appId, |
| 36 | ConnectPoint src, |
| 37 | ConnectPoint dst, |
weibit | 7e58346 | 2014-10-23 10:14:05 -0700 | [diff] [blame] | 38 | Path path) { |
Sho SHIMIZU | 2c255db | 2014-12-09 15:49:15 -0800 | [diff] [blame] | 39 | super(appId, ImmutableSet.copyOf(path.links())); |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 40 | this.src = src; |
| 41 | this.dst = dst; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 42 | this.path = path; |
| 43 | } |
| 44 | |
weibit | 9e622ac | 2014-10-23 13:45:44 -0700 | [diff] [blame] | 45 | protected OpticalPathIntent() { |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 46 | this.src = null; |
| 47 | this.dst = null; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 48 | this.path = null; |
| 49 | } |
| 50 | |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 51 | public ConnectPoint src() { |
| 52 | return src; |
| 53 | } |
| 54 | |
| 55 | public ConnectPoint dst() { |
| 56 | return dst; |
| 57 | } |
| 58 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 59 | public Path path() { |
| 60 | return path; |
| 61 | } |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 62 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 63 | @Override |
weibit | 7e58346 | 2014-10-23 10:14:05 -0700 | [diff] [blame] | 64 | public boolean isInstallable() { |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 65 | return true; |
| 66 | } |
| 67 | |
| 68 | @Override |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 69 | public String toString() { |
| 70 | return MoreObjects.toStringHelper(getClass()) |
| 71 | .add("id", id()) |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 72 | .add("ingressPort", src) |
| 73 | .add("egressPort", dst) |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 74 | .add("path", path) |
| 75 | .toString(); |
| 76 | } |
| 77 | |
Praseed Balakrishnan | 00dd1f9 | 2014-11-19 17:12:36 -0800 | [diff] [blame] | 78 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 79 | public Collection<Link> requiredLinks() { |
| 80 | return path.links(); |
| 81 | } |
| 82 | } |