blob: e630b49ecac26e08a3d978c976d3d07aff8be28c [file] [log] [blame]
Marc De Leenheer8c2caac2015-05-28 16:37:33 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Marc De Leenheer8c2caac2015-05-28 16:37: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 */
16package org.onosproject.net.intent;
17
Brian O'Connor9476fa12015-06-25 15:17:17 -040018import com.google.common.annotations.Beta;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070019import com.google.common.base.MoreObjects;
20import org.onosproject.core.ApplicationId;
Toru Furusawa72ee30c2016-01-08 13:29:04 -080021import org.onosproject.net.CltSignalType;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070022import org.onosproject.net.ConnectPoint;
Luca Prete670ac5d2017-02-03 15:55:43 -080023import org.onosproject.net.ResourceGroup;
alessioda025c42020-07-17 13:00:28 +020024import org.onosproject.net.OchSignal;
25import org.onosproject.net.Path;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070026
27import java.util.Collections;
alessioda025c42020-07-17 13:00:28 +020028import java.util.Optional;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070029
30import static com.google.common.base.Preconditions.checkNotNull;
31
32/**
33 * An optical layer intent for circuits between two OduClt ports.
34 * No traffic selector or traffic treatment are needed.
35 */
Brian O'Connor9476fa12015-06-25 15:17:17 -040036@Beta
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070037public class OpticalCircuitIntent extends Intent {
38 private final ConnectPoint src;
39 private final ConnectPoint dst;
Toru Furusawa72ee30c2016-01-08 13:29:04 -080040 private final CltSignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070041 private final boolean isBidirectional;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070042
alessioda025c42020-07-17 13:00:28 +020043 private final Optional<OchSignal> ochSignal;
44 private final Optional<Path> suggestedPath;
45
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070046 /**
47 * Creates an optical circuit intent between the specified
48 * connection points.
49 *
50 * @param appId application identification
51 * @param key intent key
52 * @param src the source transponder port
53 * @param dst the destination transponder port
54 * @param signalType ODU signal type
Brian O'Connor85cf4da2015-06-05 23:44:28 -070055 * @param isBidirectional indicate if intent is bidirectional
alessioda025c42020-07-17 13:00:28 +020056 * @param ochSignal optional suggested signal
57 * @param suggestedPath optional suggested path
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070058 * @param priority priority to use for flows from this intent
Luca Prete670ac5d2017-02-03 15:55:43 -080059 * @param resourceGroup resource group for this intent
60 */
alessioda025c42020-07-17 13:00:28 +020061 protected OpticalCircuitIntent(ApplicationId appId,
62 Key key,
63 ConnectPoint src,
64 ConnectPoint dst,
65 CltSignalType signalType,
66 boolean isBidirectional,
67 Optional<OchSignal> ochSignal,
68 Optional<Path> suggestedPath,
69 int priority,
Luca Prete670ac5d2017-02-03 15:55:43 -080070 ResourceGroup resourceGroup) {
71 super(appId, key, Collections.emptyList(), priority, resourceGroup);
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070072 this.src = checkNotNull(src);
73 this.dst = checkNotNull(dst);
74 this.signalType = checkNotNull(signalType);
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070075 this.isBidirectional = isBidirectional;
alessioda025c42020-07-17 13:00:28 +020076 this.ochSignal = ochSignal;
77 this.suggestedPath = suggestedPath;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070078 }
79
80 /**
81 * Returns a new optical circuit intent builder.
82 *
83 * @return host to host intent builder
84 */
85 public static Builder builder() {
86 return new Builder();
87 }
88
89
90 /**
91 * Builder for optical circuit intents.
92 */
93 public static class Builder extends Intent.Builder {
94 private ConnectPoint src;
95 private ConnectPoint dst;
Toru Furusawa72ee30c2016-01-08 13:29:04 -080096 private CltSignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070097 private boolean isBidirectional;
alessioda025c42020-07-17 13:00:28 +020098 private Optional<OchSignal> ochSignal = Optional.empty();
99 private Optional<Path> suggestedPath = Optional.empty();
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700100
101 @Override
102 public Builder appId(ApplicationId appId) {
103 return (Builder) super.appId(appId);
104 }
105
106 @Override
107 public Builder key(Key key) {
108 return (Builder) super.key(key);
109 }
110
111 @Override
112 public Builder priority(int priority) {
113 return (Builder) super.priority(priority);
114 }
115
Luca Prete670ac5d2017-02-03 15:55:43 -0800116 @Override
117 public Builder resourceGroup(ResourceGroup resourceGroup) {
118 return (Builder) super.resourceGroup(resourceGroup);
119 }
120
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700121 /**
122 * Sets the source for the intent that will be built.
123 *
124 * @param src source to use for built intent
125 * @return this builder
126 */
127 public Builder src(ConnectPoint src) {
128 this.src = src;
129 return this;
130 }
131
132 /**
133 * Sets the destination for the intent that will be built.
134 *
135 * @param dst dest to use for built intent
136 * @return this builder
137 */
138 public Builder dst(ConnectPoint dst) {
139 this.dst = dst;
140 return this;
141 }
142
143 /**
144 * Sets the ODU signal type for the intent that will be built.
145 *
146 * @param signalType signal type to use for built intent
147 * @return this builder
148 */
Toru Furusawa72ee30c2016-01-08 13:29:04 -0800149 public Builder signalType(CltSignalType signalType) {
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700150 this.signalType = signalType;
151 return this;
152 }
153
154 /**
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700155 * Sets the directionality of the intent.
156 *
157 * @param isBidirectional true if bidirectional, false if unidirectional
158 * @return this builder
159 */
160 public Builder bidirectional(boolean isBidirectional) {
161 this.isBidirectional = isBidirectional;
162 return this;
163 }
164
165 /**
alessioda025c42020-07-17 13:00:28 +0200166 * Sets the OCh signal of the intent.
167 *
168 * @param ochSignal the lambda
169 * @return this builder
170 */
171 public OpticalCircuitIntent.Builder ochSignal(Optional<OchSignal> ochSignal) {
172 this.ochSignal = ochSignal;
173 return this;
174 }
175
176 /**
177 * Sets the suggestedPath of the intent.
178 *
179 * @param suggestedPath the path
180 * @return this builder
181 */
182 public OpticalCircuitIntent.Builder suggestedPath(Optional<Path> suggestedPath) {
183 this.suggestedPath = suggestedPath;
184 return this;
185 }
186
187 /**
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700188 * Builds an optical circuit intent from the accumulated parameters.
189 *
190 * @return point to point intent
191 */
192 public OpticalCircuitIntent build() {
193
194 return new OpticalCircuitIntent(
195 appId,
196 key,
197 src,
198 dst,
199 signalType,
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700200 isBidirectional,
alessioda025c42020-07-17 13:00:28 +0200201 ochSignal,
202 suggestedPath,
Luca Prete670ac5d2017-02-03 15:55:43 -0800203 priority,
204 resourceGroup
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700205 );
206 }
207 }
208
209 /**
210 * Constructor for serializer.
211 */
212 protected OpticalCircuitIntent() {
213 super();
214 this.src = null;
215 this.dst = null;
216 this.signalType = null;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700217 this.isBidirectional = false;
alessioda025c42020-07-17 13:00:28 +0200218 this.ochSignal = null;
219 this.suggestedPath = null;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700220 }
221
222 /**
223 * Returns the source transponder port.
224 *
225 * @return source transponder port
226 */
227 public ConnectPoint getSrc() {
228 return src;
229 }
230
231 /**
232 * Returns the destination transponder port.
233 *
234 * @return source transponder port
235 */
236 public ConnectPoint getDst() {
237 return dst;
238 }
239
240 /**
241 * Returns the ODU signal type.
242 *
243 * @return ODU signal type
244 */
Toru Furusawa72ee30c2016-01-08 13:29:04 -0800245 public CltSignalType getSignalType() {
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700246 return signalType;
247 }
248
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700249 /**
250 * Returns the directionality of the intent.
251 *
252 * @return true if bidirectional, false if unidirectional
253 */
254 public boolean isBidirectional() {
255 return isBidirectional;
256 }
257
alessioda025c42020-07-17 13:00:28 +0200258 /**
259 * Returns the OCh signal of the intent.
260 *
261 * @return the lambda
262 */
263
264 public Optional<OchSignal> ochSignal() {
265 return ochSignal;
266 }
267
268 /**
269 * Returns the suggestedPath of the intent.
270 *
271 * @return the suggestedPath
272 */
273 public Optional<Path> suggestedPath() {
274 return suggestedPath;
275 }
276
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700277 @Override
278 public String toString() {
279 return MoreObjects.toStringHelper(this)
280 .add("id", id())
281 .add("key", key())
282 .add("appId", appId())
283 .add("priority", priority())
284 .add("resources", resources())
285 .add("src", src)
286 .add("dst", dst)
287 .add("signalType", signalType)
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700288 .add("isBidirectional", isBidirectional)
alessioda025c42020-07-17 13:00:28 +0200289 .add("ochSignal", ochSignal)
290 .add("suggestedPath", suggestedPath)
Luca Prete670ac5d2017-02-03 15:55:43 -0800291 .add("resourceGroup", resourceGroup())
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700292 .toString();
293 }
294
295}