Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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. |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 16 | package org.onlab.onos.net.intent; |
| 17 | |
Ray Milkey | 460f402 | 2014-11-05 15:41:43 -0800 | [diff] [blame^] | 18 | import java.util.List; |
| 19 | |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 20 | import com.google.common.base.MoreObjects; |
Thomas Vachuska | e0f804a | 2014-10-27 23:40:48 -0700 | [diff] [blame] | 21 | import org.onlab.onos.core.ApplicationId; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 22 | import org.onlab.onos.net.Path; |
| 23 | import org.onlab.onos.net.flow.TrafficSelector; |
| 24 | import org.onlab.onos.net.flow.TrafficTreatment; |
| 25 | |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 26 | /** |
| 27 | * Abstraction of explicitly path specified connectivity intent. |
| 28 | */ |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 29 | public class PathIntent extends ConnectivityIntent { |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 30 | |
| 31 | private final Path path; |
| 32 | |
| 33 | /** |
| 34 | * Creates a new point-to-point intent with the supplied ingress/egress |
| 35 | * ports and using the specified explicit path. |
| 36 | * |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 37 | * @param appId application identifier |
| 38 | * @param selector traffic selector |
| 39 | * @param treatment treatment |
| 40 | * @param path traversed links |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 41 | * @throws NullPointerException {@code path} is null |
| 42 | */ |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 43 | public PathIntent(ApplicationId appId, TrafficSelector selector, |
Thomas Vachuska | edc944c | 2014-11-04 15:42:25 -0800 | [diff] [blame] | 44 | TrafficTreatment treatment, Path path) { |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 45 | super(id(PathIntent.class, selector, treatment, path), appId, |
| 46 | resources(path.links()), selector, treatment); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 47 | this.path = path; |
| 48 | } |
| 49 | |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 50 | /** |
Ray Milkey | 460f402 | 2014-11-05 15:41:43 -0800 | [diff] [blame^] | 51 | * Creates a new point-to-point intent with the supplied ingress/egress |
| 52 | * ports and using the specified explicit path. |
| 53 | * |
| 54 | * @param appId application identifier |
| 55 | * @param selector traffic selector |
| 56 | * @param treatment treatment |
| 57 | * @param path traversed links |
| 58 | * @param constraints optional list of constraints |
| 59 | * @throws NullPointerException {@code path} is null |
| 60 | */ |
| 61 | public PathIntent(ApplicationId appId, TrafficSelector selector, |
| 62 | TrafficTreatment treatment, Path path, List<Constraint> constraints) { |
| 63 | super(id(PathIntent.class, selector, treatment, path, constraints), appId, |
| 64 | resources(path.links()), selector, treatment, constraints); |
| 65 | this.path = path; |
| 66 | } |
| 67 | |
| 68 | /** |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 69 | * Constructor for serializer. |
| 70 | */ |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 71 | protected PathIntent() { |
| 72 | super(); |
| 73 | this.path = null; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Returns the links which the traffic goes along. |
| 78 | * |
| 79 | * @return traversed links |
| 80 | */ |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 81 | public Path path() { |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 82 | return path; |
| 83 | } |
| 84 | |
| 85 | @Override |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 86 | public boolean isInstallable() { |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 87 | return true; |
| 88 | } |
| 89 | |
Ray Milkey | caa450b | 2014-10-29 15:54:24 -0700 | [diff] [blame] | 90 | |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 91 | @Override |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 92 | public String toString() { |
| 93 | return MoreObjects.toStringHelper(getClass()) |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 94 | .add("id", id()) |
Thomas Vachuska | e291c84 | 2014-10-21 02:52:38 -0700 | [diff] [blame] | 95 | .add("appId", appId()) |
| 96 | .add("selector", selector()) |
| 97 | .add("treatment", treatment()) |
Ray Milkey | 460f402 | 2014-11-05 15:41:43 -0800 | [diff] [blame^] | 98 | .add("constraints", constraints()) |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 99 | .add("path", path) |
| 100 | .toString(); |
| 101 | } |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 102 | |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 103 | } |