yjimmyy
Committed by Gerrit Code Review

Implement Oplink drivers for port adjacency

Change-Id: I3cdc402c4dac544a7cb48544352df758c416345d
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
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 + */
16 +package org.onosproject.net.optical;
17 +
18 +import com.google.common.annotations.Beta;
19 +
20 +/**
21 + * Collection of keys for annotation for optical devices.
22 + */
23 +@Beta
24 +public final class OpticalAnnotations {
25 +
26 + private OpticalAnnotations() {}
27 +
28 + /**
29 + * Annotation key for optical port's target power.
30 + */
31 + public static final String TARGET_POWER = "targetPower";
32 +
33 + /**
34 + * Annotation key for optical port's current power.
35 + */
36 + public static final String CURRENT_POWER = "currentPower";
37 +
38 + /**
39 + * Annotation key for optical port's neighbor's DeviceId#toString().
40 + */
41 + public static final String NEIGHBOR_ID = "neighborDeviceId";
42 +
43 + /**
44 + * Annotation key for optical port's neighbor's PortNumber#toString().
45 + */
46 + public static final String NEIGHBOR_PORT = "neighborPort";
47 +}
...@@ -15,8 +15,6 @@ ...@@ -15,8 +15,6 @@
15 */ 15 */
16 package org.onosproject.net; 16 package org.onosproject.net;
17 17
18 -import com.google.common.annotations.Beta;
19 -
20 /** 18 /**
21 * Collection of keys for annotation. 19 * Collection of keys for annotation.
22 * <p> 20 * <p>
...@@ -112,18 +110,6 @@ public final class AnnotationKeys { ...@@ -112,18 +110,6 @@ public final class AnnotationKeys {
112 public static final String STATIC_LAMBDA = "staticLambda"; 110 public static final String STATIC_LAMBDA = "staticLambda";
113 111
114 /** 112 /**
115 - * Annotation key for optical port's target power.
116 - */
117 - @Beta
118 - public static final String TARGET_POWER = "targetPower";
119 -
120 - /**
121 - * Annotation key for optical port's current power.
122 - */
123 - @Beta
124 - public static final String CURRENT_POWER = "currentPower";
125 -
126 - /**
127 * Annotation key for the static port. 113 * Annotation key for the static port.
128 */ 114 */
129 public static final String STATIC_PORT = "staticPort"; 115 public static final String STATIC_PORT = "staticPort";
......
...@@ -22,5 +22,6 @@ ...@@ -22,5 +22,6 @@
22 22
23 <bundle>mvn:org.onosproject/openflowj/0.9.5.onos</bundle> 23 <bundle>mvn:org.onosproject/openflowj/0.9.5.onos</bundle>
24 <bundle>mvn:${project.groupId}/onos-of-api/${project.version}</bundle> 24 <bundle>mvn:${project.groupId}/onos-of-api/${project.version}</bundle>
25 +
25 </feature> 26 </feature>
26 </features> 27 </features>
......
...@@ -21,18 +21,28 @@ import com.google.common.collect.ImmutableSet; ...@@ -21,18 +21,28 @@ import com.google.common.collect.ImmutableSet;
21 import java.io.IOException; 21 import java.io.IOException;
22 import java.util.ArrayList; 22 import java.util.ArrayList;
23 import java.util.Collections; 23 import java.util.Collections;
24 +import java.util.HashMap;
24 import java.util.List; 25 import java.util.List;
25 import java.util.Set; 26 import java.util.Set;
26 import java.util.concurrent.atomic.AtomicBoolean; 27 import java.util.concurrent.atomic.AtomicBoolean;
27 28
28 -import org.onosproject.net.AnnotationKeys; 29 +import org.jboss.netty.buffer.ChannelBuffer;
30 +import org.jboss.netty.buffer.ChannelBuffers;
31 +import org.onosproject.drivers.optical.OpticalAdjacencyLinkService;
32 +import org.onosproject.net.Annotations;
33 +import org.onosproject.net.ConnectPoint;
29 import org.onosproject.net.DefaultAnnotations; 34 import org.onosproject.net.DefaultAnnotations;
30 import org.onosproject.net.Device; 35 import org.onosproject.net.Device;
36 +import org.onosproject.net.DeviceId;
37 +import org.onosproject.net.Link;
31 import org.onosproject.net.Port; 38 import org.onosproject.net.Port;
32 import org.onosproject.net.PortNumber; 39 import org.onosproject.net.PortNumber;
33 import org.onosproject.net.device.DefaultPortDescription; 40 import org.onosproject.net.device.DefaultPortDescription;
34 import org.onosproject.net.device.DeviceService; 41 import org.onosproject.net.device.DeviceService;
35 import org.onosproject.net.device.PortDescription; 42 import org.onosproject.net.device.PortDescription;
43 +import org.onosproject.net.link.DefaultLinkDescription;
44 +import org.onosproject.net.optical.OpticalAnnotations;
45 +import org.onosproject.openflow.controller.Dpid;
36 import org.onosproject.openflow.controller.OpenFlowOpticalSwitch; 46 import org.onosproject.openflow.controller.OpenFlowOpticalSwitch;
37 import org.onosproject.openflow.controller.PortDescPropertyType; 47 import org.onosproject.openflow.controller.PortDescPropertyType;
38 import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch; 48 import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch;
...@@ -42,6 +52,12 @@ import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeNotSta ...@@ -42,6 +52,12 @@ import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeNotSta
42 import org.projectfloodlight.openflow.protocol.OFCircuitPortStatus; 52 import org.projectfloodlight.openflow.protocol.OFCircuitPortStatus;
43 import org.projectfloodlight.openflow.protocol.OFCircuitPortsReply; 53 import org.projectfloodlight.openflow.protocol.OFCircuitPortsReply;
44 import org.projectfloodlight.openflow.protocol.OFCircuitPortsRequest; 54 import org.projectfloodlight.openflow.protocol.OFCircuitPortsRequest;
55 +import org.projectfloodlight.openflow.protocol.OFExpExtAdId;
56 +import org.projectfloodlight.openflow.protocol.OFExpPortAdidOtn;
57 +import org.projectfloodlight.openflow.protocol.OFExpPortAdjacency;
58 +import org.projectfloodlight.openflow.protocol.OFExpPortAdjacencyId;
59 +import org.projectfloodlight.openflow.protocol.OFExpPortAdjacencyReply;
60 +import org.projectfloodlight.openflow.protocol.OFExpPortAdjacencyRequest;
45 import org.projectfloodlight.openflow.protocol.OFMessage; 61 import org.projectfloodlight.openflow.protocol.OFMessage;
46 import org.projectfloodlight.openflow.protocol.OFObject; 62 import org.projectfloodlight.openflow.protocol.OFObject;
47 import org.projectfloodlight.openflow.protocol.OFOplinkPortPower; 63 import org.projectfloodlight.openflow.protocol.OFOplinkPortPower;
...@@ -61,7 +77,7 @@ import org.projectfloodlight.openflow.protocol.OFOplinkPortPowerReply; ...@@ -61,7 +77,7 @@ import org.projectfloodlight.openflow.protocol.OFOplinkPortPowerReply;
61 * Driver implements custom handshaker and supports for Optical channel Port based on OpenFlow OTN extension. 77 * Driver implements custom handshaker and supports for Optical channel Port based on OpenFlow OTN extension.
62 * The device consists of Och ports, and performances wavelength cross-connect among the ports. 78 * The device consists of Och ports, and performances wavelength cross-connect among the ports.
63 */ 79 */
64 -public class OplinkRoadmHandshaker extends AbstractOpenFlowSwitch implements OpenFlowOpticalSwitch { 80 +public class OplinkRoadm extends AbstractOpenFlowSwitch implements OpenFlowOpticalSwitch {
65 81
66 private final AtomicBoolean driverHandshakeComplete = new AtomicBoolean(false); 82 private final AtomicBoolean driverHandshakeComplete = new AtomicBoolean(false);
67 private List<OFPortOptical> opticalPorts; 83 private List<OFPortOptical> opticalPorts;
...@@ -172,19 +188,24 @@ public class OplinkRoadmHandshaker extends AbstractOpenFlowSwitch implements Ope ...@@ -172,19 +188,24 @@ public class OplinkRoadmHandshaker extends AbstractOpenFlowSwitch implements Ope
172 188
173 @Override 189 @Override
174 public final void sendMsg(OFMessage m) { 190 public final void sendMsg(OFMessage m) {
175 - OFMessage newMsg = m; 191 + List<OFMessage> messages = new ArrayList<>();
176 - 192 + messages.add(m);
177 if (m.getType() == OFType.STATS_REQUEST) { 193 if (m.getType() == OFType.STATS_REQUEST) {
178 OFStatsRequest sr = (OFStatsRequest) m; 194 OFStatsRequest sr = (OFStatsRequest) m;
179 log.debug("OPLK ROADM rebuilding stats request type {}", sr.getStatsType()); 195 log.debug("OPLK ROADM rebuilding stats request type {}", sr.getStatsType());
180 switch (sr.getStatsType()) { 196 switch (sr.getStatsType()) {
181 case PORT: 197 case PORT:
182 //replace with Oplink experiment stats message to get the port current power 198 //replace with Oplink experiment stats message to get the port current power
183 - OFOplinkPortPowerRequest pRequest = this.factory().buildOplinkPortPowerRequest() 199 + OFOplinkPortPowerRequest powerRequest = this.factory().buildOplinkPortPowerRequest()
184 .setXid(sr.getXid()) 200 .setXid(sr.getXid())
185 .setFlags(sr.getFlags()) 201 .setFlags(sr.getFlags())
186 .build(); 202 .build();
187 - newMsg = pRequest; 203 + messages.add(powerRequest);
204 + OFExpPortAdjacencyRequest adjacencyRequest = this.factory().buildExpPortAdjacencyRequest()
205 + .setXid(sr.getXid())
206 + .setFlags(sr.getFlags())
207 + .build();
208 + messages.add(adjacencyRequest);
188 break; 209 break;
189 default: 210 default:
190 break; 211 break;
...@@ -193,7 +214,9 @@ public class OplinkRoadmHandshaker extends AbstractOpenFlowSwitch implements Ope ...@@ -193,7 +214,9 @@ public class OplinkRoadmHandshaker extends AbstractOpenFlowSwitch implements Ope
193 log.debug("OPLK ROADM sends msg:{}, as is", m.getType()); 214 log.debug("OPLK ROADM sends msg:{}, as is", m.getType());
194 } 215 }
195 216
196 - super.sendMsg(newMsg); 217 + for (OFMessage message : messages) {
218 + super.sendMsg(message);
219 + }
197 } 220 }
198 221
199 private void sendHandshakeOFExperimenterPortDescRequest() throws IOException { 222 private void sendHandshakeOFExperimenterPortDescRequest() throws IOException {
...@@ -223,33 +246,124 @@ public class OplinkRoadmHandshaker extends AbstractOpenFlowSwitch implements Ope ...@@ -223,33 +246,124 @@ public class OplinkRoadmHandshaker extends AbstractOpenFlowSwitch implements Ope
223 public List<PortDescription> processExpPortStats(OFMessage msg) { 246 public List<PortDescription> processExpPortStats(OFMessage msg) {
224 if (msg instanceof OFOplinkPortPowerReply) { 247 if (msg instanceof OFOplinkPortPowerReply) {
225 return buildPortPowerDescriptions(((OFOplinkPortPowerReply) msg).getEntries()); 248 return buildPortPowerDescriptions(((OFOplinkPortPowerReply) msg).getEntries());
249 + } else if (msg instanceof OFExpPortAdjacencyReply) {
250 + return buildPortAdjacencyDescriptions(((OFExpPortAdjacencyReply) msg).getEntries());
226 } 251 }
227 return Collections.emptyList(); 252 return Collections.emptyList();
228 } 253 }
229 254
230 - private OFOplinkPortPower getPortPower(List<OFOplinkPortPower> portPowers, PortNumber portNum) { 255 + private List<PortDescription> buildPortPowerDescriptions(List<OFOplinkPortPower> portPowers) {
231 - for (OFOplinkPortPower power : portPowers) { 256 + DeviceService deviceService = this.handler().get(DeviceService.class);
232 - if (power.getPort() == portNum.toLong()) { 257 + List<Port> ports = deviceService.getPorts(this.data().deviceId());
233 - return power; 258 + HashMap<Long, OFOplinkPortPower> powerMap = new HashMap<>(portPowers.size());
259 + portPowers.forEach(power -> powerMap.put((long) power.getPort(), power));
260 + final List<PortDescription> portDescs = new ArrayList<>();
261 + for (Port port : ports) {
262 + DefaultAnnotations.Builder builder = DefaultAnnotations.builder();
263 + builder.putAll(port.annotations());
264 + OFOplinkPortPower power = powerMap.get(port.number().toLong());
265 + if (power != null) {
266 + builder.set(OpticalAnnotations.CURRENT_POWER, Long.toString(power.getPowerValue()));
267 + }
268 + portDescs.add(new DefaultPortDescription(port.number(), port.isEnabled(),
269 + port.type(), port.portSpeed(), builder.build()));
270 + }
271 + return portDescs;
272 + }
273 +
274 + private OplinkPortAdjacency getNeighbor(OFExpPortAdjacency ad) {
275 + for (OFExpPortAdjacencyId adid : ad.getProperties()) {
276 + List<OFExpExtAdId> otns = adid.getAdId();
277 + if (otns != null && otns.size() > 0) {
278 + OFExpPortAdidOtn otn = (OFExpPortAdidOtn) otns.get(0);
279 + // ITU-T G.7714 ETH MAC Format (in second 16 bytes of the following)
280 + // |---------------------------------------------------------------------------|
281 + // | Other format (16 bytes) |
282 + // |---------------------------------------------------------------------------|
283 + // | Header (2 bytes) | ID (4 bits) | MAC (6 bytes) | Port (4 bytes) | Unused |
284 + // |---------------------------------------------------------------------------|
285 + ChannelBuffer buffer = ChannelBuffers.buffer(32);
286 + otn.getOpspec().write32Bytes(buffer);
287 + long mac = buffer.getLong(18) << 4 >>> 16;
288 + int port = (int) (buffer.getLong(24) << 4 >>> 32);
289 + // Oplink does not use the 4 most significant bytes of Dpid so Dpid can be
290 + // constructed from MAC address
291 + return new OplinkPortAdjacency(DeviceId.deviceId(Dpid.uri(new Dpid(mac))),
292 + PortNumber.portNumber(port));
234 } 293 }
235 } 294 }
236 return null; 295 return null;
237 } 296 }
238 297
239 - private List<PortDescription> buildPortPowerDescriptions(List<OFOplinkPortPower> portPowers) { 298 + private List<PortDescription> buildPortAdjacencyDescriptions(List<OFExpPortAdjacency> portAds) {
240 DeviceService deviceService = this.handler().get(DeviceService.class); 299 DeviceService deviceService = this.handler().get(DeviceService.class);
241 List<Port> ports = deviceService.getPorts(this.data().deviceId()); 300 List<Port> ports = deviceService.getPorts(this.data().deviceId());
242 - final List<PortDescription> portDescs = new ArrayList<>(); 301 +
302 + // Map port's number with port's adjacency
303 + HashMap<Long, OFExpPortAdjacency> adMap = new HashMap<>(portAds.size());
304 + portAds.forEach(ad -> adMap.put((long) ad.getPortNo().getPortNumber(), ad));
305 +
306 + List<PortDescription> portDescs = new ArrayList<>();
243 for (Port port : ports) { 307 for (Port port : ports) {
244 DefaultAnnotations.Builder builder = DefaultAnnotations.builder(); 308 DefaultAnnotations.Builder builder = DefaultAnnotations.builder();
245 - builder.putAll(port.annotations()); 309 + Annotations oldAnnotations = port.annotations();
246 - OFOplinkPortPower power = getPortPower(portPowers, port.number()); 310 + builder.putAll(oldAnnotations);
247 - if (power != null) { 311 + OFExpPortAdjacency ad = adMap.get(port.number().toLong());
248 - builder.set(AnnotationKeys.CURRENT_POWER, Long.toString(power.getPowerValue())); 312 + if (ad != null) {
313 + // neighbor discovered, add to port descriptions
314 + OplinkPortAdjacency neighbor = getNeighbor(ad);
315 + String newId = neighbor.getDeviceId().toString();
316 + String newPort = neighbor.getPort().toString();
317 + // Check if annotation already exists
318 + if (!newId.equals(oldAnnotations.value(OpticalAnnotations.NEIGHBOR_ID)) ||
319 + !newPort.equals(oldAnnotations.value(OpticalAnnotations.NEIGHBOR_PORT))) {
320 + builder.set(OpticalAnnotations.NEIGHBOR_ID, newId);
321 + builder.set(OpticalAnnotations.NEIGHBOR_PORT, newPort);
322 + }
323 + addLink(port.number(), neighbor);
324 + } else {
325 + // no neighbors found
326 + builder.remove(OpticalAnnotations.NEIGHBOR_ID);
327 + builder.remove(OpticalAnnotations.NEIGHBOR_PORT);
328 + removeLink(port.number());
249 } 329 }
250 portDescs.add(new DefaultPortDescription(port.number(), port.isEnabled(), 330 portDescs.add(new DefaultPortDescription(port.number(), port.isEnabled(),
251 port.type(), port.portSpeed(), builder.build())); 331 port.type(), port.portSpeed(), builder.build()));
252 } 332 }
253 return portDescs; 333 return portDescs;
254 } 334 }
335 +
336 + private void addLink(PortNumber portNumber, OplinkPortAdjacency neighbor) {
337 + ConnectPoint dst = new ConnectPoint(handler().data().deviceId(), portNumber);
338 + ConnectPoint src = new ConnectPoint(neighbor.getDeviceId(), neighbor.portNumber);
339 + OpticalAdjacencyLinkService adService =
340 + this.handler().get(OpticalAdjacencyLinkService.class);
341 + adService.linkDetected(new DefaultLinkDescription(src, dst, Link.Type.OPTICAL));
342 + }
343 +
344 + // Remove incoming link with port if there are any.
345 + private void removeLink(PortNumber portNumber) {
346 + ConnectPoint dst = new ConnectPoint(handler().data().deviceId(), portNumber);
347 + OpticalAdjacencyLinkService adService =
348 + this.handler().get(OpticalAdjacencyLinkService.class);
349 + adService.linksVanished(dst);
350 + }
351 +
352 + private class OplinkPortAdjacency {
353 + private DeviceId deviceId;
354 + private PortNumber portNumber;
355 +
356 + public OplinkPortAdjacency(DeviceId deviceId, PortNumber portNumber) {
357 + this.deviceId = deviceId;
358 + this.portNumber = portNumber;
359 + }
360 +
361 + public DeviceId getDeviceId() {
362 + return deviceId;
363 + }
364 +
365 + public PortNumber getPort() {
366 + return portNumber;
367 + }
368 + }
255 } 369 }
......
...@@ -18,13 +18,13 @@ package org.onosproject.driver.optical.power; ...@@ -18,13 +18,13 @@ package org.onosproject.driver.optical.power;
18 18
19 import java.util.Optional; 19 import java.util.Optional;
20 20
21 -import org.onosproject.net.AnnotationKeys;
22 import org.onosproject.net.driver.AbstractHandlerBehaviour; 21 import org.onosproject.net.driver.AbstractHandlerBehaviour;
23 import org.onosproject.net.Direction; 22 import org.onosproject.net.Direction;
24 import org.onosproject.net.Port; 23 import org.onosproject.net.Port;
25 import org.onosproject.net.PortNumber; 24 import org.onosproject.net.PortNumber;
26 import org.onosproject.net.behaviour.PowerConfig; 25 import org.onosproject.net.behaviour.PowerConfig;
27 import org.onosproject.net.device.DeviceService; 26 import org.onosproject.net.device.DeviceService;
27 +import org.onosproject.net.optical.OpticalAnnotations;
28 import org.onosproject.openflow.controller.Dpid; 28 import org.onosproject.openflow.controller.Dpid;
29 import org.onosproject.openflow.controller.OpenFlowController; 29 import org.onosproject.openflow.controller.OpenFlowController;
30 import org.onosproject.openflow.controller.OpenFlowSwitch; 30 import org.onosproject.openflow.controller.OpenFlowSwitch;
...@@ -69,7 +69,7 @@ public class OplinkRoadmPowerConfig extends AbstractHandlerBehaviour ...@@ -69,7 +69,7 @@ public class OplinkRoadmPowerConfig extends AbstractHandlerBehaviour
69 DeviceService deviceService = this.handler().get(DeviceService.class); 69 DeviceService deviceService = this.handler().get(DeviceService.class);
70 Port port = deviceService.getPort(this.data().deviceId(), portNum); 70 Port port = deviceService.getPort(this.data().deviceId(), portNum);
71 if (port != null) { 71 if (port != null) {
72 - String currentPower = port.annotations().value(AnnotationKeys.CURRENT_POWER); 72 + String currentPower = port.annotations().value(OpticalAnnotations.CURRENT_POWER);
73 if (currentPower != null) { 73 if (currentPower != null) {
74 returnVal = Long.valueOf(currentPower); 74 returnVal = Long.valueOf(currentPower);
75 } 75 }
......
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
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 + */
16 +package org.onosproject.drivers.optical;
17 +
18 +import com.google.common.annotations.Beta;
19 +import org.apache.felix.scr.annotations.Activate;
20 +import org.apache.felix.scr.annotations.Component;
21 +import org.apache.felix.scr.annotations.Deactivate;
22 +import org.apache.felix.scr.annotations.Reference;
23 +import org.apache.felix.scr.annotations.ReferenceCardinality;
24 +import org.apache.felix.scr.annotations.Service;
25 +import org.onosproject.net.ConnectPoint;
26 +import org.onosproject.net.DeviceId;
27 +import org.onosproject.net.link.LinkDescription;
28 +import org.onosproject.net.link.LinkProvider;
29 +import org.onosproject.net.link.LinkProviderRegistry;
30 +import org.onosproject.net.link.LinkProviderService;
31 +import org.onosproject.net.provider.ProviderId;
32 +import org.slf4j.Logger;
33 +
34 +import static org.slf4j.LoggerFactory.getLogger;
35 +
36 +
37 +/**
38 + * Interface to allow for optical device drivers to add/remove links to
39 + * the store. Acts as a proxy to LinkProviderService.
40 + *
41 + * Registers a dummy LinkProvider to get an instance of LinkProviderService.
42 + */
43 +@Beta
44 +@Component(immediate = true)
45 +@Service
46 +public class OpticalAdjacencyLinkManager implements OpticalAdjacencyLinkService {
47 +
48 + private static final ProviderId PID =
49 + new ProviderId("of", "org.onosproject.drivers.optical");
50 +
51 + private final Logger log = getLogger(getClass());
52 +
53 + private LinkProvider linkProvider = new StubLinkProvider();
54 + private LinkProviderService linkProviderService;
55 +
56 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
57 + protected LinkProviderRegistry linkProviderRegistry;
58 +
59 + @Activate
60 + public void activate() {
61 + linkProviderService = linkProviderRegistry.register(linkProvider);
62 + log.info("Started");
63 + }
64 +
65 + @Deactivate
66 + public void deactivate() {
67 + linkProviderRegistry.unregister(linkProvider);
68 + log.info("Stopped");
69 + }
70 +
71 + /**
72 + * Signals that an infrastructure link has been detected.
73 + *
74 + * @param linkDescription link information
75 + */
76 + @Override
77 + public void linkDetected(LinkDescription linkDescription) {
78 + linkProviderService.linkDetected(linkDescription);
79 + }
80 +
81 + /**
82 + * Signals that an infrastructure link has disappeared.
83 + *
84 + * @param linkDescription link information
85 + */
86 + @Override
87 + public void linkVanished(LinkDescription linkDescription) {
88 + linkProviderService.linkVanished(linkDescription);
89 + }
90 +
91 + /**
92 + * Signals that infrastructure links associated with the specified
93 + * connect point have vanished.
94 + *
95 + * @param connectPoint connect point
96 + */
97 + @Override
98 + public void linksVanished(ConnectPoint connectPoint) {
99 + linkProviderService.linksVanished(connectPoint);
100 + }
101 +
102 + /**
103 + * Signals that infrastructure links associated with the specified
104 + * device have vanished.
105 + *
106 + * @param deviceId device identifier
107 + */
108 + @Override
109 + public void linksVanished(DeviceId deviceId) {
110 + linkProviderService.linksVanished(deviceId);
111 + }
112 +
113 + // Stub provider used to get LinkProviderService
114 + private static final class StubLinkProvider implements LinkProvider {
115 + @Override
116 + public ProviderId id() {
117 + return PID;
118 + }
119 + }
120 +}
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
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 + */
16 +package org.onosproject.drivers.optical;
17 +
18 +import com.google.common.annotations.Beta;
19 +import org.onosproject.net.ConnectPoint;
20 +import org.onosproject.net.DeviceId;
21 +import org.onosproject.net.link.LinkDescription;
22 +
23 +/**
24 + * Interface to allow for optical device drivers to add/remove links to
25 + * the store. Acts as a proxy to LinkProviderService.
26 + */
27 +@Beta
28 +public interface OpticalAdjacencyLinkService {
29 + /**
30 + * Signals that an infrastructure link has been detected.
31 + *
32 + * @param linkDescription link information
33 + */
34 + void linkDetected(LinkDescription linkDescription);
35 +
36 + /**
37 + * Signals that an infrastructure link has disappeared.
38 + *
39 + * @param linkDescription link information
40 + */
41 + void linkVanished(LinkDescription linkDescription);
42 +
43 + /**
44 + * Signals that infrastructure links associated with the specified
45 + * connect point have vanished.
46 + *
47 + * @param connectPoint connect point
48 + */
49 + void linksVanished(ConnectPoint connectPoint);
50 +
51 + /**
52 + * Signals that infrastructure links associated with the specified
53 + * device have vanished.
54 + *
55 + * @param deviceId device identifier
56 + */
57 + void linksVanished(DeviceId deviceId);
58 +}
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
51 manufacturer="Oplink a Molex company" hwVersion="ROADM" 51 manufacturer="Oplink a Molex company" hwVersion="ROADM"
52 swVersion="of-agent"> 52 swVersion="of-agent">
53 <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver" 53 <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
54 - impl="org.onosproject.driver.optical.handshaker.OplinkRoadmHandshaker"/> 54 + impl="org.onosproject.driver.optical.handshaker.OplinkRoadm"/>
55 <behaviour api="org.onosproject.net.behaviour.LambdaQuery" 55 <behaviour api="org.onosproject.net.behaviour.LambdaQuery"
56 impl="org.onosproject.driver.optical.query.OplinkRoadmLambdaQuery"/> 56 impl="org.onosproject.driver.optical.query.OplinkRoadmLambdaQuery"/>
57 <behaviour api="org.onosproject.net.optical.OpticalDevice" 57 <behaviour api="org.onosproject.net.optical.OpticalDevice"
......