Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 19 | package org.onlab.onos.net.intent; |
| 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, |
| 45 | TrafficTreatment treatment, Path path) { |
| 46 | super(id(PathIntent.class, selector, treatment, path), appId, |
| 47 | resources(path.links()), selector, treatment); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 48 | this.path = path; |
| 49 | } |
| 50 | |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 51 | /** |
| 52 | * Constructor for serializer. |
| 53 | */ |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 54 | protected PathIntent() { |
| 55 | super(); |
| 56 | this.path = null; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Returns the links which the traffic goes along. |
| 61 | * |
| 62 | * @return traversed links |
| 63 | */ |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 64 | public Path path() { |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 65 | return path; |
| 66 | } |
| 67 | |
| 68 | @Override |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 69 | public boolean isInstallable() { |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 70 | return true; |
| 71 | } |
| 72 | |
| 73 | @Override |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 74 | public String toString() { |
| 75 | return MoreObjects.toStringHelper(getClass()) |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 76 | .add("id", id()) |
Thomas Vachuska | e291c84 | 2014-10-21 02:52:38 -0700 | [diff] [blame] | 77 | .add("appId", appId()) |
| 78 | .add("selector", selector()) |
| 79 | .add("treatment", treatment()) |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 80 | .add("path", path) |
| 81 | .toString(); |
| 82 | } |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 83 | |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 84 | } |