Search in sources :

Example 1 with OpticalAdjacencyLinkService

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));
}
Also used : OpticalAdjacencyLinkService(org.onosproject.drivers.optical.OpticalAdjacencyLinkService) ConnectPoint(org.onosproject.net.ConnectPoint) OpticalAdjacencyLinkService(org.onosproject.drivers.optical.OpticalAdjacencyLinkService) LinkService(org.onosproject.net.link.LinkService) Link(org.onosproject.net.Link) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription)

Aggregations

OpticalAdjacencyLinkService (org.onosproject.drivers.optical.OpticalAdjacencyLinkService)1 ConnectPoint (org.onosproject.net.ConnectPoint)1 Link (org.onosproject.net.Link)1 DefaultLinkDescription (org.onosproject.net.link.DefaultLinkDescription)1 LinkService (org.onosproject.net.link.LinkService)1