use of org.onosproject.net.intent.IntentId in project onos by opennetworkinglab.
the class OpticalCircuitIntentCompiler method findAvailableOchPort.
private Optional<OchPort> findAvailableOchPort(ConnectPoint oduPort, OduSignalType ochPortSignalType) {
// First see if the port mappings are constrained
ConnectPoint ochCP = staticPort(oduPort);
if (ochCP != null) {
OchPort ochPort = (OchPort) deviceService.getPort(ochCP.deviceId(), ochCP.port());
Optional<IntentId> intentId = resourceService.getResourceAllocations(Resources.discrete(ochCP.deviceId(), ochCP.port()).id()).stream().map(ResourceAllocation::consumerId).map(ResourceHelper::getIntentId).flatMap(Tools::stream).findAny();
if (isAvailable(intentId.orElse(null))) {
return Optional.of(ochPort);
}
return Optional.empty();
}
// No port constraints, so find any port that works
List<Port> ports = deviceService.getPorts(oduPort.deviceId());
for (Port port : ports) {
if (!(port instanceof OchPort)) {
continue;
}
// This should be the first allocation on the OCH port
if (!resourceService.isAvailable(Resources.discrete(oduPort.deviceId(), port.number()).resource())) {
continue;
}
// OchPort is required to have the requested oduSignalType
if (((OchPort) port).signalType() != ochPortSignalType) {
continue;
}
Optional<IntentId> intentId = resourceService.getResourceAllocations(Resources.discrete(oduPort.deviceId(), port.number()).id()).stream().map(ResourceAllocation::consumerId).map(ResourceHelper::getIntentId).flatMap(Tools::stream).findAny();
if (isAvailable(intentId.orElse(null))) {
return Optional.of((OchPort) port);
}
}
return Optional.empty();
}
use of org.onosproject.net.intent.IntentId in project onos by opennetworkinglab.
the class IntentDetailsCommand method detailIntents.
/**
* Print detailed data for intents, given a list of IDs.
*
* @param intentsIds List of intent IDs
*/
public void detailIntents(List<String> intentsIds) {
if (intentsIds != null) {
ids = intentsIds.stream().map(IntentId::valueOf).collect(Collectors.toSet());
}
IntentService service = get(IntentService.class);
Tools.stream(service.getIntentData()).filter(this::filter).forEach(this::printIntentData);
}
use of org.onosproject.net.intent.IntentId in project onos by opennetworkinglab.
the class GnpyConnectionRequestCommand method doExecute.
@Override
protected void doExecute() {
GnpyService service = get(GnpyService.class);
if (!service.isConnected()) {
print("gNPY is not connected, please issue `odtn-connect-gnpy-command` first");
return;
}
ConnectPoint ingress = createConnectPoint(ingressString);
ConnectPoint egress = createConnectPoint(egressString);
Pair<IntentId, Double> intentIdAndOsnr = service.obtainConnectivity(ingress, egress, bidirectional);
if (intentIdAndOsnr != null) {
print("Optical Connectivity from %s to %s submitted through GNPy. \n", ingress, egress);
print("Expected GSNR %.2f dB", intentIdAndOsnr.getRight().doubleValue());
print("Intent: %s", intentIdAndOsnr.getLeft());
} else {
print("Error in submitting Optical Connectivity submitted through GNPy, please see logs");
}
}
Aggregations