Search in sources :

Example 1 with PiTranslatedEntity

use of org.onosproject.net.pi.service.PiTranslatedEntity in project onos by opennetworkinglab.

the class P4RuntimeMeterProgrammable method forgeMeter.

private Meter forgeMeter(PiMeterCellConfig config, PiMeterCellHandle handle) {
    final Optional<PiTranslatedEntity<Meter, PiMeterCellConfig>> translatedEntity = translator.lookup(handle);
    final TimedEntry<PiMeterCellConfig> timedEntry = meterMirror.get(handle);
    // is default configuration.
    if (translatedEntity.isEmpty()) {
        if (!config.isDefaultConfig()) {
            log.warn("Meter Cell Config obtained from device {} is different from " + "one in in translation store: device={}, store=Default", deviceId, config);
        } else {
            log.debug("Configs for {} obtained from device: {} and from the store are default, " + "skipping the forge section", config.cellId(), deviceId);
        }
        return null;
    }
    // that config from devices can be default which means no band
    if (!isSimilar(translatedEntity.get().translated(), config)) {
        log.warn("Meter Cell Config obtained from device {} is different from " + "one in in translation store: device={}, store={}", deviceId, config, translatedEntity.get().translated());
        return null;
    }
    // the eventual consistent maps used in the AbstractDistributedP4RuntimeMirror
    if (timedEntry == null) {
        log.warn("Meter entry handle not found in device mirror: {}", handle);
        return null;
    }
    Meter original = translatedEntity.get().original();
    // Forge a meter with MeterCellId, Bands and DeviceId using the original value.
    DefaultMeter meter = (DefaultMeter) DefaultMeter.builder().withBands(original.bands()).withCellId(original.meterCellId()).forDevice(deviceId).build();
    meter.setState(MeterState.ADDED);
    return meter;
}
Also used : PiTranslatedEntity(org.onosproject.net.pi.service.PiTranslatedEntity) DefaultMeter(org.onosproject.net.meter.DefaultMeter) Meter(org.onosproject.net.meter.Meter) PiMeterCellConfig(org.onosproject.net.pi.runtime.PiMeterCellConfig) DefaultMeter(org.onosproject.net.meter.DefaultMeter)

Example 2 with PiTranslatedEntity

use of org.onosproject.net.pi.service.PiTranslatedEntity in project onos by opennetworkinglab.

the class P4RuntimeActionGroupProgrammable method checkAndForgeGroupEntry.

private Group checkAndForgeGroupEntry(PiActionProfileGroup piGroupOnDevice, Map<PiActionProfileMemberHandle, PiActionProfileMember> membersOnDevice) {
    final PiActionProfileGroupHandle handle = PiActionProfileGroupHandle.of(deviceId, piGroupOnDevice);
    final Optional<PiTranslatedEntity<Group, PiActionProfileGroup>> translatedEntity = groupTranslator.lookup(handle);
    final TimedEntry<PiActionProfileGroup> mirrorEntry = groupMirror.get(handle);
    // by the translation store.
    if (!translatedEntity.isPresent()) {
        log.warn("Group not found in translation store: {}", handle);
        return null;
    }
    final PiActionProfileGroup piGroupFromStore = translatedEntity.get().translated();
    if (!piGroupFromStore.equals(piGroupOnDevice)) {
        log.warn("Group on device {} is different from the one in " + "translation store: {} [device={}, store={}]", deviceId, handle, piGroupOnDevice, piGroupFromStore);
        return null;
    }
    // found on the device.
    if (!validateGroupMembers(piGroupFromStore, membersOnDevice)) {
        log.warn("Group on device {} refers to members that are different " + "than those found in translation store: {}", deviceId, handle);
        return null;
    }
    if (mirrorEntry == null) {
        log.warn("Group handle not found in device mirror: {}", handle);
        return null;
    }
    // Check that members from device are the same as in the translated group.
    return addedGroup(translatedEntity.get().original(), mirrorEntry.lifeSec());
}
Also used : PiTranslatedEntity(org.onosproject.net.pi.service.PiTranslatedEntity) PiActionProfileGroupHandle(org.onosproject.net.pi.runtime.PiActionProfileGroupHandle) PiActionProfileGroup(org.onosproject.net.pi.runtime.PiActionProfileGroup)

Example 3 with PiTranslatedEntity

use of org.onosproject.net.pi.service.PiTranslatedEntity in project onos by opennetworkinglab.

the class P4RuntimeReplicationGroupProgrammable method forgeGroupEntry.

private Group forgeGroupEntry(PiPreEntry preEntry) {
    final PiPreEntryHandle handle = (PiPreEntryHandle) preEntry.handle(deviceId);
    final Optional<PiTranslatedEntity<Group, PiPreEntry>> translatedEntity = translator.lookup(handle);
    final TimedEntry<PiPreEntry> timedEntry = mirror.get(handle);
    // Is entry consistent with our state?
    if (!translatedEntity.isPresent()) {
        log.warn("PRE entry handle not found in translation store: {}", handle);
        return null;
    }
    if (timedEntry == null) {
        log.warn("PRE entry handle not found in device mirror: {}", handle);
        return null;
    }
    return addedGroup(translatedEntity.get().original(), timedEntry.lifeSec());
}
Also used : PiTranslatedEntity(org.onosproject.net.pi.service.PiTranslatedEntity) PiPreEntryHandle(org.onosproject.net.pi.runtime.PiPreEntryHandle) PiPreEntry(org.onosproject.net.pi.runtime.PiPreEntry)

Aggregations

PiTranslatedEntity (org.onosproject.net.pi.service.PiTranslatedEntity)3 DefaultMeter (org.onosproject.net.meter.DefaultMeter)1 Meter (org.onosproject.net.meter.Meter)1 PiActionProfileGroup (org.onosproject.net.pi.runtime.PiActionProfileGroup)1 PiActionProfileGroupHandle (org.onosproject.net.pi.runtime.PiActionProfileGroupHandle)1 PiMeterCellConfig (org.onosproject.net.pi.runtime.PiMeterCellConfig)1 PiPreEntry (org.onosproject.net.pi.runtime.PiPreEntry)1 PiPreEntryHandle (org.onosproject.net.pi.runtime.PiPreEntryHandle)1