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