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;
}
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);
}
}
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);
}
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);
}
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
}
Aggregations