Search in sources :

Example 1 with PiPipeconfId

use of org.onosproject.net.pi.model.PiPipeconfId in project onos by opennetworkinglab.

the class AbstractFabricHandlerBehavior method setCapabilitiesFromHandler.

private void setCapabilitiesFromHandler(DeviceId deviceId, PiPipeconfService pipeconfService) {
    checkNotNull(deviceId);
    checkNotNull(pipeconfService);
    // Get pipeconf capabilities.
    final PiPipeconfId pipeconfId = pipeconfService.ofDevice(deviceId).orElse(null);
    if (pipeconfId == null) {
        throw new IllegalStateException(format("Unable to get pipeconf ID of device %s", deviceId.toString()));
    }
    if (!pipeconfService.getPipeconf(pipeconfId).isPresent()) {
        throw new IllegalStateException(format("Pipeconf '%s' is not registered ", pipeconfId));
    }
    this.capabilities = new FabricCapabilities(pipeconfService.getPipeconf(pipeconfId).get());
}
Also used : PiPipeconfId(org.onosproject.net.pi.model.PiPipeconfId)

Example 2 with PiPipeconfId

use of org.onosproject.net.pi.model.PiPipeconfId in project onos by opennetworkinglab.

the class DriverManager method getPipeconfMergedDriver.

private Driver getPipeconfMergedDriver(DeviceId deviceId) {
    PiPipeconfId pipeconfId = pipeconfService.ofDevice(deviceId).orElse(null);
    if (pipeconfId == null) {
        log.warn("Missing pipeconf for {}, cannot produce a pipeconf merged driver", deviceId);
        return null;
    }
    String mergedDriverName = pipeconfService.getMergedDriver(deviceId, pipeconfId);
    if (mergedDriverName == null) {
        log.warn("Unable to get pipeconf merged driver for {} and {}", deviceId, pipeconfId);
        return null;
    }
    try {
        return getDriver(mergedDriverName);
    } catch (ItemNotFoundException e) {
        log.warn("Specified pipeconf merged driver {} for {} not found", mergedDriverName, deviceId);
        return null;
    }
}
Also used : PiPipeconfId(org.onosproject.net.pi.model.PiPipeconfId) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Example 3 with PiPipeconfId

use of org.onosproject.net.pi.model.PiPipeconfId in project onos by opennetworkinglab.

the class PiPipeconfWatchdogManager method probeTask.

private void probeTask(Device device) {
    if (!isLocalMaster(device)) {
        return;
    }
    final PiPipeconfId pipeconfId = pipeconfMappingStore.getPipeconfId(device.id());
    if (pipeconfId == null || !device.is(PiPipelineProgrammable.class)) {
        return;
    }
    if (pipeconfService.getPipeconf(pipeconfId).isEmpty()) {
        log.warn("Pipeconf {} is not registered, skipping probe for {}", pipeconfId, device.id());
        return;
    }
    final PiPipeconf pipeconf = pipeconfService.getPipeconf(pipeconfId).get();
    if (!device.is(DeviceHandshaker.class)) {
        log.error("Missing DeviceHandshaker behavior for {}", device.id());
        return;
    }
    final boolean success = doSetPipeconfIfRequired(device, pipeconf);
    // the mastership after pipeline probe returns.
    if (isLocalMaster(device)) {
        // (next reconcile interval)
        if (success) {
            signalStatusReady(device.id());
            signalStatusConfigured(device.id());
        } else {
            // When a network partition occurs watchdog is stuck for LONG_TIMEOUT
            // before returning and will mark the device offline. However, in the
            // meanwhile the mastership has been passed to another instance which is
            // already connected and has already marked the device online.
            signalStatusUnknown(device.id());
        }
    } else {
        log.warn("No longer the master for {} aborting probe task", device.id());
    }
}
Also used : DeviceHandshaker(org.onosproject.net.device.DeviceHandshaker) PiPipeconf(org.onosproject.net.pi.model.PiPipeconf) PiPipeconfId(org.onosproject.net.pi.model.PiPipeconfId)

Example 4 with PiPipeconfId

use of org.onosproject.net.pi.model.PiPipeconfId in project onos by opennetworkinglab.

the class GeneralDeviceProvider method getPipeconfId.

private PiPipeconfId getPipeconfId(DeviceId deviceId, PiPipelineProgrammable pipelineProg) {
    // Places to look for a pipeconf ID (in priority order)):
    // 1) netcfg
    // 2) device driver (default one)
    final PiPipeconfId pipeconfId = getPipeconfFromCfg(deviceId);
    if (pipeconfId != null && !pipeconfId.id().isEmpty()) {
        return pipeconfId;
    }
    if (pipelineProg != null && pipelineProg.getDefaultPipeconf().isPresent()) {
        final PiPipeconf defaultPipeconf = pipelineProg.getDefaultPipeconf().get();
        log.info("Using default pipeconf {} for {}", defaultPipeconf.id(), deviceId);
        return defaultPipeconf.id();
    }
    return null;
}
Also used : PiPipeconf(org.onosproject.net.pi.model.PiPipeconf) PiPipeconfId(org.onosproject.net.pi.model.PiPipeconfId)

Example 5 with PiPipeconfId

use of org.onosproject.net.pi.model.PiPipeconfId in project onos by opennetworkinglab.

the class GeneralDeviceProvider method bindPipeconfIfRequired.

private void bindPipeconfIfRequired(DeviceId deviceId) {
    if (pipeconfService.getPipeconf(deviceId).isPresent() || !isPipelineProgrammable(deviceId)) {
        // Device has already a pipeconf or is not programmable.
        return;
    }
    // Get pipeconf from netcfg or driver (default one).
    final PiPipelineProgrammable pipelineProg = getBehaviour(deviceId, PiPipelineProgrammable.class);
    final PiPipeconfId pipeconfId = getPipeconfId(deviceId, pipelineProg);
    if (pipeconfId == null) {
        throw new DeviceTaskException("unable to find pipeconf");
    }
    if (!pipeconfService.getPipeconf(pipeconfId).isPresent()) {
        throw new DeviceTaskException(format("pipeconf %s not registered", pipeconfId));
    }
    // Store binding in pipeconf service.
    pipeconfService.bindToDevice(pipeconfId, deviceId);
}
Also used : PiPipelineProgrammable(org.onosproject.net.behaviour.PiPipelineProgrammable) PiPipeconfId(org.onosproject.net.pi.model.PiPipeconfId) DeviceTaskException(org.onosproject.provider.general.device.impl.DeviceTaskExecutor.DeviceTaskException)

Aggregations

PiPipeconfId (org.onosproject.net.pi.model.PiPipeconfId)9 HexString (org.onlab.util.HexString)2 BasicDeviceConfig (org.onosproject.net.config.basics.BasicDeviceConfig)2 PiPipeconf (org.onosproject.net.pi.model.PiPipeconf)2 Test (org.junit.Test)1 ItemNotFoundException (org.onlab.util.ItemNotFoundException)1 PiPipelineProgrammable (org.onosproject.net.behaviour.PiPipelineProgrammable)1 DeviceHandshaker (org.onosproject.net.device.DeviceHandshaker)1 AbstractHandlerBehaviour (org.onosproject.net.driver.AbstractHandlerBehaviour)1 Behaviour (org.onosproject.net.driver.Behaviour)1 Driver (org.onosproject.net.driver.Driver)1 DriverProvider (org.onosproject.net.driver.DriverProvider)1 DeviceTaskException (org.onosproject.provider.general.device.impl.DeviceTaskExecutor.DeviceTaskException)1