blob: 1fe1617e71cbe0be35357c08224df2bf8052d693 [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska58de4162015-09-10 16:15:33 -07003 *
4 * 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
7 *
8 * 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.
15 */
Michele Santuari4b6019e2014-12-19 11:31:45 +010016package org.onosproject.net.intent;
17
Michele Santuari4b6019e2014-12-19 11:31:45 +010018import java.util.List;
19import java.util.Optional;
20
Brian O'Connor9476fa12015-06-25 15:17:17 -040021import com.google.common.annotations.Beta;
Michele Santuari4b6019e2014-12-19 11:31:45 +010022import org.onlab.packet.MplsLabel;
23import org.onosproject.core.ApplicationId;
24import org.onosproject.net.Path;
25import org.onosproject.net.flow.TrafficSelector;
26import org.onosproject.net.flow.TrafficTreatment;
27
Ray Milkeyebc5d222015-03-18 15:45:36 -070028import static com.google.common.base.Preconditions.checkNotNull;
29
Michele Santuari4b6019e2014-12-19 11:31:45 +010030
31/**
32 * Abstraction of explicit MPLS label-switched path.
Michele Santuari6096acd2016-02-09 17:00:37 +010033 *
34 * @deprecated in Goldeneye Release, in favour of encapsulation
35 * constraint {@link org.onosproject.net.intent.constraint.EncapsulationConstraint}
Michele Santuari4b6019e2014-12-19 11:31:45 +010036 */
Brian O'Connor9476fa12015-06-25 15:17:17 -040037@Beta
Michele Santuari6096acd2016-02-09 17:00:37 +010038@Deprecated
Ray Milkeybd4f0112015-03-02 17:07:09 -080039public final class MplsPathIntent extends PathIntent {
Michele Santuari4b6019e2014-12-19 11:31:45 +010040
Ray Milkeybd4f0112015-03-02 17:07:09 -080041 private final Optional<MplsLabel> ingressLabel;
42 private final Optional<MplsLabel> egressLabel;
Michele Santuari4b6019e2014-12-19 11:31:45 +010043
44 /**
45 * Creates a new point-to-point intent with the supplied ingress/egress
46 * ports and using the specified explicit path.
47 *
48 * @param appId application identifier
ilhem fajjarib0a06842015-11-02 18:59:02 +010049 * @param key intent key
Michele Santuari4b6019e2014-12-19 11:31:45 +010050 * @param selector traffic selector
51 * @param treatment treatment
52 * @param path traversed links
53 * @param ingressLabel MPLS egress label
54 * @param egressLabel MPLS ingress label
Michele Santuari4b6019e2014-12-19 11:31:45 +010055 * @param constraints optional list of constraints
Ray Milkey50a9b722015-03-12 10:38:55 -070056 * @param priority priority to use for flows generated by this intent
Michele Santuari4b6019e2014-12-19 11:31:45 +010057 * @throws NullPointerException {@code path} is null
58 */
ilhem fajjarib0a06842015-11-02 18:59:02 +010059 private MplsPathIntent(ApplicationId appId, Key key, TrafficSelector selector,
Michele Santuari4b6019e2014-12-19 11:31:45 +010060 TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel,
Ray Milkey50a9b722015-03-12 10:38:55 -070061 Optional<MplsLabel> egressLabel, List<Constraint> constraints,
62 int priority) {
ilhem fajjarib0a06842015-11-02 18:59:02 +010063 super(appId, key, selector, treatment, path, constraints,
Ray Milkey50a9b722015-03-12 10:38:55 -070064 priority);
Michele Santuari4b6019e2014-12-19 11:31:45 +010065
Ray Milkeyebc5d222015-03-18 15:45:36 -070066 this.ingressLabel = checkNotNull(ingressLabel);
67 this.egressLabel = checkNotNull(egressLabel);
Michele Santuari4b6019e2014-12-19 11:31:45 +010068 }
69
70 /**
Ray Milkeyebc5d222015-03-18 15:45:36 -070071 * Returns a new host to host intent builder.
72 *
73 * @return host to host intent builder
74 */
75 public static Builder builder() {
76 return new Builder();
77 }
78
79 /**
80 * Builder of a host to host intent.
81 */
82 public static final class Builder extends PathIntent.Builder {
83 private Optional<MplsLabel> ingressLabel = Optional.empty();
84 private Optional<MplsLabel> egressLabel = Optional.empty();
85
86 private Builder() {
87 // Hide constructor
88 }
89
90 @Override
91 public Builder appId(ApplicationId appId) {
92 return (Builder) super.appId(appId);
93 }
94
95 @Override
96 public Builder key(Key key) {
97 return (Builder) super.key(key);
98 }
99
100 @Override
101 public Builder selector(TrafficSelector selector) {
102 return (Builder) super.selector(selector);
103 }
104
105 @Override
106 public Builder treatment(TrafficTreatment treatment) {
107 return (Builder) super.treatment(treatment);
108 }
109
110 @Override
111 public Builder constraints(List<Constraint> constraints) {
112 return (Builder) super.constraints(constraints);
113 }
114
115 @Override
116 public Builder priority(int priority) {
117 return (Builder) super.priority(priority);
118 }
119
120 @Override
121 public Builder path(Path path) {
122 return (Builder) super.path(path);
123 }
124
125 /**
126 * Sets the ingress label of the intent that will be built.
127 *
128 * @param ingressLabel ingress label
129 * @return this builder
130 */
131 public Builder ingressLabel(Optional<MplsLabel> ingressLabel) {
132 this.ingressLabel = ingressLabel;
133 return this;
134 }
135
136 /**
137 * Sets the ingress label of the intent that will be built.
138 *
139 * @param egressLabel ingress label
140 * @return this builder
141 */
142 public Builder egressLabel(Optional<MplsLabel> egressLabel) {
143 this.egressLabel = egressLabel;
144 return this;
145 }
146
147
148 /**
149 * Builds a host to host intent from the accumulated parameters.
150 *
151 * @return point to point intent
152 */
153 public MplsPathIntent build() {
154
155 return new MplsPathIntent(
156 appId,
ilhem fajjarib0a06842015-11-02 18:59:02 +0100157 key,
Ray Milkeyebc5d222015-03-18 15:45:36 -0700158 selector,
159 treatment,
160 path,
161 ingressLabel,
162 egressLabel,
163 constraints,
164 priority
165 );
166 }
167 }
168
169
170 /**
Michele Santuari4b6019e2014-12-19 11:31:45 +0100171 * Returns the MPLS label which the ingress traffic should tagged.
172 *
173 * @return ingress MPLS label
174 */
175 public Optional<MplsLabel> ingressLabel() {
176 return ingressLabel;
177 }
178
179 /**
180 * Returns the MPLS label which the egress traffic should tagged.
181 *
182 * @return egress MPLS label
183 */
184 public Optional<MplsLabel> egressLabel() {
185 return egressLabel;
186 }
187
188}