use of org.onosproject.net.driver.DriverHandler 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.DriverHandler 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.DriverHandler in project onos by opennetworkinglab.
the class NetconfRpcTestCommand method doExecute.
@Override
protected void doExecute() {
DriverService service = get(DriverService.class);
deviceId = DeviceId.deviceId(uri);
DriverHandler h = service.createHandler(deviceId);
ConfigSetter config = h.behaviour(ConfigSetter.class);
checkNotNull(cfgFile, "Configuration file cannot be null");
print(config.setConfiguration(cfgFile));
}
use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.
the class DeviceControllersCommand method doExecute.
@Override
protected void doExecute() {
DriverService service = get(DriverService.class);
deviceId = DeviceId.deviceId(uri);
DriverHandler h = service.createHandler(deviceId);
ControllerConfig config = h.behaviour(ControllerConfig.class);
config.getControllers().forEach(c -> print(c.target()));
}
use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.
the class DeviceInterfacesListCommand method printDevice.
private void printDevice(DeviceService deviceService, DriverService driverService, Device device) {
super.printDevice(deviceService, device);
if (!device.is(InterfaceConfig.class)) {
// The relevant behavior is not supported by the device.
print(ERROR_RESULT);
return;
}
DriverHandler h = driverService.createHandler(device.id());
InterfaceConfig interfaceConfig = h.behaviour(InterfaceConfig.class);
List<DeviceInterfaceDescription> interfaces = interfaceConfig.getInterfaces();
if (interfaces == null) {
print(ERROR_RESULT);
} else if (interfaces.isEmpty()) {
print(NO_INTERFACES);
} else {
interfaces.forEach(this::printInterface);
}
}
Aggregations