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