Search in sources :

Example 46 with DriverHandler

use of org.onosproject.net.driver.DriverHandler 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)

Example 47 with DriverHandler

use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.

the class ResourceDeviceListener method queryVlanIds.

private Set<VlanId> queryVlanIds(DeviceId device, PortNumber port) {
    try {
        DriverHandler handler = driverService.createHandler(device);
        if (handler == null || !handler.hasBehaviour(VlanQuery.class)) {
            return ImmutableSet.of();
        }
        VlanQuery query = handler.behaviour(VlanQuery.class);
        if (query == null) {
            return ImmutableSet.of();
        }
        return query.queryVlanIds(port);
    } catch (ItemNotFoundException e) {
        return ImmutableSet.of();
    }
}
Also used : DriverHandler(org.onosproject.net.driver.DriverHandler) VlanQuery(org.onosproject.net.behaviour.VlanQuery) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Example 48 with DriverHandler

use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.

the class ResourceDeviceListener method queryTributarySlots.

private Set<TributarySlot> queryTributarySlots(DeviceId device, PortNumber port) {
    try {
        DriverHandler handler = driverService.createHandler(device);
        if (handler == null || !handler.hasBehaviour(TributarySlotQuery.class)) {
            return Collections.emptySet();
        }
        TributarySlotQuery query = handler.behaviour(TributarySlotQuery.class);
        if (query != null) {
            return query.queryTributarySlots(port);
        } else {
            return Collections.emptySet();
        }
    } catch (ItemNotFoundException e) {
        return Collections.emptySet();
    }
}
Also used : DriverHandler(org.onosproject.net.driver.DriverHandler) TributarySlotQuery(org.onosproject.net.behaviour.TributarySlotQuery) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Example 49 with DriverHandler

use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.

the class FlowObjectiveManager method initPipelineHandler.

/**
 * Creates and initialize {@link Pipeliner}.
 * <p>
 * Note: Expected to be called under per-Device lock.
 *      e.g., {@code pipeliners}' Map#compute family methods
 *
 * @param deviceId Device to initialize pipeliner
 * @return {@link Pipeliner} instance or null
 */
private Pipeliner initPipelineHandler(DeviceId deviceId) {
    start = now();
    // Attempt to lookup the handler in the cache
    DriverHandler handler = driverHandlers.get(deviceId);
    cTime = now();
    if (handler == null) {
        try {
            // Otherwise create it and if it has pipeline behaviour, cache it
            handler = driverService.createHandler(deviceId);
            dTime = now();
            if (!handler.driver().hasBehaviour(Pipeliner.class)) {
                log.debug("Pipeline behaviour not supported for device {}", deviceId);
                return null;
            }
        } catch (ItemNotFoundException e) {
            log.warn("No applicable driver for device {}", deviceId);
            return null;
        }
        driverHandlers.put(deviceId, handler);
        eTime = now();
    }
    // Always (re)initialize the pipeline behaviour
    log.info("Driver {} bound to device {} ... initializing driver", handler.driver().name(), deviceId);
    hTime = now();
    Pipeliner pipeliner = handler.behaviour(Pipeliner.class);
    hbTime = now();
    pipeliner.init(deviceId, context);
    stopWatch();
    return pipeliner;
}
Also used : Pipeliner(org.onosproject.net.behaviour.Pipeliner) DriverHandler(org.onosproject.net.driver.DriverHandler) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Example 50 with DriverHandler

use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.

the class FlowObjectiveCompositionManager method setupPipelineHandler.

private void setupPipelineHandler(DeviceId deviceId) {
    // Attempt to lookup the handler in the cache
    DriverHandler handler = driverHandlers.get(deviceId);
    if (handler == null) {
        try {
            // Otherwise create it and if it has pipeline behaviour, cache it
            handler = driverService.createHandler(deviceId);
            if (!handler.driver().hasBehaviour(Pipeliner.class)) {
                log.warn("Pipeline behaviour not supported for device {}", deviceId);
                return;
            }
        } catch (ItemNotFoundException e) {
            log.warn("No applicable driver for device {}", deviceId);
            return;
        }
        driverHandlers.put(deviceId, handler);
    }
    // Always (re)initialize the pipeline behaviour
    log.info("Driver {} bound to device {} ... initializing driver", handler.driver().name(), deviceId);
    Pipeliner pipeliner = handler.behaviour(Pipeliner.class);
    pipeliner.init(deviceId, context);
    pipeliners.putIfAbsent(deviceId, pipeliner);
}
Also used : Pipeliner(org.onosproject.net.behaviour.Pipeliner) DriverHandler(org.onosproject.net.driver.DriverHandler) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Aggregations

DriverHandler (org.onosproject.net.driver.DriverHandler)104 DeviceId (org.onosproject.net.DeviceId)46 DriverService (org.onosproject.net.driver.DriverService)22 NetconfController (org.onosproject.netconf.NetconfController)22 NetconfException (org.onosproject.netconf.NetconfException)22 MastershipService (org.onosproject.mastership.MastershipService)20 ArrayList (java.util.ArrayList)12 DefaultDriverHandler (org.onosproject.net.driver.DefaultDriverHandler)12 ItemNotFoundException (org.onlab.util.ItemNotFoundException)9 DeviceService (org.onosproject.net.device.DeviceService)9 OvsdbClientService (org.onosproject.ovsdb.controller.OvsdbClientService)9 DefaultDriverData (org.onosproject.net.driver.DefaultDriverData)8 Driver (org.onosproject.net.driver.Driver)8 Test (org.junit.Test)7 ControllerInfo (org.onosproject.net.behaviour.ControllerInfo)6 RestSBController (org.onosproject.protocol.rest.RestSBController)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 PolicerConfigurable (org.onosproject.net.behaviour.trafficcontrol.PolicerConfigurable)5 PolicerId (org.onosproject.net.behaviour.trafficcontrol.PolicerId)5