blob: 0789db0eea5ebff143c63344613fe33a560f41c3 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska83e090e2014-10-22 14:25:35 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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 Vachuska83e090e2014-10-22 14:25:35 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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 Vachuska83e090e2014-10-22 14:25:35 -070015 */
Brian O'Connorb876bf12014-10-02 14:59:37 -070016package org.onlab.onos.net.intent;
17
tom95329eb2014-10-06 08:40:06 -070018import com.google.common.base.MoreObjects;
Thomas Vachuskae0f804a2014-10-27 23:40:48 -070019import org.onlab.onos.core.ApplicationId;
Brian O'Connorb876bf12014-10-02 14:59:37 -070020import org.onlab.onos.net.Path;
21import org.onlab.onos.net.flow.TrafficSelector;
22import org.onlab.onos.net.flow.TrafficTreatment;
Ray Milkeycaa450b2014-10-29 15:54:24 -070023import org.onlab.onos.net.resource.LinkResourceRequest;
Brian O'Connorb876bf12014-10-02 14:59:37 -070024
Brian O'Connorb876bf12014-10-02 14:59:37 -070025/**
26 * Abstraction of explicitly path specified connectivity intent.
27 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070028public class PathIntent extends ConnectivityIntent {
Brian O'Connorb876bf12014-10-02 14:59:37 -070029
30 private final Path path;
Ray Milkeycaa450b2014-10-29 15:54:24 -070031 private final LinkResourceRequest[] resourceRequests;
Brian O'Connorb876bf12014-10-02 14:59:37 -070032
33 /**
34 * Creates a new point-to-point intent with the supplied ingress/egress
35 * ports and using the specified explicit path.
36 *
Thomas Vachuskac96058a2014-10-20 23:00:16 -070037 * @param appId application identifier
38 * @param selector traffic selector
39 * @param treatment treatment
40 * @param path traversed links
Brian O'Connorb876bf12014-10-02 14:59:37 -070041 * @throws NullPointerException {@code path} is null
42 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070043 public PathIntent(ApplicationId appId, TrafficSelector selector,
Ray Milkeycaa450b2014-10-29 15:54:24 -070044 TrafficTreatment treatment, Path path, LinkResourceRequest[] resourceRequests) {
Thomas Vachuskac96058a2014-10-20 23:00:16 -070045 super(id(PathIntent.class, selector, treatment, path), appId,
46 resources(path.links()), selector, treatment);
Brian O'Connorb876bf12014-10-02 14:59:37 -070047 this.path = path;
Ray Milkeycaa450b2014-10-29 15:54:24 -070048 this.resourceRequests = resourceRequests;
Brian O'Connorb876bf12014-10-02 14:59:37 -070049 }
50
Thomas Vachuskac96058a2014-10-20 23:00:16 -070051 /**
52 * Constructor for serializer.
53 */
Brian O'Connorb876bf12014-10-02 14:59:37 -070054 protected PathIntent() {
55 super();
56 this.path = null;
Ray Milkeycaa450b2014-10-29 15:54:24 -070057 this.resourceRequests = new LinkResourceRequest[0];
Brian O'Connorb876bf12014-10-02 14:59:37 -070058 }
59
60 /**
61 * Returns the links which the traffic goes along.
62 *
63 * @return traversed links
64 */
tom85258ee2014-10-07 00:10:02 -070065 public Path path() {
Brian O'Connorb876bf12014-10-02 14:59:37 -070066 return path;
67 }
68
69 @Override
Thomas Vachuskac96058a2014-10-20 23:00:16 -070070 public boolean isInstallable() {
Brian O'Connorb876bf12014-10-02 14:59:37 -070071 return true;
72 }
73
Ray Milkeycaa450b2014-10-29 15:54:24 -070074 public LinkResourceRequest[] resourceRequests() {
75 return resourceRequests;
76 }
77
Brian O'Connorb876bf12014-10-02 14:59:37 -070078 @Override
Brian O'Connorb876bf12014-10-02 14:59:37 -070079 public String toString() {
80 return MoreObjects.toStringHelper(getClass())
tom85258ee2014-10-07 00:10:02 -070081 .add("id", id())
Thomas Vachuskae291c842014-10-21 02:52:38 -070082 .add("appId", appId())
83 .add("selector", selector())
84 .add("treatment", treatment())
Brian O'Connorb876bf12014-10-02 14:59:37 -070085 .add("path", path)
86 .toString();
87 }
tom95329eb2014-10-06 08:40:06 -070088
Brian O'Connorb876bf12014-10-02 14:59:37 -070089}