blob: e2e54d8b792a937b5df62612f8445f57be7957aa [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 Open Networking Laboratory
Thomas Vachuska781d18b2014-10-27 10:31:25 -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 Vachuska781d18b2014-10-27 10:31:25 -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 Vachuska781d18b2014-10-27 10:31:25 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.optical;
weibitf32383b2014-10-22 10:17:31 -070017
weibitf32383b2014-10-22 10:17:31 -070018import org.apache.felix.scr.annotations.Activate;
19import org.apache.felix.scr.annotations.Component;
Marc De Leenheer16f857b2015-05-05 20:50:24 -070020import org.apache.felix.scr.annotations.Deactivate;
weibitf32383b2014-10-22 10:17:31 -070021import org.apache.felix.scr.annotations.Reference;
22import org.apache.felix.scr.annotations.ReferenceCardinality;
Marc De Leenheer8b3e80b2015-03-06 14:27:03 -080023import org.onosproject.cluster.ClusterService;
24import org.onosproject.cluster.NodeId;
Brian O'Connorabafb502014-12-02 22:26:20 -080025import org.onosproject.core.ApplicationId;
26import org.onosproject.core.CoreService;
Marc De Leenheer8b3e80b2015-03-06 14:27:03 -080027import org.onosproject.mastership.MastershipService;
Brian O'Connorabafb502014-12-02 22:26:20 -080028import org.onosproject.net.ConnectPoint;
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070029import org.onosproject.net.Device;
Brian O'Connorabafb502014-12-02 22:26:20 -080030import org.onosproject.net.Host;
31import org.onosproject.net.Link;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070032import org.onosproject.net.OchPort;
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070033import org.onosproject.net.OduCltPort;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070034import org.onosproject.net.OduSignalType;
Brian O'Connorabafb502014-12-02 22:26:20 -080035import org.onosproject.net.Path;
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070036import org.onosproject.net.Port;
37import org.onosproject.net.device.DeviceService;
Brian O'Connorabafb502014-12-02 22:26:20 -080038import org.onosproject.net.host.HostService;
39import org.onosproject.net.intent.HostToHostIntent;
40import org.onosproject.net.intent.Intent;
41import org.onosproject.net.intent.IntentEvent;
42import org.onosproject.net.intent.IntentListener;
Brian O'Connorabafb502014-12-02 22:26:20 -080043import org.onosproject.net.intent.IntentService;
44import org.onosproject.net.intent.IntentState;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070045import org.onosproject.net.intent.OpticalCircuitIntent;
Brian O'Connorabafb502014-12-02 22:26:20 -080046import org.onosproject.net.intent.OpticalConnectivityIntent;
47import org.onosproject.net.intent.PointToPointIntent;
Brian O'Connor6de2e202015-05-21 14:30:41 -070048import org.onosproject.net.resource.device.DeviceResourceService;
Ayaka Koshibebcb02372015-06-01 10:56:42 -070049import org.onosproject.net.resource.link.LinkResourceAllocations;
Brian O'Connor6de2e202015-05-21 14:30:41 -070050import org.onosproject.net.resource.link.LinkResourceService;
Brian O'Connorabafb502014-12-02 22:26:20 -080051import org.onosproject.net.topology.LinkWeight;
52import org.onosproject.net.topology.PathService;
53import org.onosproject.net.topology.TopologyEdge;
weibitf32383b2014-10-22 10:17:31 -070054import org.slf4j.Logger;
55import org.slf4j.LoggerFactory;
56
Marc De Leenheer16f857b2015-05-05 20:50:24 -070057import java.util.Collections;
Brian O'Connor772852a2014-11-17 15:51:19 -080058import java.util.Iterator;
Marc De Leenheer16f857b2015-05-05 20:50:24 -070059import java.util.LinkedList;
Brian O'Connor772852a2014-11-17 15:51:19 -080060import java.util.List;
Brian O'Connorc7bdd8c2014-12-08 01:29:53 -080061import java.util.Map;
Brian O'Connor772852a2014-11-17 15:51:19 -080062import java.util.Set;
Brian O'Connorc7bdd8c2014-12-08 01:29:53 -080063import java.util.concurrent.ConcurrentHashMap;
64
Marc De Leenheer16f857b2015-05-05 20:50:24 -070065import static com.google.common.base.Preconditions.checkArgument;
Marc De Leenheer16f857b2015-05-05 20:50:24 -070066import static com.google.common.base.Preconditions.checkNotNull;
67
weibitf32383b2014-10-22 10:17:31 -070068/**
Marc De Leenheer16f857b2015-05-05 20:50:24 -070069 * OpticalPathProvisioner listens for event notifications from the Intent F/W.
weibitf32383b2014-10-22 10:17:31 -070070 * It generates one or more opticalConnectivityIntent(s) and submits (or withdraws) to Intent F/W
71 * for adding/releasing capacity at the packet layer.
weibitf32383b2014-10-22 10:17:31 -070072 */
73
74@Component(immediate = true)
75public class OpticalPathProvisioner {
76
77 protected static final Logger log = LoggerFactory
78 .getLogger(OpticalPathProvisioner.class);
79
80 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
81 private IntentService intentService;
82
83 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Brian O'Connor772852a2014-11-17 15:51:19 -080084 protected PathService pathService;
weibitf32383b2014-10-22 10:17:31 -070085
86 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
87 protected CoreService coreService;
88
weibit7e583462014-10-23 10:14:05 -070089 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Praseed Balakrishnanc0029652014-11-14 13:38:49 -080090 protected HostService hostService;
91
Marc De Leenheer8b3e80b2015-03-06 14:27:03 -080092 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
93 protected MastershipService mastershipService;
94
95 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
96 protected ClusterService clusterService;
97
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070098 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070099 protected DeviceService deviceService;
100
101 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
102 protected DeviceResourceService deviceResourceService;
103
104 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
105 protected LinkResourceService linkResourceService;
106
107 private ApplicationId appId;
Brian O'Connorc7bdd8c2014-12-08 01:29:53 -0800108
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700109 private final Map<ConnectPoint, Map<ConnectPoint, Intent>> intentMap =
Brian O'Connorc7bdd8c2014-12-08 01:29:53 -0800110 new ConcurrentHashMap<>();
weibitf32383b2014-10-22 10:17:31 -0700111
112 private final InternalOpticalPathProvisioner pathProvisioner = new InternalOpticalPathProvisioner();
113
114 @Activate
115 protected void activate() {
116 intentService.addListener(pathProvisioner);
Brian O'Connorabafb502014-12-02 22:26:20 -0800117 appId = coreService.registerApplication("org.onosproject.optical");
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700118 initOpticalPorts();
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700119 log.info("Started");
120 }
121
122 @Deactivate
123 protected void deactivate() {
124 intentService.removeListener(pathProvisioner);
125 log.info("Stopped");
weibitf32383b2014-10-22 10:17:31 -0700126 }
127
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700128 /**
129 * Initialize availability of optical ports.
130 */
131 private void initOpticalPorts() {
132 // TODO: check for existing optical intents
133 return;
Brian O'Connorc7bdd8c2014-12-08 01:29:53 -0800134 }
135
weibitf32383b2014-10-22 10:17:31 -0700136 public class InternalOpticalPathProvisioner implements IntentListener {
137 @Override
138 public void event(IntentEvent event) {
139 switch (event.type()) {
Brian O'Connor7a71d5d2014-12-02 00:12:27 -0800140 case INSTALL_REQ:
weibitf32383b2014-10-22 10:17:31 -0700141 break;
142 case INSTALLED:
143 break;
144 case FAILED:
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700145 log.info("Intent {} failed, calling optical path provisioning app.", event.subject());
Brian O'Connor772852a2014-11-17 15:51:19 -0800146 setupLightpath(event.subject());
weibitf32383b2014-10-22 10:17:31 -0700147 break;
148 case WITHDRAWN:
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700149 log.info("Intent {} withdrawn.", event.subject());
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700150 withdrawIntent(event.subject());
weibitf32383b2014-10-22 10:17:31 -0700151 break;
152 default:
153 break;
154 }
155 }
156
Brian O'Connorc7bdd8c2014-12-08 01:29:53 -0800157 /**
158 * Registers an intent from src to dst.
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700159 *
Brian O'Connorc7bdd8c2014-12-08 01:29:53 -0800160 * @param src source point
161 * @param dst destination point
162 * @param intent intent to be registered
163 * @return true if intent has not been previously added, false otherwise
164 */
165 private boolean addIntent(ConnectPoint src, ConnectPoint dst, Intent intent) {
166 Map<ConnectPoint, Intent> srcMap = intentMap.get(src);
167 if (srcMap == null) {
168 srcMap = new ConcurrentHashMap<>();
169 intentMap.put(src, srcMap);
170 }
171 if (srcMap.containsKey(dst)) {
172 return false;
173 } else {
174 srcMap.put(dst, intent);
175 return true;
176 }
177 }
178
Brian O'Connor772852a2014-11-17 15:51:19 -0800179 private void setupLightpath(Intent intent) {
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700180 checkNotNull(intent);
181
Brian O'Connorc7bdd8c2014-12-08 01:29:53 -0800182 // TODO change the coordination approach between packet intents and optical intents
183 // Low speed LLDP may cause multiple calls which are not expected
184
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800185 if (!IntentState.FAILED.equals(intentService.getIntentState(intent.key()))) {
Marc De Leenheer8b3e80b2015-03-06 14:27:03 -0800186 return;
Marc De Leenheerb473b9d2015-02-06 15:21:03 -0800187 }
Brian O'Connorc7bdd8c2014-12-08 01:29:53 -0800188
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700189 // Get source and destination based on intent type
190 ConnectPoint src;
191 ConnectPoint dst;
Brian O'Connor772852a2014-11-17 15:51:19 -0800192 if (intent instanceof HostToHostIntent) {
193 HostToHostIntent hostToHostIntent = (HostToHostIntent) intent;
Marc De Leenheer8b3e80b2015-03-06 14:27:03 -0800194
Brian O'Connor772852a2014-11-17 15:51:19 -0800195 Host one = hostService.getHost(hostToHostIntent.one());
196 Host two = hostService.getHost(hostToHostIntent.two());
Marc De Leenheer8b3e80b2015-03-06 14:27:03 -0800197
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700198 checkNotNull(one);
199 checkNotNull(two);
Marc De Leenheer8b3e80b2015-03-06 14:27:03 -0800200
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700201 src = one.location();
202 dst = two.location();
Brian O'Connor772852a2014-11-17 15:51:19 -0800203 } else if (intent instanceof PointToPointIntent) {
204 PointToPointIntent p2pIntent = (PointToPointIntent) intent;
Marc De Leenheer8b3e80b2015-03-06 14:27:03 -0800205
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700206 src = p2pIntent.ingressPoint();
207 dst = p2pIntent.egressPoint();
Brian O'Connor772852a2014-11-17 15:51:19 -0800208 } else {
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700209 return;
Brian O'Connor772852a2014-11-17 15:51:19 -0800210 }
Praseed Balakrishnanc0029652014-11-14 13:38:49 -0800211
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700212 if (src == null || dst == null) {
213 return;
214 }
215
216 // Ignore if we're not the master for the intent's origin device
217 NodeId localNode = clusterService.getLocalNode().id();
218 NodeId sourceMaster = mastershipService.getMasterFor(src.deviceId());
219 if (!localNode.equals(sourceMaster)) {
220 return;
221 }
222
223 // Generate optical connectivity intents
Sho SHIMIZUfb446fe2015-05-21 14:45:23 -0700224 List<Intent> intents = getOpticalIntents(src, dst);
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700225
226 // Submit the intents
Brian O'Connor772852a2014-11-17 15:51:19 -0800227 for (Intent i : intents) {
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700228 intentService.submit(i);
Sho SHIMIZUb5d38412015-05-21 11:12:58 -0700229 log.debug("Submitted an intent: {}", i);
Brian O'Connor772852a2014-11-17 15:51:19 -0800230 }
weibit7e583462014-10-23 10:14:05 -0700231 }
232
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700233 /**
234 * Returns list of cross connection points of missing optical path sections.
235 *
236 * Scans the given multi-layer path and looks for sections that use cross connect links.
237 * The ingress and egress points in the optical layer are returned in a list.
238 *
239 * @param path the multi-layer path
240 * @return list of cross connection points on the optical layer
241 */
242 private List<ConnectPoint> getCrossConnectPoints(Path path) {
243 boolean scanning = false;
244 List<ConnectPoint> connectPoints = new LinkedList<ConnectPoint>();
245
246 for (Link link : path.links()) {
247 if (!isCrossConnectLink(link)) {
248 continue;
249 }
250
251 if (scanning) {
252 connectPoints.add(checkNotNull(link.src()));
253 scanning = false;
254 } else {
255 connectPoints.add(checkNotNull(link.dst()));
256 scanning = true;
257 }
258 }
259
260 return connectPoints;
261 }
262
263 /**
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700264 * Checks if cross connect points are of same type.
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700265 *
266 * @param crossConnectPoints list of cross connection points
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700267 * @return true if cross connect point pairs are of same type, false otherwise
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700268 */
269 private boolean checkCrossConnectPoints(List<ConnectPoint> crossConnectPoints) {
270 checkArgument(crossConnectPoints.size() % 2 == 0);
271
272 Iterator<ConnectPoint> itr = crossConnectPoints.iterator();
273
274 while (itr.hasNext()) {
275 // checkArgument at start ensures we'll always have pairs of connect points
276 ConnectPoint src = itr.next();
277 ConnectPoint dst = itr.next();
278
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700279 Device.Type srcType = deviceService.getDevice(src.deviceId()).type();
280 Device.Type dstType = deviceService.getDevice(dst.deviceId()).type();
281
282 // Only support connections between identical port types
283 if (srcType != dstType) {
284 log.warn("Unsupported mix of cross connect points");
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700285 return false;
286 }
287 }
288
289 return true;
290 }
291
292 /**
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700293 * Scans the list of cross connection points and returns a list of optical connectivity intents.
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700294 *
295 * @param crossConnectPoints list of cross connection points
296 * @return list of optical connectivity intents
297 */
298 private List<Intent> getIntents(List<ConnectPoint> crossConnectPoints) {
299 checkArgument(crossConnectPoints.size() % 2 == 0);
300
Sho SHIMIZU79945e82015-05-20 17:20:47 -0700301 List<Intent> intents = new LinkedList<>();
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700302 Iterator<ConnectPoint> itr = crossConnectPoints.iterator();
303
304 while (itr.hasNext()) {
305 // checkArgument at start ensures we'll always have pairs of connect points
306 ConnectPoint src = itr.next();
307 ConnectPoint dst = itr.next();
308
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700309 Port srcPort = deviceService.getPort(src.deviceId(), src.port());
310 Port dstPort = deviceService.getPort(dst.deviceId(), dst.port());
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700311
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700312 if (srcPort instanceof OduCltPort && dstPort instanceof OduCltPort) {
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700313 // TODO: Check availability of ports
314
315 // Create OTN circuit
316 Intent circuitIntent = OpticalCircuitIntent.builder()
317 .appId(appId)
318 .src(src)
319 .dst(dst)
320 .signalType(OduCltPort.SignalType.CLT_10GBE)
321 .build();
322 intents.add(circuitIntent);
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700323 continue;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700324 } else if (srcPort instanceof OchPort && dstPort instanceof OchPort) {
325 // Create lightpath
326 // FIXME: hardcoded ODU signal type
327 Intent opticalIntent = OpticalConnectivityIntent.builder()
328 .appId(appId)
329 .src(src)
330 .dst(dst)
331 .signalType(OduSignalType.ODU4)
332 .build();
333 intents.add(opticalIntent);
334 continue;
335 } else {
336 log.warn("Unsupported cross connect point types {} {}", srcPort.type(), dstPort.type());
337 return Collections.emptyList();
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700338 }
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700339 }
340
341 return intents;
342 }
343
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700344 /**
345 * Returns list of optical connectivity intents needed to create connectivity
346 * between ingress and egress.
347 *
348 * @param ingress the ingress connect point
349 * @param egress the egress connect point
350 * @return list of optical connectivity intents, empty list if no path was found
351 */
352 private List<Intent> getOpticalIntents(ConnectPoint ingress, ConnectPoint egress) {
Brian O'Connor772852a2014-11-17 15:51:19 -0800353 Set<Path> paths = pathService.getPaths(ingress.deviceId(),
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700354 egress.deviceId(),
355 new OpticalLinkWeight());
Brian O'Connor772852a2014-11-17 15:51:19 -0800356
357 if (paths.isEmpty()) {
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700358 return Collections.emptyList();
weibit7e583462014-10-23 10:14:05 -0700359 }
Brian O'Connor772852a2014-11-17 15:51:19 -0800360
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700361 // Search path with available cross connect points
362 for (Path path : paths) {
363 List<ConnectPoint> crossConnectPoints = getCrossConnectPoints(path);
Brian O'Connor772852a2014-11-17 15:51:19 -0800364
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700365 // Skip to next path if cross connect points are mismatched
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700366 if (!checkCrossConnectPoints(crossConnectPoints)) {
367 continue;
Brian O'Connor772852a2014-11-17 15:51:19 -0800368 }
369
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700370 return getIntents(crossConnectPoints);
Brian O'Connor772852a2014-11-17 15:51:19 -0800371 }
Brian O'Connorc7bdd8c2014-12-08 01:29:53 -0800372
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700373 return Collections.emptyList();
Brian O'Connor772852a2014-11-17 15:51:19 -0800374 }
375
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700376 /**
377 * Link weight function that emphasizes re-use of packet links.
378 */
379 private class OpticalLinkWeight implements LinkWeight {
380 @Override
381 public double weight(TopologyEdge edge) {
382 // Ignore inactive links
383 if (edge.link().state() == Link.State.INACTIVE) {
384 return -1;
385 }
Brian O'Connorc7bdd8c2014-12-08 01:29:53 -0800386
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700387 // TODO: Ignore cross connect links with used ports
388
389 // Transport links have highest weight
390 if (edge.link().type() == Link.Type.OPTICAL) {
391 return 1000;
392 }
393
394 // Packet links
395 return 1;
Brian O'Connorc7bdd8c2014-12-08 01:29:53 -0800396 }
weibitf32383b2014-10-22 10:17:31 -0700397 }
Brian O'Connorc7bdd8c2014-12-08 01:29:53 -0800398
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700399 /**
400 * Handle withdrawn intent on each network layer.
401 *
402 * @param intent the withdrawn intent
403 */
404 private void withdrawIntent(Intent intent) {
Ayaka Koshibebcb02372015-06-01 10:56:42 -0700405 LinkResourceAllocations lra = linkResourceService.getAllocations(intent.id());
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700406 if (intent instanceof OpticalConnectivityIntent) {
407 deviceResourceService.releasePorts(intent.id());
Ayaka Koshibebcb02372015-06-01 10:56:42 -0700408 linkResourceService.releaseResources(lra);
Marc De Leenheer9f7d1892015-05-30 13:22:24 -0700409 } else if (intent instanceof OpticalCircuitIntent) {
410 deviceResourceService.releasePorts(intent.id());
411 deviceResourceService.releaseMapping(intent.id());
Ayaka Koshibebcb02372015-06-01 10:56:42 -0700412 if (lra != null) {
413 linkResourceService.releaseResources(lra);
414 }
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700415 }
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700416 }
Brian O'Connor772852a2014-11-17 15:51:19 -0800417 }
weibitf32383b2014-10-22 10:17:31 -0700418
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700419 /**
420 * Verifies if given link is cross-connect between packet and optical layer.
421 *
422 * @param link the link
423 * @return true if the link is a cross-connect link
424 */
425 public static boolean isCrossConnectLink(Link link) {
426 if (link.type() != Link.Type.OPTICAL) {
427 return false;
Praseed Balakrishnanc0029652014-11-14 13:38:49 -0800428 }
Marc De Leenheer16f857b2015-05-05 20:50:24 -0700429
430 checkNotNull(link.annotations());
431 checkNotNull(link.annotations().value("optical.type"));
432
Sho SHIMIZU6d283122015-05-21 11:07:02 -0700433 return link.annotations().value("optical.type").equals("cross-connect");
Brian O'Connor772852a2014-11-17 15:51:19 -0800434 }
Praseed Balakrishnanc0029652014-11-14 13:38:49 -0800435
weibitf32383b2014-10-22 10:17:31 -0700436}