Search in sources :

Example 6 with Driver

use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.

the class PiPipeconfManager method buildMergedDriver.

private Driver buildMergedDriver(PiPipeconfId pipeconfId, String baseDriverName, String newDriverName) {
    final Driver baseDriver = getDriver(baseDriverName);
    if (baseDriver == null) {
        log.error("Base driver {} not found, cannot build a merged one", baseDriverName);
        return null;
    }
    final PiPipeconf pipeconf = pipeconfs.get(pipeconfId);
    if (pipeconf == null) {
        log.error("Pipeconf {} is not registered, cannot build a merged driver", pipeconfId);
        return null;
    }
    // extract the behaviours from the pipipeconf.
    final Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours = new HashMap<>();
    pipeconf.behaviours().forEach(b -> behaviours.put(b, pipeconf.implementation(b).get()));
    // general, we should give higher priority to pipeconf behaviours.
    if (baseDriver.hasBehaviour(PortStatisticsDiscovery.class) && behaviours.remove(PortStatisticsDiscovery.class) != null) {
        log.warn("Ignoring {} behaviour from pipeconf {}, but using " + "the one provided by {} driver...", PortStatisticsDiscovery.class.getSimpleName(), pipeconfId, baseDriver.name());
    }
    final Driver piPipeconfDriver = new DefaultDriver(newDriverName, baseDriver.parents(), baseDriver.manufacturer(), baseDriver.hwVersion(), baseDriver.swVersion(), behaviours, new HashMap<>());
    // merge it with the base driver that was assigned to the device
    return piPipeconfDriver.merge(baseDriver);
}
Also used : PortStatisticsDiscovery(org.onosproject.net.device.PortStatisticsDiscovery) Behaviour(org.onosproject.net.driver.Behaviour) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) PiPipeconf(org.onosproject.net.pi.model.PiPipeconf) DefaultDriver(org.onosproject.net.driver.DefaultDriver) DefaultDriver(org.onosproject.net.driver.DefaultDriver) Driver(org.onosproject.net.driver.Driver)

Example 7 with Driver

use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.

the class PiPipeconfManager method doMergeDriver.

private String doMergeDriver(String baseDriverName, PiPipeconfId pipeconfId) {
    final String newDriverName = mergedDriverName(baseDriverName, pipeconfId);
    // Serialize per newDriverName, avoid creating duplicates.
    locks.get(newDriverName).lock();
    try {
        // If merged driver exists already we don't create a new one.
        if (getDriver(newDriverName) != null) {
            return newDriverName;
        }
        log.debug("Creating merged driver {}...", newDriverName);
        final Driver mergedDriver = buildMergedDriver(pipeconfId, baseDriverName, newDriverName);
        if (mergedDriver == null) {
            // Error logged by buildMergedDriver
            return null;
        }
        registerMergedDriver(mergedDriver);
        if (missingMergedDrivers.remove(newDriverName)) {
            log.info("There are still {} missing merged drivers", missingMergedDrivers.size());
        }
        return newDriverName;
    } finally {
        locks.get(newDriverName).unlock();
    }
}
Also used : DefaultDriver(org.onosproject.net.driver.DefaultDriver) Driver(org.onosproject.net.driver.Driver) HexString(org.onlab.util.HexString)

Example 8 with Driver

use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.

the class ExtensionInstructionSerializer method write.

@Override
public void write(Kryo kryo, Output output, Instructions.ExtensionInstructionWrapper object) {
    kryo.writeClassAndObject(output, object.extensionInstruction().type());
    kryo.writeClassAndObject(output, object.deviceId());
    DriverService driverService = DefaultServiceDirectory.getService(DriverService.class);
    // It raises ItemNotFoundException if it failed to find driver
    Driver driver = driverService.getDriver(object.deviceId());
    kryo.writeClassAndObject(output, driver.name());
    kryo.writeClassAndObject(output, object.extensionInstruction().serialize());
}
Also used : Driver(org.onosproject.net.driver.Driver) DriverService(org.onosproject.net.driver.DriverService)

Example 9 with Driver

use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.

the class MockDriverHandler method init.

// Centralize some initialization.
private void init(Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours, DeviceId mockDeviceId, CoreService mockCoreService, DeviceService mockDeviceService) throws NetconfException {
    Map<String, String> properties = new HashMap<String, String>();
    Driver mockDriver = new DefaultDriver("mockDriver", null, "ONOSProject", "1.0.0", "1.0.0", behaviours, properties);
    mockDriverData = new DefaultDriverData(mockDriver, mockDeviceId);
    ncc = new MockNetconfController();
    ncc.connectDevice(mockDeviceId);
    coreService = mockCoreService;
    mastershipService = new MockMastershipService();
    deviceService = mockDeviceService;
}
Also used : HashMap(java.util.HashMap) DefaultDriver(org.onosproject.net.driver.DefaultDriver) DefaultDriver(org.onosproject.net.driver.DefaultDriver) Driver(org.onosproject.net.driver.Driver) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Example 10 with Driver

use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.

the class NetconfSessionMinaImpl method getClientCapabilites.

/**
 * Get the list of the netconf client capabilities from device driver property.
 *
 * @param deviceId the deviceID for which to recover the capabilities from the driver.
 * @return the String list of clientCapability property, or null if it is not configured
 */
public Set<String> getClientCapabilites(DeviceId deviceId) {
    Set<String> capabilities = new LinkedHashSet<>();
    DriverService driverService = directory.get(DriverService.class);
    try {
        Driver driver = driverService.getDriver(deviceId);
        if (driver == null) {
            return capabilities;
        }
        String clientCapabilities = driver.getProperty(NETCONF_CLIENT_CAPABILITY);
        if (clientCapabilities == null) {
            return capabilities;
        }
        String[] textStr = clientCapabilities.split("\\|");
        capabilities.addAll(Arrays.asList(textStr));
        return capabilities;
    } catch (ItemNotFoundException e) {
        log.warn("Driver for device {} currently not available", deviceId);
        return capabilities;
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Driver(org.onosproject.net.driver.Driver) DriverService(org.onosproject.net.driver.DriverService) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

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