blob: 721a8fd76121c4ad97afbd903f3dad9482d237b7 [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;
23
Brian O'Connorb876bf12014-10-02 14:59:37 -070024/**
25 * Abstraction of explicitly path specified connectivity intent.
26 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070027public class PathIntent extends ConnectivityIntent {
Brian O'Connorb876bf12014-10-02 14:59:37 -070028
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 Vachuskac96058a2014-10-20 23:00:16 -070035 * @param appId application identifier
36 * @param selector traffic selector
37 * @param treatment treatment
38 * @param path traversed links
Brian O'Connorb876bf12014-10-02 14:59:37 -070039 * @throws NullPointerException {@code path} is null
40 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070041 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'Connorb876bf12014-10-02 14:59:37 -070045 this.path = path;
46 }
47
Thomas Vachuskac96058a2014-10-20 23:00:16 -070048 /**
49 * Constructor for serializer.
50 */
Brian O'Connorb876bf12014-10-02 14:59:37 -070051 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 */
tom85258ee2014-10-07 00:10:02 -070061 public Path path() {
Brian O'Connorb876bf12014-10-02 14:59:37 -070062 return path;
63 }
64
65 @Override
Thomas Vachuskac96058a2014-10-20 23:00:16 -070066 public boolean isInstallable() {
Brian O'Connorb876bf12014-10-02 14:59:37 -070067 return true;
68 }
69
70 @Override
Brian O'Connorb876bf12014-10-02 14:59:37 -070071 public String toString() {
72 return MoreObjects.toStringHelper(getClass())
tom85258ee2014-10-07 00:10:02 -070073 .add("id", id())
Thomas Vachuskae291c842014-10-21 02:52:38 -070074 .add("appId", appId())
75 .add("selector", selector())
76 .add("treatment", treatment())
Brian O'Connorb876bf12014-10-02 14:59:37 -070077 .add("path", path)
78 .toString();
79 }
tom95329eb2014-10-06 08:40:06 -070080
Brian O'Connorb876bf12014-10-02 14:59:37 -070081}