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;
}
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());
}
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());
}
Aggregations