Search in sources :

Example 1 with EdgePortService

use of org.onosproject.net.edge.EdgePortService in project onos by opennetworkinglab.

the class CreateNullEntity method findAvailablePorts.

/**
 * Finds an available connect points among edge ports of the specified device.
 *
 * @param deviceId device identifier
 * @return list of connect points available for link or host attachments
 */
protected List<ConnectPoint> findAvailablePorts(DeviceId deviceId) {
    EdgePortService eps = get(EdgePortService.class);
    // As there may be a slight delay in edge service getting updated, retry a few times
    for (int i = 0; i < MAX_EDGE_PORT_TRIES; i++) {
        List<ConnectPoint> points = ImmutableList.sortedCopyOf((l, r) -> Longs.compare(l.port().toLong(), r.port().toLong()), eps.getEdgePoints(deviceId));
        if (!points.isEmpty()) {
            return points;
        }
        Tools.delay(100);
    }
    return ImmutableList.of();
}
Also used : EdgePortService(org.onosproject.net.edge.EdgePortService) ConnectPoint(org.onosproject.net.ConnectPoint) ConnectPoint(org.onosproject.net.ConnectPoint)

Aggregations

ConnectPoint (org.onosproject.net.ConnectPoint)1 EdgePortService (org.onosproject.net.edge.EdgePortService)1