Search in sources :

Example 1 with LambdaQuery

use of org.onosproject.net.behaviour.LambdaQuery in project onos by opennetworkinglab.

the class PortAvailableWaveLengthCommand method doExecute.

@Override
protected void doExecute() throws Exception {
    DeviceService deviceService = get(DeviceService.class);
    ConnectPoint cp = ConnectPoint.deviceConnectPoint(connectPointString);
    Device d = deviceService.getDevice(cp.deviceId());
    if (d.is(LambdaQuery.class)) {
        LambdaQuery lambdaQuery = d.as(LambdaQuery.class);
        lambdaQuery.queryLambdas(cp.port()).forEach(lambda -> {
            print(FMT, lambda.toString(), lambda.centralFrequency().asGHz());
        });
    } else {
        print("Device is not capable of querying lambdas");
    }
}
Also used : LambdaQuery(org.onosproject.net.behaviour.LambdaQuery) Device(org.onosproject.net.Device) DeviceService(org.onosproject.net.device.DeviceService) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 2 with LambdaQuery

use of org.onosproject.net.behaviour.LambdaQuery in project onos by opennetworkinglab.

the class RoadmManager method getLambdaQuery.

private LambdaQuery getLambdaQuery(DeviceId deviceId) {
    Device device = deviceService.getDevice(deviceId);
    if (device != null && device.is(LambdaQuery.class)) {
        return device.as(LambdaQuery.class);
    }
    // Do not need warning here for port polling.
    log.debug("Unable to load LambdaQuery for {}", deviceId);
    return null;
}
Also used : LambdaQuery(org.onosproject.net.behaviour.LambdaQuery) Device(org.onosproject.net.Device)

Example 3 with LambdaQuery

use of org.onosproject.net.behaviour.LambdaQuery in project onos by opennetworkinglab.

the class RoadmManager method queryLambdas.

@Override
public Set<OchSignal> queryLambdas(DeviceId deviceId, PortNumber portNumber) {
    checkNotNull(deviceId);
    checkNotNull(portNumber);
    LambdaQuery lambdaQuery = getLambdaQuery(deviceId);
    if (lambdaQuery != null) {
        return lambdaQuery.queryLambdas(portNumber);
    }
    return Collections.emptySet();
}
Also used : LambdaQuery(org.onosproject.net.behaviour.LambdaQuery)

Example 4 with LambdaQuery

use of org.onosproject.net.behaviour.LambdaQuery in project onos by opennetworkinglab.

the class RoadmManager method validChannel.

@Override
public boolean validChannel(DeviceId deviceId, PortNumber portNumber, OchSignal ochSignal) {
    checkNotNull(deviceId);
    checkNotNull(portNumber);
    checkNotNull(ochSignal);
    LambdaQuery lambdaQuery = getLambdaQuery(deviceId);
    if (lambdaQuery != null) {
        Set<OchSignal> channels = lambdaQuery.queryLambdas(portNumber);
        return channels.contains(ochSignal);
    }
    return false;
}
Also used : LambdaQuery(org.onosproject.net.behaviour.LambdaQuery) OchSignal(org.onosproject.net.OchSignal)

Example 5 with LambdaQuery

use of org.onosproject.net.behaviour.LambdaQuery in project onos by opennetworkinglab.

the class ResourceDeviceListener method queryLambdas.

private Set<OchSignal> queryLambdas(DeviceId did, PortNumber port) {
    try {
        DriverHandler handler = driverService.createHandler(did);
        if (handler == null || !handler.hasBehaviour(LambdaQuery.class)) {
            return Collections.emptySet();
        }
        LambdaQuery query = handler.behaviour(LambdaQuery.class);
        if (query != null) {
            return query.queryLambdas(port).stream().flatMap(ResourceDeviceListener::toResourceGrid).collect(ImmutableSet.toImmutableSet());
        } else {
            return Collections.emptySet();
        }
    } catch (ItemNotFoundException e) {
        return Collections.emptySet();
    }
}
Also used : LambdaQuery(org.onosproject.net.behaviour.LambdaQuery) DriverHandler(org.onosproject.net.driver.DriverHandler) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Aggregations

LambdaQuery (org.onosproject.net.behaviour.LambdaQuery)5 Device (org.onosproject.net.Device)2 ItemNotFoundException (org.onlab.util.ItemNotFoundException)1 ConnectPoint (org.onosproject.net.ConnectPoint)1 OchSignal (org.onosproject.net.OchSignal)1 DeviceService (org.onosproject.net.device.DeviceService)1 DriverHandler (org.onosproject.net.driver.DriverHandler)1