use of org.onosproject.drivers.optical.OpticalAdjacencyLinkService in project onos by opennetworkinglab.
the class OplinkHandshakerUtil method addLink.
// Add incoming link with port
private void addLink(PortNumber portNumber, OplinkPortAdjacency neighbor) {
ConnectPoint dst = new ConnectPoint(driver.handler().data().deviceId(), portNumber);
Set<Link> links = driver.handler().get(LinkService.class).getIngressLinks(dst);
// find out if the new report link is the same as before
for (Link link : links) {
if (link.src().port().equals(neighbor.getPort())) {
return;
}
}
OpticalAdjacencyLinkService adService = driver.handler().get(OpticalAdjacencyLinkService.class);
// remove the old link of destination connect point
if (!links.isEmpty()) {
log.debug("Remove link of destination {}.", dst);
adService.linksVanished(dst);
}
// add the new link
ConnectPoint src = new ConnectPoint(neighbor.getDeviceId(), neighbor.getPort());
log.debug("Add link from {} to {}.", src, dst);
adService.linkDetected(new DefaultLinkDescription(src, dst, Link.Type.OPTICAL));
}
Aggregations