Search in sources :

Example 11 with DefaultDriverHandler

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

the class FlowModBuilder method buildExtensionOxm.

private OFOxm buildExtensionOxm(ExtensionSelector extension) {
    if (!driverService.isPresent()) {
        log.error("No driver service present");
        return null;
    }
    Driver driver = driverService.get().getDriver(deviceId);
    if (driver.hasBehaviour(ExtensionSelectorInterpreter.class)) {
        DefaultDriverHandler handler = new DefaultDriverHandler(new DefaultDriverData(driver, deviceId));
        ExtensionSelectorInterpreter interpreter = handler.behaviour(ExtensionSelectorInterpreter.class);
        return interpreter.mapSelector(factory(), extension);
    }
    return null;
}
Also used : ExtensionSelectorInterpreter(org.onosproject.openflow.controller.ExtensionSelectorInterpreter) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) Driver(org.onosproject.net.driver.Driver) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Example 12 with DefaultDriverHandler

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

the class NetconfDeviceProvider method getDeviceDescription.

private DeviceDescription getDeviceDescription(DeviceId deviceId, NetconfDeviceConfig config) {
    Driver driver = driverService.getDriver(deviceId);
    if (driver.hasBehaviour(DeviceDescriptionDiscovery.class)) {
        final DriverData data = new DefaultDriverData(driver, deviceId);
        final DriverHandler handler = new DefaultDriverHandler(data);
        // creating the behaviour because the core has yet no notion of device.
        DeviceDescriptionDiscovery deviceDescriptionDiscovery = driver.createBehaviour(handler, DeviceDescriptionDiscovery.class);
        return getDeviceRepresentation(deviceId, config, deviceDescriptionDiscovery);
    } else {
        return existingOrEmptyDescription(deviceId, config);
    }
}
Also used : DefaultDriverData(org.onosproject.net.driver.DefaultDriverData) DriverData(org.onosproject.net.driver.DriverData) DeviceDescriptionDiscovery(org.onosproject.net.device.DeviceDescriptionDiscovery) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) DriverHandler(org.onosproject.net.driver.DriverHandler) Driver(org.onosproject.net.driver.Driver) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Example 13 with DefaultDriverHandler

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

the class ExtensionCriterionSerializer method read.

@Override
public ExtensionCriterion read(Kryo kryo, Input input, Class<ExtensionCriterion> type) {
    ExtensionSelectorType exType = (ExtensionSelectorType) kryo.readClassAndObject(input);
    DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input);
    DriverService driverService = DefaultServiceDirectory.getService(DriverService.class);
    byte[] bytes = (byte[]) kryo.readClassAndObject(input);
    ExtensionSelector selector;
    try {
        DriverHandler handler = new DefaultDriverHandler(new DefaultDriverData(driverService.getDriver(deviceId), deviceId));
        ExtensionSelectorResolver resolver = handler.behaviour(ExtensionSelectorResolver.class);
        selector = resolver.getExtensionSelector(exType);
        selector.deserialize(bytes);
    } catch (ItemNotFoundException | IllegalArgumentException e) {
        selector = new UnresolvedExtensionSelector(bytes, exType);
    }
    return Criteria.extension(selector, deviceId);
}
Also used : UnresolvedExtensionSelector(org.onosproject.net.flow.criteria.UnresolvedExtensionSelector) ExtensionSelector(org.onosproject.net.flow.criteria.ExtensionSelector) DeviceId(org.onosproject.net.DeviceId) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) ExtensionSelectorResolver(org.onosproject.net.behaviour.ExtensionSelectorResolver) UnresolvedExtensionSelector(org.onosproject.net.flow.criteria.UnresolvedExtensionSelector) DriverHandler(org.onosproject.net.driver.DriverHandler) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) ExtensionSelectorType(org.onosproject.net.flow.criteria.ExtensionSelectorType) DriverService(org.onosproject.net.driver.DriverService) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Example 14 with DefaultDriverHandler

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

the class ExtensionInstructionSerializer method read.

@Override
public Instructions.ExtensionInstructionWrapper read(Kryo kryo, Input input, Class<Instructions.ExtensionInstructionWrapper> type) {
    ExtensionTreatmentType exType = (ExtensionTreatmentType) kryo.readClassAndObject(input);
    DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input);
    String driverName = (String) kryo.readClassAndObject(input);
    DriverService driverService = DefaultServiceDirectory.getService(DriverService.class);
    byte[] bytes = (byte[]) kryo.readClassAndObject(input);
    ExtensionTreatment instruction;
    try {
        DriverHandler handler = new DefaultDriverHandler(new DefaultDriverData(driverService.getDriver(driverName), deviceId));
        ExtensionTreatmentResolver resolver = handler.behaviour(ExtensionTreatmentResolver.class);
        instruction = resolver.getExtensionInstruction(exType);
        instruction.deserialize(bytes);
    } catch (ItemNotFoundException | IllegalArgumentException e) {
        instruction = new UnresolvedExtensionTreatment(bytes, exType);
    }
    return Instructions.extension(instruction, deviceId);
}
Also used : DeviceId(org.onosproject.net.DeviceId) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) ExtensionTreatmentResolver(org.onosproject.net.behaviour.ExtensionTreatmentResolver) UnresolvedExtensionTreatment(org.onosproject.net.flow.instructions.UnresolvedExtensionTreatment) DriverHandler(org.onosproject.net.driver.DriverHandler) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) ExtensionTreatment(org.onosproject.net.flow.instructions.ExtensionTreatment) UnresolvedExtensionTreatment(org.onosproject.net.flow.instructions.UnresolvedExtensionTreatment) ExtensionTreatmentType(org.onosproject.net.flow.instructions.ExtensionTreatmentType) DriverService(org.onosproject.net.driver.DriverService) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Example 15 with DefaultDriverHandler

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

the class OvsdbControllerConfigTest method setUp.

@Before
public void setUp() {
    controllerConfig = new OvsdbControllerConfig();
    ddc = new DefaultDriver("foo.bar", new ArrayList<>(), "Circus", "lux", "1.2a", ImmutableMap.of(ControllerConfig.class, OvsdbControllerConfig.class), ImmutableMap.of("foo", "bar"));
    data = new DefaultDriverData(ddc, DEVICE_ID);
    handler = new DefaultDriverHandler(data);
// handler.controllerConfig.setHandler(handler);
// TODO setTestService directory on handler
// TODO setup ovsdb fake controller with fake ovsdbclient
// TODO setup fake device service
}
Also used : DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) DefaultDriver(org.onosproject.net.driver.DefaultDriver) ArrayList(java.util.ArrayList) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData) Before(org.junit.Before)

Aggregations

DefaultDriverData (org.onosproject.net.driver.DefaultDriverData)18 DefaultDriverHandler (org.onosproject.net.driver.DefaultDriverHandler)18 Driver (org.onosproject.net.driver.Driver)13 DriverHandler (org.onosproject.net.driver.DriverHandler)8 DeviceId (org.onosproject.net.DeviceId)5 ItemNotFoundException (org.onlab.util.ItemNotFoundException)3 DriverData (org.onosproject.net.driver.DriverData)3 ArrayList (java.util.ArrayList)2 ExtensionTreatmentResolver (org.onosproject.net.behaviour.ExtensionTreatmentResolver)2 DeviceDescriptionDiscovery (org.onosproject.net.device.DeviceDescriptionDiscovery)2 DriverService (org.onosproject.net.driver.DriverService)2 Beta (com.google.common.annotations.Beta)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 EnumSet (java.util.EnumSet)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors.newSingleThreadExecutor (java.util.concurrent.Executors.newSingleThreadExecutor)1