use of org.onosproject.net.driver.DefaultDriverData in project onos by opennetworkinglab.
the class SelectGroupHandler method buildNiciraExtenstion.
/**
* Builds Nicira extension for tagging remoteIp of vxlan.
*
* @param id device id of vxlan source device
* @param hostIp remote ip of vxlan destination device
* @return NiciraExtension Treatment
*/
private ExtensionTreatment buildNiciraExtenstion(DeviceId id, Ip4Address hostIp) {
Driver driver = driverService.getDriver(id);
DriverHandler driverHandler = new DefaultDriverHandler(new DefaultDriverData(driver, id));
ExtensionTreatmentResolver resolver = driverHandler.behaviour(ExtensionTreatmentResolver.class);
ExtensionTreatment extensionInstruction = resolver.getExtensionInstruction(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST.type());
try {
extensionInstruction.setPropertyValue(TUNNEL_DESTINATION, hostIp);
} catch (ExtensionPropertyException e) {
log.error("Error setting Nicira extension setting {}", e);
}
return extensionInstruction;
}
use of org.onosproject.net.driver.DefaultDriverData in project onos by opennetworkinglab.
the class DeviceInjectionConfigMonitor method injectDevice.
private void injectDevice(DeviceId did) {
Optional<BasicDeviceConfig> basic = Optional.ofNullable(netcfgService.getConfig(did, BasicDeviceConfig.class));
Optional<DeviceDescriptionDiscovery> discovery = basic.map(BasicDeviceConfig::driver).map(driverService::getDriver).filter(drvr -> drvr.hasBehaviour(DeviceDescriptionDiscovery.class)).map(drvr -> drvr.createBehaviour(new DefaultDriverHandler(new DefaultDriverData(drvr, did)), DeviceDescriptionDiscovery.class));
if (discovery.isPresent()) {
providerService.deviceConnected(did, discovery.get().discoverDeviceDetails());
providerService.updatePorts(did, discovery.get().discoverPortDetails());
} else {
String unk = "UNKNOWN";
DefaultDeviceDescription desc = new DefaultDeviceDescription(did.uri(), basic.map(BasicDeviceConfig::type).orElse(Type.SWITCH), basic.map(BasicDeviceConfig::manufacturer).orElse(unk), basic.map(BasicDeviceConfig::hwVersion).orElse(unk), basic.map(BasicDeviceConfig::swVersion).orElse(unk), basic.map(BasicDeviceConfig::serial).orElse(unk), new ChassisId(), true);
providerService.deviceConnected(did, desc);
Optional<DeviceInjectionConfig> inject = Optional.ofNullable(netcfgService.getConfig(did, DeviceInjectionConfig.class));
String ports = inject.map(DeviceInjectionConfig::ports).orElse("0");
int numPorts = Integer.parseInt(ports);
List<PortDescription> portDescs = new ArrayList<>(numPorts);
for (int i = 1; i <= numPorts; ++i) {
// TODO inject port details if something like BasicPortConfig was created
PortNumber number = portNumber(i);
boolean isEnabled = true;
portDescs.add(DefaultPortDescription.builder().withPortNumber(number).isEnabled(isEnabled).build());
}
providerService.updatePorts(did, portDescs);
}
}
use of org.onosproject.net.driver.DefaultDriverData in project onos by opennetworkinglab.
the class DriverManager method createHandler.
@Override
public DriverHandler createHandler(DeviceId deviceId, String... credentials) {
checkPermission(DRIVER_WRITE);
Driver driver = getDriver(deviceId);
return new DefaultDriverHandler(new DefaultDriverData(driver, deviceId));
}
use of org.onosproject.net.driver.DefaultDriverData in project onos by opennetworkinglab.
the class OfdpaPipelineTraceableTest method setUpOfdpa.
private PipelineTraceable setUpOfdpa() {
PipelineTraceable behaviour = new OfdpaPipelineTraceable();
DriverData driverData = new DefaultDriverData(ofdpaDriver, OFDPA_DEVICE);
behaviour.setData(driverData);
behaviour.setHandler(testDriverHandlerOfdpa);
behaviour.init();
return behaviour;
}
use of org.onosproject.net.driver.DefaultDriverData in project onos by opennetworkinglab.
the class FujitsuNetconfControllerMock method setUp.
/**
* Sets up initial test environment.
*
* @param listener listener to be added
* @return driver handler
* @throws NetconfException when there is a problem
*/
public FujitsuDriverHandlerAdapter setUp(FujitsuNetconfSessionListenerTest listener) throws NetconfException {
try {
NetconfDeviceInfo deviceInfo = new NetconfDeviceInfo(VOLT_DEVICE_USERNAME, VOLT_DEVICE_PASSWORD, IpAddress.valueOf(VOLT_DEVICE_IP), VOLT_DEVICE_PORT);
NetconfDevice netconfDevice = connectDevice(deviceInfo.getDeviceId());
FujitsuNetconfSessionMock session = (FujitsuNetconfSessionMock) netconfDevice.getSession();
session.setListener(listener);
DeviceId deviceId = deviceInfo.getDeviceId();
DefaultDriver driver = new DefaultDriver(VOLT_DRIVER_NAME, new ArrayList<>(), "Fujitsu", "1.0", "1.0", ImmutableMap.of(), ImmutableMap.of());
DefaultDriverData driverData = new DefaultDriverData(driver, deviceId);
FujitsuDriverHandlerAdapter driverHandler;
driverHandler = new FujitsuDriverHandlerAdapter(driverData);
driverHandler.setUp(this);
return driverHandler;
} catch (NetconfException e) {
throw new NetconfException("Cannot create a device ", e);
}
}
Aggregations