Search in sources :

Example 6 with PiPipeconfId

use of org.onosproject.net.pi.model.PiPipeconfId in project onos by opennetworkinglab.

the class PiPipeconfManagerTest method mergeDriver.

@Test
public void mergeDriver() {
    PiPipeconfId piPipeconfId = new PiPipeconfId(cfgService.getConfig(DEVICE_ID, BasicDeviceConfig.class).pipeconf());
    assertEquals(pipeconf.id(), piPipeconfId);
    String baseDriverName = cfgService.getConfig(DEVICE_ID, BasicDeviceConfig.class).driver();
    assertEquals(BASE_DRIVER, baseDriverName);
    mgr.register(pipeconf);
    assertEquals("Returned PiPipeconf is not correct", pipeconf, mgr.getPipeconf(pipeconf.id()).get());
    String mergedDriverName = mgr.getMergedDriver(DEVICE_ID, piPipeconfId);
    String expectedName = BASE_DRIVER + ":" + piPipeconfId.id();
    assertEquals(expectedName, mergedDriverName);
    // we assume that the provider is 1 and that it contains 1 driver
    // we also assume that everything after driverAdminService.registerProvider(provider); has been tested.
    assertEquals("Provider should be registered", 1, providers.size());
    assertTrue("Merged driver name should be valid", mergedDriverName != null && !mergedDriverName.isEmpty());
    DriverProvider provider = providers.iterator().next();
    assertEquals("Provider should contain one driver", 1, provider.getDrivers().size());
    Driver driver = provider.getDrivers().iterator().next();
    Set<Class<? extends Behaviour>> expectedBehaviours = Sets.newHashSet();
    expectedBehaviours.addAll(BASIC_PIPECONF.behaviours());
    expectedBehaviours.addAll(baseDriver.behaviours());
    // FIXME: remove when stratum_bmv2 will be open source
    // (see PiPipeconfManager)
    // expectedBehaviours.remove(PortStatisticsDiscovery.class);
    assertEquals("The driver contains wrong behaviours", expectedBehaviours, driver.behaviours());
}
Also used : DriverProvider(org.onosproject.net.driver.DriverProvider) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) Behaviour(org.onosproject.net.driver.Behaviour) PiPipeconfId(org.onosproject.net.pi.model.PiPipeconfId) Driver(org.onosproject.net.driver.Driver) BasicDeviceConfig(org.onosproject.net.config.basics.BasicDeviceConfig) Test(org.junit.Test)

Example 7 with PiPipeconfId

use of org.onosproject.net.pi.model.PiPipeconfId in project onos by opennetworkinglab.

the class PiPipeconfManager method checkMissingMergedDriver.

private void checkMissingMergedDriver(DeviceId deviceId) {
    final PiPipeconfId pipeconfId = pipeconfMappingStore.getPipeconfId(deviceId);
    final BasicDeviceConfig cfg = cfgService.getConfig(deviceId, BasicDeviceConfig.class);
    if (pipeconfId == null) {
        // No pipeconf associated.
        return;
    }
    if (cfg == null || cfg.driver() == null) {
        log.warn("Missing basic device config or driver key in netcfg for " + "{}, which is odd since it has a " + "pipeconf associated ({})", deviceId, pipeconfId);
        return;
    }
    final String baseDriverName = cfg.driver();
    final String mergedDriverName = mergedDriverName(baseDriverName, pipeconfId);
    if (driverExists(mergedDriverName) || missingMergedDrivers.contains(mergedDriverName)) {
        // Not missing, or already aware of it missing.
        return;
    }
    log.info("Detected missing merged driver: {}", mergedDriverName);
    missingMergedDrivers.add(mergedDriverName);
    // Attempt building the driver now if all pieces are present.
    // If not, either a driver or pipeconf event will re-trigger
    // the process.
    attemptDriverMerge(mergedDriverName);
}
Also used : PiPipeconfId(org.onosproject.net.pi.model.PiPipeconfId) HexString(org.onlab.util.HexString) BasicDeviceConfig(org.onosproject.net.config.basics.BasicDeviceConfig)

Example 8 with PiPipeconfId

use of org.onosproject.net.pi.model.PiPipeconfId in project onos by opennetworkinglab.

the class PiPipeconfManager method bindToDevice.

@Override
public void bindToDevice(PiPipeconfId pipeconfId, DeviceId deviceId) {
    PiPipeconfId existingPipeconfId = pipeconfMappingStore.getPipeconfId(deviceId);
    if (existingPipeconfId != null && !existingPipeconfId.equals(pipeconfId)) {
        log.error("Cannot set binding for {} to {} as one already exists ({})", deviceId, pipeconfId, existingPipeconfId);
        return;
    }
    pipeconfMappingStore.createOrUpdateBinding(deviceId, pipeconfId);
}
Also used : PiPipeconfId(org.onosproject.net.pi.model.PiPipeconfId)

Example 9 with PiPipeconfId

use of org.onosproject.net.pi.model.PiPipeconfId in project onos by opennetworkinglab.

the class PiPipeconfManager method attemptDriverMerge.

private void attemptDriverMerge(String mergedDriverName) {
    final String baseDriverName = getBaseDriverNameFromMerged(mergedDriverName);
    final PiPipeconfId pipeconfId = getPipeconfIdFromMerged(mergedDriverName);
    if (driverExists(baseDriverName) && pipeconfs.containsKey(pipeconfId)) {
        doMergeDriver(baseDriverName, pipeconfId);
    }
}
Also used : PiPipeconfId(org.onosproject.net.pi.model.PiPipeconfId) HexString(org.onlab.util.HexString)

Aggregations

PiPipeconfId (org.onosproject.net.pi.model.PiPipeconfId)9 HexString (org.onlab.util.HexString)2 BasicDeviceConfig (org.onosproject.net.config.basics.BasicDeviceConfig)2 PiPipeconf (org.onosproject.net.pi.model.PiPipeconf)2 Test (org.junit.Test)1 ItemNotFoundException (org.onlab.util.ItemNotFoundException)1 PiPipelineProgrammable (org.onosproject.net.behaviour.PiPipelineProgrammable)1 DeviceHandshaker (org.onosproject.net.device.DeviceHandshaker)1 AbstractHandlerBehaviour (org.onosproject.net.driver.AbstractHandlerBehaviour)1 Behaviour (org.onosproject.net.driver.Behaviour)1 Driver (org.onosproject.net.driver.Driver)1 DriverProvider (org.onosproject.net.driver.DriverProvider)1 DeviceTaskException (org.onosproject.provider.general.device.impl.DeviceTaskExecutor.DeviceTaskException)1