use of org.onosproject.net.driver.Driver 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.Driver in project onos by opennetworkinglab.
the class SoamManagerTest method testCreateDmNoBehavior.
@Test
public void testCreateDmNoBehavior() throws CfmConfigException, SoamConfigException {
final DeviceId deviceId3 = DeviceId.deviceId("netconf:3.2.3.4:830");
final MepId mepId3 = MepId.valueOf((short) 3);
Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours = new HashMap<>();
behaviours.put(DeviceDescriptionDiscovery.class, TestDeviceDiscoveryBehavior.class);
Driver testDriver3 = new DefaultDriver(TEST_DRIVER_3, new ArrayList<Driver>(), TEST_MFR, TEST_HW_VERSION, TEST_SW_3, behaviours, new HashMap<>());
Device device3 = new DefaultDevice(ProviderId.NONE, deviceId3, Device.Type.SWITCH, TEST_MFR, TEST_HW_VERSION, TEST_SW_3, TEST_SN, new ChassisId(2), DefaultAnnotations.builder().set(AnnotationKeys.DRIVER, TEST_DRIVER_3).build());
expect(deviceService.getDevice(deviceId3)).andReturn(device3).anyTimes();
replay(deviceService);
MepEntry mep3 = DefaultMepEntry.builder(mepId3, deviceId3, PortNumber.P0, Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).buildEntry();
expect(mepService.getMep(MDNAME1, MANAME1, mepId3)).andReturn(mep3).anyTimes();
replay(mepService);
expect(driverService.getDriver(deviceId3)).andReturn(testDriver3).anyTimes();
replay(driverService);
DelayMeasurementCreate dmCreate1 = DefaultDelayMeasurementCreate.builder(DelayMeasurementCreate.DmType.DM1DMTX, DelayMeasurementCreate.Version.Y17312011, MepId.valueOf((short) 11), Mep.Priority.PRIO3).binsPerFdInterval((short) 4).binsPerFdrInterval((short) 5).binsPerIfdvInterval((short) 6).build();
try {
soamManager.createDm(MDNAME1, MANAME1, mepId3, dmCreate1);
fail("Expecting exception since device does not support behavior");
} catch (CfmConfigException e) {
assertEquals("Device netconf:3.2.3.4:830 from MEP :md-1/" + "ma-1-1/3 does not implement SoamDmProgrammable", e.getMessage());
}
}
use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.
the class DriverManager method getDriver.
@Override
public Driver getDriver(DeviceId deviceId) {
checkPermission(DRIVER_READ);
Driver driver;
// Special processing for devices with pipeconf.
if (pipeconfService.ofDevice(deviceId).isPresent()) {
// Throws exception if pipeconf driver does not exist.
return nullIsNotFound(getPipeconfMergedDriver(deviceId), "Device is pipeconf-capable but a " + "pipeconf-merged driver was not found");
}
// Primary source of driver configuration is the network config.
BasicDeviceConfig cfg = networkConfigService.getConfig(deviceId, BasicDeviceConfig.class);
driver = lookupDriver(cfg != null ? cfg.driver() : null);
if (driver != null) {
return driver;
}
// Secondary source of the driver selection is driver annotation.
Device device = nullIsNotFound(deviceService.getDevice(deviceId), NO_DEVICE);
driver = lookupDriver(device.annotations().value(DRIVER));
if (driver != null) {
return driver;
}
// obtained from the device.
return nullIsNotFound(getDriver(device.manufacturer(), device.hwVersion(), device.swVersion()), NO_DRIVER);
}
use of org.onosproject.net.driver.Driver 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.Driver in project onos by opennetworkinglab.
the class DriverRegistryManager method getDriver.
@Override
public Driver getDriver(String mfr, String hw, String sw) {
checkPermission(DRIVER_READ);
// First attempt a literal search.
Driver driver = driverByKey.get(key(mfr, hw, sw));
if (driver != null) {
return driver;
}
// Otherwise, sweep through the key space and attempt to match using
// regular expression matching.
Optional<Driver> optional = driverByKey.values().stream().filter(d -> matches(d, mfr, hw, sw)).findFirst();
// If no matching driver is found, return default.
return optional.orElse(drivers.get(DEFAULT));
}
Aggregations