blob: 7a0e365ee6a6d855613bfdfbca7a56a4430b0b88 [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
Sho SHIMIZUc3df36b2014-11-11 18:19:29 -080018import java.util.Collections;
Ray Milkey460f4022014-11-05 15:41:43 -080019import java.util.List;
20
tom95329eb2014-10-06 08:40:06 -070021import com.google.common.base.MoreObjects;
Thomas Vachuskae0f804a2014-10-27 23:40:48 -070022import org.onlab.onos.core.ApplicationId;
Brian O'Connorb876bf12014-10-02 14:59:37 -070023import org.onlab.onos.net.Path;
24import org.onlab.onos.net.flow.TrafficSelector;
25import org.onlab.onos.net.flow.TrafficTreatment;
26
Brian O'Connorb876bf12014-10-02 14:59:37 -070027/**
28 * Abstraction of explicitly path specified connectivity intent.
29 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070030public class PathIntent extends ConnectivityIntent {
Brian O'Connorb876bf12014-10-02 14:59:37 -070031
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 Vachuskac96058a2014-10-20 23:00:16 -070038 * @param appId application identifier
39 * @param selector traffic selector
40 * @param treatment treatment
41 * @param path traversed links
Brian O'Connorb876bf12014-10-02 14:59:37 -070042 * @throws NullPointerException {@code path} is null
43 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070044 public PathIntent(ApplicationId appId, TrafficSelector selector,
Thomas Vachuskaedc944c2014-11-04 15:42:25 -080045 TrafficTreatment treatment, Path path) {
Sho SHIMIZUc3df36b2014-11-11 18:19:29 -080046 this(appId, selector, treatment, path, Collections.emptyList());
Brian O'Connorb876bf12014-10-02 14:59:37 -070047 }
48
Thomas Vachuskac96058a2014-10-20 23:00:16 -070049 /**
Ray Milkey460f4022014-11-05 15:41:43 -080050 * Creates a new point-to-point intent with the supplied ingress/egress
51 * ports and using the specified explicit path.
52 *
53 * @param appId application identifier
54 * @param selector traffic selector
55 * @param treatment treatment
56 * @param path traversed links
57 * @param constraints optional list of constraints
58 * @throws NullPointerException {@code path} is null
59 */
60 public PathIntent(ApplicationId appId, TrafficSelector selector,
61 TrafficTreatment treatment, Path path, List<Constraint> constraints) {
62 super(id(PathIntent.class, selector, treatment, path, constraints), appId,
63 resources(path.links()), selector, treatment, constraints);
64 this.path = path;
65 }
66
67 /**
Thomas Vachuskac96058a2014-10-20 23:00:16 -070068 * Constructor for serializer.
69 */
Brian O'Connorb876bf12014-10-02 14:59:37 -070070 protected PathIntent() {
71 super();
72 this.path = null;
73 }
74
75 /**
76 * Returns the links which the traffic goes along.
77 *
78 * @return traversed links
79 */
tom85258ee2014-10-07 00:10:02 -070080 public Path path() {
Brian O'Connorb876bf12014-10-02 14:59:37 -070081 return path;
82 }
83
84 @Override
Thomas Vachuskac96058a2014-10-20 23:00:16 -070085 public boolean isInstallable() {
Brian O'Connorb876bf12014-10-02 14:59:37 -070086 return true;
87 }
88
Ray Milkeycaa450b2014-10-29 15:54:24 -070089
Brian O'Connorb876bf12014-10-02 14:59:37 -070090 @Override
Brian O'Connorb876bf12014-10-02 14:59:37 -070091 public String toString() {
92 return MoreObjects.toStringHelper(getClass())
tom85258ee2014-10-07 00:10:02 -070093 .add("id", id())
Thomas Vachuskae291c842014-10-21 02:52:38 -070094 .add("appId", appId())
95 .add("selector", selector())
96 .add("treatment", treatment())
Ray Milkey460f4022014-11-05 15:41:43 -080097 .add("constraints", constraints())
Brian O'Connorb876bf12014-10-02 14:59:37 -070098 .add("path", path)
99 .toString();
100 }
tom95329eb2014-10-06 08:40:06 -0700101
Brian O'Connorb876bf12014-10-02 14:59:37 -0700102}