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();
}
Aggregations