blob: f96a0bafecd5c1e56b6957a3744792daded2b0f0 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2014-present Open Networking Foundation
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.intent;
weibitf32383b2014-10-22 10:17:31 -070017
Brian O'Connor9476fa12015-06-25 15:17:17 -040018import com.google.common.annotations.Beta;
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +090019import com.google.common.base.MoreObjects;
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.core.ApplicationId;
21import org.onosproject.net.ConnectPoint;
Marc De Leenheeradfeffd2017-06-22 16:05:34 -070022import org.onosproject.net.OchSignal;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070023import org.onosproject.net.OduSignalType;
Luca Prete670ac5d2017-02-03 15:55:43 -080024import org.onosproject.net.ResourceGroup;
alessio3039bdb2018-11-29 14:12:32 +010025import org.onosproject.net.Path;
weibitf32383b2014-10-22 10:17:31 -070026
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +090027import java.util.Collections;
Marc De Leenheeradfeffd2017-06-22 16:05:34 -070028import java.util.Optional;
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +090029
Ray Milkeye076c792015-03-24 09:38:30 -070030import static com.google.common.base.Preconditions.checkNotNull;
Sho SHIMIZUd7d18002015-01-21 14:37:14 -080031
weibitf32383b2014-10-22 10:17:31 -070032/**
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070033 * An optical layer intent for connectivity between two OCh ports.
34 * No traffic selector or traffic treatment are needed.
alessio3039bdb2018-11-29 14:12:32 +010035 * OchSignal and suggestedPath are optional.
weibitf32383b2014-10-22 10:17:31 -070036 */
Brian O'Connor9476fa12015-06-25 15:17:17 -040037@Beta
Ray Milkeybd4f0112015-03-02 17:07:09 -080038public final class OpticalConnectivityIntent extends Intent {
39 private final ConnectPoint src;
40 private final ConnectPoint dst;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070041 private final OduSignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070042 private final boolean isBidirectional;
alessio3039bdb2018-11-29 14:12:32 +010043
Marc De Leenheeradfeffd2017-06-22 16:05:34 -070044 private final Optional<OchSignal> ochSignal;
alessio3039bdb2018-11-29 14:12:32 +010045 private final Optional<Path> suggestedPath;
weibitf32383b2014-10-22 10:17:31 -070046
47 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -070048 * Creates an optical connectivity intent between the specified
49 * connection points.
weibitf32383b2014-10-22 10:17:31 -070050 *
Thomas Vachuska4b420772014-10-30 16:46:17 -070051 * @param appId application identification
Ray Milkey5b3717e2015-02-05 11:44:08 -080052 * @param key intent key
53 * @param src the source transponder port
54 * @param dst the destination transponder port
Brian O'Connor85cf4da2015-06-05 23:44:28 -070055 * @param signalType signal type
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070056 * @param isBidirectional indicates if intent is unidirectional
Marc De Leenheeradfeffd2017-06-22 16:05:34 -070057 * @param ochSignal optional OCh signal
alessio3039bdb2018-11-29 14:12:32 +010058 * @param suggestedPath optional suggested path
Luca Prete670ac5d2017-02-03 15:55:43 -080059 * @param priority priority to use for flows from this intent
60 * @param resourceGroup resource group of this intent
61 */
62 protected OpticalConnectivityIntent(ApplicationId appId,
63 Key key,
64 ConnectPoint src,
65 ConnectPoint dst,
66 OduSignalType signalType,
67 boolean isBidirectional,
Marc De Leenheeradfeffd2017-06-22 16:05:34 -070068 Optional<OchSignal> ochSignal,
alessio3039bdb2018-11-29 14:12:32 +010069 Optional<Path> suggestedPath,
Luca Prete670ac5d2017-02-03 15:55:43 -080070 int priority,
71 ResourceGroup resourceGroup) {
72 super(appId, key, Collections.emptyList(), priority, resourceGroup);
Ray Milkeye076c792015-03-24 09:38:30 -070073 this.src = checkNotNull(src);
74 this.dst = checkNotNull(dst);
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070075 this.signalType = checkNotNull(signalType);
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070076 this.isBidirectional = isBidirectional;
Marc De Leenheeradfeffd2017-06-22 16:05:34 -070077 this.ochSignal = ochSignal;
alessio3039bdb2018-11-29 14:12:32 +010078 this.suggestedPath = suggestedPath;
weibitf32383b2014-10-22 10:17:31 -070079 }
80
Ray Milkeye076c792015-03-24 09:38:30 -070081 /**
82 * Returns a new optical connectivity intent builder.
83 *
84 * @return host to host intent builder
85 */
86 public static Builder builder() {
87 return new Builder();
88 }
89
90
91 /**
92 * Builder for optical connectivity intents.
93 */
94 public static class Builder extends Intent.Builder {
95 private ConnectPoint src;
96 private ConnectPoint dst;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070097 private OduSignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070098 private boolean isBidirectional;
Marc De Leenheeradfeffd2017-06-22 16:05:34 -070099 private Optional<OchSignal> ochSignal = Optional.empty();
alessio3039bdb2018-11-29 14:12:32 +0100100 private Optional<Path> suggestedPath = Optional.empty();
Ray Milkeye076c792015-03-24 09:38:30 -0700101
102 @Override
103 public Builder appId(ApplicationId appId) {
104 return (Builder) super.appId(appId);
105 }
106
107 @Override
108 public Builder key(Key key) {
109 return (Builder) super.key(key);
110 }
111
112 @Override
113 public Builder priority(int priority) {
114 return (Builder) super.priority(priority);
115 }
116
Luca Prete670ac5d2017-02-03 15:55:43 -0800117 @Override
118 public Builder resourceGroup(ResourceGroup resourceGroup) {
119 return (Builder) super.resourceGroup(resourceGroup);
120 }
121
Ray Milkeye076c792015-03-24 09:38:30 -0700122 /**
123 * Sets the source for the intent that will be built.
124 *
125 * @param src source to use for built intent
126 * @return this builder
127 */
128 public Builder src(ConnectPoint src) {
129 this.src = src;
130 return this;
131 }
132
133 /**
134 * Sets the destination for the intent that will be built.
135 *
136 * @param dst dest to use for built intent
137 * @return this builder
138 */
139 public Builder dst(ConnectPoint dst) {
140 this.dst = dst;
141 return this;
142 }
143
144 /**
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700145 * Sets the ODU signal type for the intent that will be built.
146 *
147 * @param signalType ODU signal type
148 * @return this builder
149 */
150 public Builder signalType(OduSignalType signalType) {
151 this.signalType = signalType;
152 return this;
153 }
154
155 /**
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700156 * Sets the directionality of the intent.
157 *
158 * @param isBidirectional true if bidirectional, false if unidirectional
159 * @return this builder
160 */
161 public Builder bidirectional(boolean isBidirectional) {
162 this.isBidirectional = isBidirectional;
163 return this;
164 }
165
166 /**
Marc De Leenheeradfeffd2017-06-22 16:05:34 -0700167 * Sets the OCh signal of the intent.
168 *
169 * @param ochSignal the lambda
170 * @return this builder
171 */
alessioda025c42020-07-17 13:00:28 +0200172 public Builder ochSignal(Optional<OchSignal> ochSignal) {
173 this.ochSignal = ochSignal;
Marc De Leenheeradfeffd2017-06-22 16:05:34 -0700174 return this;
175 }
176
177 /**
alessio3039bdb2018-11-29 14:12:32 +0100178 * Sets the suggestedPath of the intent.
179 *
180 * @param suggestedPath the path
181 * @return this builder
182 */
alessioda025c42020-07-17 13:00:28 +0200183 public Builder suggestedPath(Optional<Path> suggestedPath) {
184 this.suggestedPath = suggestedPath;
alessio3039bdb2018-11-29 14:12:32 +0100185 return this;
186 }
187
188 /**
Ray Milkeye076c792015-03-24 09:38:30 -0700189 * Builds an optical connectivity intent from the accumulated parameters.
190 *
191 * @return point to point intent
192 */
193 public OpticalConnectivityIntent build() {
194
195 return new OpticalConnectivityIntent(
196 appId,
197 key,
198 src,
199 dst,
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700200 signalType,
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700201 isBidirectional,
Marc De Leenheeradfeffd2017-06-22 16:05:34 -0700202 ochSignal,
alessio3039bdb2018-11-29 14:12:32 +0100203 suggestedPath,
Luca Prete670ac5d2017-02-03 15:55:43 -0800204 priority,
205 resourceGroup
Ray Milkeye076c792015-03-24 09:38:30 -0700206 );
207 }
208 }
Ray Milkey5b3717e2015-02-05 11:44:08 -0800209
weibitf32383b2014-10-22 10:17:31 -0700210 /**
211 * Constructor for serializer.
212 */
213 protected OpticalConnectivityIntent() {
214 super();
215 this.src = null;
216 this.dst = null;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700217 this.signalType = null;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700218 this.isBidirectional = false;
Marc De Leenheeradfeffd2017-06-22 16:05:34 -0700219 this.ochSignal = null;
alessio3039bdb2018-11-29 14:12:32 +0100220 this.suggestedPath = null;
weibitf32383b2014-10-22 10:17:31 -0700221 }
222
223 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -0700224 * Returns the source transponder port.
weibitf32383b2014-10-22 10:17:31 -0700225 *
Thomas Vachuska4b420772014-10-30 16:46:17 -0700226 * @return source transponder port
weibitf32383b2014-10-22 10:17:31 -0700227 */
Jonathan Hartc9d76732014-11-18 10:52:20 -0800228 public ConnectPoint getSrc() {
weibitf32383b2014-10-22 10:17:31 -0700229 return src;
230 }
231
232 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -0700233 * Returns the destination transponder port.
weibitf32383b2014-10-22 10:17:31 -0700234 *
Thomas Vachuska4b420772014-10-30 16:46:17 -0700235 * @return source transponder port
weibitf32383b2014-10-22 10:17:31 -0700236 */
237 public ConnectPoint getDst() {
238 return dst;
239 }
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +0900240
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700241 /**
242 * Returns the ODU signal type.
243 *
244 * @return ODU signal type
245 */
246 public OduSignalType getSignalType() {
247 return signalType;
248 }
249
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700250 /**
251 * Returns the directionality of the intent.
252 *
253 * @return true if bidirectional, false if unidirectional
254 */
255 public boolean isBidirectional() {
256 return isBidirectional;
257 }
258
Marc De Leenheeradfeffd2017-06-22 16:05:34 -0700259 /**
260 * Returns the OCh signal of the intent.
261 *
262 * @return the lambda
263 */
alessio3039bdb2018-11-29 14:12:32 +0100264
Marc De Leenheeradfeffd2017-06-22 16:05:34 -0700265 public Optional<OchSignal> ochSignal() {
266 return ochSignal;
267 }
268
alessio3039bdb2018-11-29 14:12:32 +0100269 /**
270 * Returns the suggestedPath of the intent.
271 *
272 * @return the suggestedPath
273 */
274 public Optional<Path> suggestedPath() {
275 return suggestedPath;
276 }
277
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +0900278 @Override
279 public String toString() {
280 return MoreObjects.toStringHelper(this)
281 .add("id", id())
282 .add("key", key())
283 .add("appId", appId())
284 .add("priority", priority())
285 .add("resources", resources())
286 .add("src", src)
287 .add("dst", dst)
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700288 .add("signalType", signalType)
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700289 .add("isBidirectional", isBidirectional)
Marc De Leenheeradfeffd2017-06-22 16:05:34 -0700290 .add("ochSignal", ochSignal)
alessio3039bdb2018-11-29 14:12:32 +0100291 .add("suggestedPath", suggestedPath)
Luca Prete670ac5d2017-02-03 15:55:43 -0800292 .add("resourceGroup", resourceGroup())
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +0900293 .toString();
294 }
weibitf32383b2014-10-22 10:17:31 -0700295}