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