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