blob: 9f8816d7068ad06661cb0ff9c9d8ab0550071027 [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
Ray Milkey460f4022014-11-05 15:41:43 -080018import java.util.List;
19
tom95329eb2014-10-06 08:40:06 -070020import com.google.common.base.MoreObjects;
Thomas Vachuskae0f804a2014-10-27 23:40:48 -070021import org.onlab.onos.core.ApplicationId;
Brian O'Connorb876bf12014-10-02 14:59:37 -070022import org.onlab.onos.net.Path;
23import org.onlab.onos.net.flow.TrafficSelector;
24import org.onlab.onos.net.flow.TrafficTreatment;
25
Brian O'Connorb876bf12014-10-02 14:59:37 -070026/**
27 * Abstraction of explicitly path specified connectivity intent.
28 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070029public class PathIntent extends ConnectivityIntent {
Brian O'Connorb876bf12014-10-02 14:59:37 -070030
31 private final Path path;
32
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,
Thomas Vachuskaedc944c2014-11-04 15:42:25 -080044 TrafficTreatment treatment, Path path) {
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;
48 }
49
Thomas Vachuskac96058a2014-10-20 23:00:16 -070050 /**
Ray Milkey460f4022014-11-05 15:41:43 -080051 * Creates a new point-to-point intent with the supplied ingress/egress
52 * ports and using the specified explicit path.
53 *
54 * @param appId application identifier
55 * @param selector traffic selector
56 * @param treatment treatment
57 * @param path traversed links
58 * @param constraints optional list of constraints
59 * @throws NullPointerException {@code path} is null
60 */
61 public PathIntent(ApplicationId appId, TrafficSelector selector,
62 TrafficTreatment treatment, Path path, List<Constraint> constraints) {
63 super(id(PathIntent.class, selector, treatment, path, constraints), appId,
64 resources(path.links()), selector, treatment, constraints);
65 this.path = path;
66 }
67
68 /**
Thomas Vachuskac96058a2014-10-20 23:00:16 -070069 * Constructor for serializer.
70 */
Brian O'Connorb876bf12014-10-02 14:59:37 -070071 protected PathIntent() {
72 super();
73 this.path = null;
74 }
75
76 /**
77 * Returns the links which the traffic goes along.
78 *
79 * @return traversed links
80 */
tom85258ee2014-10-07 00:10:02 -070081 public Path path() {
Brian O'Connorb876bf12014-10-02 14:59:37 -070082 return path;
83 }
84
85 @Override
Thomas Vachuskac96058a2014-10-20 23:00:16 -070086 public boolean isInstallable() {
Brian O'Connorb876bf12014-10-02 14:59:37 -070087 return true;
88 }
89
Ray Milkeycaa450b2014-10-29 15:54:24 -070090
Brian O'Connorb876bf12014-10-02 14:59:37 -070091 @Override
Brian O'Connorb876bf12014-10-02 14:59:37 -070092 public String toString() {
93 return MoreObjects.toStringHelper(getClass())
tom85258ee2014-10-07 00:10:02 -070094 .add("id", id())
Thomas Vachuskae291c842014-10-21 02:52:38 -070095 .add("appId", appId())
96 .add("selector", selector())
97 .add("treatment", treatment())
Ray Milkey460f4022014-11-05 15:41:43 -080098 .add("constraints", constraints())
Brian O'Connorb876bf12014-10-02 14:59:37 -070099 .add("path", path)
100 .toString();
101 }
tom95329eb2014-10-06 08:40:06 -0700102
Brian O'Connorb876bf12014-10-02 14:59:37 -0700103}