Search in sources :

Example 1 with Driver

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;
}
Also used : DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) DriverHandler(org.onosproject.net.driver.DriverHandler) Driver(org.onosproject.net.driver.Driver) ExtensionTreatmentResolver(org.onosproject.net.behaviour.ExtensionTreatmentResolver) ExtensionTreatment(org.onosproject.net.flow.instructions.ExtensionTreatment) ExtensionPropertyException(org.onosproject.net.flow.instructions.ExtensionPropertyException) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Example 2 with Driver

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());
    }
}
Also used : ChassisId(org.onlab.packet.ChassisId) Behaviour(org.onosproject.net.driver.Behaviour) HashMap(java.util.HashMap) DeviceId(org.onosproject.net.DeviceId) DefaultDevice(org.onosproject.net.DefaultDevice) Device(org.onosproject.net.Device) DefaultDevice(org.onosproject.net.DefaultDevice) Driver(org.onosproject.net.driver.Driver) DefaultDriver(org.onosproject.net.driver.DefaultDriver) MepEntry(org.onosproject.incubator.net.l2monitoring.cfm.MepEntry) DefaultMepEntry(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMepEntry) DefaultDriver(org.onosproject.net.driver.DefaultDriver) DelayMeasurementCreate(org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate) DefaultDelayMeasurementCreate(org.onosproject.incubator.net.l2monitoring.soam.delay.DefaultDelayMeasurementCreate) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) MepId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId) Test(org.junit.Test)

Example 3 with Driver

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);
}
Also used : Device(org.onosproject.net.Device) Driver(org.onosproject.net.driver.Driver) BasicDeviceConfig(org.onosproject.net.config.basics.BasicDeviceConfig)

Example 4 with 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));
}
Also used : DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) Driver(org.onosproject.net.driver.Driver) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Example 5 with Driver

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));
}
Also used : ListenerRegistry(org.onosproject.event.ListenerRegistry) DeviceService(org.onosproject.net.device.DeviceService) ComponentContext(org.osgi.service.component.ComponentContext) LoggerFactory(org.slf4j.LoggerFactory) AppGuard.checkPermission(org.onosproject.security.AppGuard.checkPermission) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) DriverEvent(org.onosproject.net.driver.DriverEvent) ComponentService(org.onosproject.component.ComponentService) Component(org.osgi.service.component.annotations.Component) Behaviour(org.onosproject.net.driver.Behaviour) DriverRegistry(org.onosproject.net.driver.DriverRegistry) Map(java.util.Map) DriverProvider(org.onosproject.net.driver.DriverProvider) Activate(org.osgi.service.component.annotations.Activate) Driver(org.onosproject.net.driver.Driver) DefaultDriverProvider(org.onosproject.net.driver.DefaultDriverProvider) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) DriverListener(org.onosproject.net.driver.DriverListener) Tools.get(org.onlab.util.Tools.get) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) Properties(java.util.Properties) Tools.nullIsNotFound(org.onlab.util.Tools.nullIsNotFound) DRIVER_REDUCED(org.onosproject.net.driver.DriverEvent.Type.DRIVER_REDUCED) Deactivate(org.osgi.service.component.annotations.Deactivate) EventDeliveryService(org.onosproject.event.EventDeliveryService) Set(java.util.Set) REQUIRED_DRIVERS_DEFAULT(org.onosproject.net.driver.impl.OsgiPropertyConstants.REQUIRED_DRIVERS_DEFAULT) DRIVER_READ(org.onosproject.security.AppPermission.Type.DRIVER_READ) REQUIRED_DRIVERS(org.onosproject.net.driver.impl.OsgiPropertyConstants.REQUIRED_DRIVERS) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) DRIVER_ENHANCED(org.onosproject.net.driver.DriverEvent.Type.DRIVER_ENHANCED) DriverAdminService(org.onosproject.net.driver.DriverAdminService) Modified(org.osgi.service.component.annotations.Modified) Optional(java.util.Optional) Reference(org.osgi.service.component.annotations.Reference) Dictionary(java.util.Dictionary) Driver(org.onosproject.net.driver.Driver)

Aggregations

Driver (org.onosproject.net.driver.Driver)32 DefaultDriverHandler (org.onosproject.net.driver.DefaultDriverHandler)15 DefaultDriverData (org.onosproject.net.driver.DefaultDriverData)14 DriverHandler (org.onosproject.net.driver.DriverHandler)8 DeviceId (org.onosproject.net.DeviceId)6 Device (org.onosproject.net.Device)5 Behaviour (org.onosproject.net.driver.Behaviour)5 DefaultDriver (org.onosproject.net.driver.DefaultDriver)5 HashMap (java.util.HashMap)4 ChassisId (org.onlab.packet.ChassisId)4 ItemNotFoundException (org.onlab.util.ItemNotFoundException)4 Test (org.junit.Test)3 BasicDeviceConfig (org.onosproject.net.config.basics.BasicDeviceConfig)3 DeviceDescriptionDiscovery (org.onosproject.net.device.DeviceDescriptionDiscovery)3 DriverService (org.onosproject.net.driver.DriverService)3 MepId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)2 CfmConfigException (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)2 DefaultDevice (org.onosproject.net.DefaultDevice)2 DevicesDiscovery (org.onosproject.net.behaviour.DevicesDiscovery)2 DefaultDeviceDescription (org.onosproject.net.device.DefaultDeviceDescription)2