Search in sources :

Example 1 with IntentId

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();
}
Also used : Port(org.onosproject.net.Port) OchPort(org.onosproject.net.optical.OchPort) OduCltPort(org.onosproject.net.optical.OduCltPort) ConnectPoint(org.onosproject.net.ConnectPoint) OchPort(org.onosproject.net.optical.OchPort) IntentId(org.onosproject.net.intent.IntentId)

Example 2 with IntentId

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);
}
Also used : IntentService(org.onosproject.net.intent.IntentService) IntentId(org.onosproject.net.intent.IntentId)

Example 3 with IntentId

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");
    }
}
Also used : GnpyService(org.onosproject.odtn.GnpyService) ConnectPoint(org.onosproject.net.ConnectPoint) IntentId(org.onosproject.net.intent.IntentId)

Aggregations

IntentId (org.onosproject.net.intent.IntentId)3 ConnectPoint (org.onosproject.net.ConnectPoint)2 Port (org.onosproject.net.Port)1 IntentService (org.onosproject.net.intent.IntentService)1 OchPort (org.onosproject.net.optical.OchPort)1 OduCltPort (org.onosproject.net.optical.OduCltPort)1 GnpyService (org.onosproject.odtn.GnpyService)1