blob: 7cf4411dd4ed0e933db61b1f52036f236d470d1a [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;
weibitf32383b2014-10-22 10:17:31 -070025
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +090026import java.util.Collections;
Marc De Leenheeradfeffd2017-06-22 16:05:34 -070027import java.util.Optional;
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +090028
Ray Milkeye076c792015-03-24 09:38:30 -070029import static com.google.common.base.Preconditions.checkNotNull;
Sho SHIMIZUd7d18002015-01-21 14:37:14 -080030
weibitf32383b2014-10-22 10:17:31 -070031/**
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070032 * An optical layer intent for connectivity between two OCh ports.
33 * No traffic selector or traffic treatment are needed.
weibitf32383b2014-10-22 10:17:31 -070034 */
Brian O'Connor9476fa12015-06-25 15:17:17 -040035@Beta
Ray Milkeybd4f0112015-03-02 17:07:09 -080036public final class OpticalConnectivityIntent extends Intent {
37 private final ConnectPoint src;
38 private final ConnectPoint dst;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070039 private final OduSignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070040 private final boolean isBidirectional;
Marc De Leenheeradfeffd2017-06-22 16:05:34 -070041 private final Optional<OchSignal> ochSignal;
weibitf32383b2014-10-22 10:17:31 -070042
43 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -070044 * Creates an optical connectivity intent between the specified
45 * connection points.
weibitf32383b2014-10-22 10:17:31 -070046 *
Thomas Vachuska4b420772014-10-30 16:46:17 -070047 * @param appId application identification
Ray Milkey5b3717e2015-02-05 11:44:08 -080048 * @param key intent key
49 * @param src the source transponder port
50 * @param dst the destination transponder port
Brian O'Connor85cf4da2015-06-05 23:44:28 -070051 * @param signalType signal type
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070052 * @param isBidirectional indicates if intent is unidirectional
Marc De Leenheeradfeffd2017-06-22 16:05:34 -070053 * @param ochSignal optional OCh signal
Luca Prete670ac5d2017-02-03 15:55:43 -080054 * @param priority priority to use for flows from this intent
55 * @param resourceGroup resource group of this intent
56 */
57 protected OpticalConnectivityIntent(ApplicationId appId,
58 Key key,
59 ConnectPoint src,
60 ConnectPoint dst,
61 OduSignalType signalType,
62 boolean isBidirectional,
Marc De Leenheeradfeffd2017-06-22 16:05:34 -070063 Optional<OchSignal> ochSignal,
Luca Prete670ac5d2017-02-03 15:55:43 -080064 int priority,
65 ResourceGroup resourceGroup) {
66 super(appId, key, Collections.emptyList(), priority, resourceGroup);
Ray Milkeye076c792015-03-24 09:38:30 -070067 this.src = checkNotNull(src);
68 this.dst = checkNotNull(dst);
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070069 this.signalType = checkNotNull(signalType);
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070070 this.isBidirectional = isBidirectional;
Marc De Leenheeradfeffd2017-06-22 16:05:34 -070071 this.ochSignal = ochSignal;
weibitf32383b2014-10-22 10:17:31 -070072 }
73
Ray Milkeye076c792015-03-24 09:38:30 -070074 /**
75 * Returns a new optical connectivity intent builder.
76 *
77 * @return host to host intent builder
78 */
79 public static Builder builder() {
80 return new Builder();
81 }
82
83
84 /**
85 * Builder for optical connectivity intents.
86 */
87 public static class Builder extends Intent.Builder {
88 private ConnectPoint src;
89 private ConnectPoint dst;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070090 private OduSignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070091 private boolean isBidirectional;
Marc De Leenheeradfeffd2017-06-22 16:05:34 -070092 private Optional<OchSignal> ochSignal = Optional.empty();
Ray Milkeye076c792015-03-24 09:38:30 -070093
94 @Override
95 public Builder appId(ApplicationId appId) {
96 return (Builder) super.appId(appId);
97 }
98
99 @Override
100 public Builder key(Key key) {
101 return (Builder) super.key(key);
102 }
103
104 @Override
105 public Builder priority(int priority) {
106 return (Builder) super.priority(priority);
107 }
108
Luca Prete670ac5d2017-02-03 15:55:43 -0800109 @Override
110 public Builder resourceGroup(ResourceGroup resourceGroup) {
111 return (Builder) super.resourceGroup(resourceGroup);
112 }
113
Ray Milkeye076c792015-03-24 09:38:30 -0700114 /**
115 * Sets the source for the intent that will be built.
116 *
117 * @param src source to use for built intent
118 * @return this builder
119 */
120 public Builder src(ConnectPoint src) {
121 this.src = src;
122 return this;
123 }
124
125 /**
126 * Sets the destination for the intent that will be built.
127 *
128 * @param dst dest to use for built intent
129 * @return this builder
130 */
131 public Builder dst(ConnectPoint dst) {
132 this.dst = dst;
133 return this;
134 }
135
136 /**
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700137 * Sets the ODU signal type for the intent that will be built.
138 *
139 * @param signalType ODU signal type
140 * @return this builder
141 */
142 public Builder signalType(OduSignalType signalType) {
143 this.signalType = signalType;
144 return this;
145 }
146
147 /**
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700148 * Sets the directionality of the intent.
149 *
150 * @param isBidirectional true if bidirectional, false if unidirectional
151 * @return this builder
152 */
153 public Builder bidirectional(boolean isBidirectional) {
154 this.isBidirectional = isBidirectional;
155 return this;
156 }
157
158 /**
Marc De Leenheeradfeffd2017-06-22 16:05:34 -0700159 * Sets the OCh signal of the intent.
160 *
161 * @param ochSignal the lambda
162 * @return this builder
163 */
164 public Builder ochSignal(OchSignal ochSignal) {
165 this.ochSignal = Optional.ofNullable(ochSignal);
166 return this;
167 }
168
169 /**
Ray Milkeye076c792015-03-24 09:38:30 -0700170 * Builds an optical connectivity intent from the accumulated parameters.
171 *
172 * @return point to point intent
173 */
174 public OpticalConnectivityIntent build() {
175
176 return new OpticalConnectivityIntent(
177 appId,
178 key,
179 src,
180 dst,
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700181 signalType,
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700182 isBidirectional,
Marc De Leenheeradfeffd2017-06-22 16:05:34 -0700183 ochSignal,
Luca Prete670ac5d2017-02-03 15:55:43 -0800184 priority,
185 resourceGroup
Ray Milkeye076c792015-03-24 09:38:30 -0700186 );
187 }
188 }
Ray Milkey5b3717e2015-02-05 11:44:08 -0800189
weibitf32383b2014-10-22 10:17:31 -0700190 /**
191 * Constructor for serializer.
192 */
193 protected OpticalConnectivityIntent() {
194 super();
195 this.src = null;
196 this.dst = null;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700197 this.signalType = null;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700198 this.isBidirectional = false;
Marc De Leenheeradfeffd2017-06-22 16:05:34 -0700199 this.ochSignal = null;
weibitf32383b2014-10-22 10:17:31 -0700200 }
201
202 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -0700203 * Returns the source transponder port.
weibitf32383b2014-10-22 10:17:31 -0700204 *
Thomas Vachuska4b420772014-10-30 16:46:17 -0700205 * @return source transponder port
weibitf32383b2014-10-22 10:17:31 -0700206 */
Jonathan Hartc9d76732014-11-18 10:52:20 -0800207 public ConnectPoint getSrc() {
weibitf32383b2014-10-22 10:17:31 -0700208 return src;
209 }
210
211 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -0700212 * Returns the destination transponder port.
weibitf32383b2014-10-22 10:17:31 -0700213 *
Thomas Vachuska4b420772014-10-30 16:46:17 -0700214 * @return source transponder port
weibitf32383b2014-10-22 10:17:31 -0700215 */
216 public ConnectPoint getDst() {
217 return dst;
218 }
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +0900219
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700220 /**
221 * Returns the ODU signal type.
222 *
223 * @return ODU signal type
224 */
225 public OduSignalType getSignalType() {
226 return signalType;
227 }
228
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700229 /**
230 * Returns the directionality of the intent.
231 *
232 * @return true if bidirectional, false if unidirectional
233 */
234 public boolean isBidirectional() {
235 return isBidirectional;
236 }
237
Marc De Leenheeradfeffd2017-06-22 16:05:34 -0700238 /**
239 * Returns the OCh signal of the intent.
240 *
241 * @return the lambda
242 */
243 public Optional<OchSignal> ochSignal() {
244 return ochSignal;
245 }
246
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +0900247 @Override
248 public String toString() {
249 return MoreObjects.toStringHelper(this)
250 .add("id", id())
251 .add("key", key())
252 .add("appId", appId())
253 .add("priority", priority())
254 .add("resources", resources())
255 .add("src", src)
256 .add("dst", dst)
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700257 .add("signalType", signalType)
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700258 .add("isBidirectional", isBidirectional)
Marc De Leenheeradfeffd2017-06-22 16:05:34 -0700259 .add("ochSignal", ochSignal)
Luca Prete670ac5d2017-02-03 15:55:43 -0800260 .add("resourceGroup", resourceGroup())
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +0900261 .toString();
262 }
weibitf32383b2014-10-22 10:17:31 -0700263}