use of org.openkilda.model.of.MeterSchema in project open-kilda by telstra.
the class MeterVerifyCommand method validateMeterConfig.
private void validateMeterConfig(MeterSchema actualSchema, boolean isInaccurate) {
DatapathId datapathId = getSw().getId();
MeterSchema expectedSchema = MeterSchemaMapper.INSTANCE.map(datapathId, makeMeterAddMessage());
if (!expectedSchema.equals(actualSchema)) {
throw maskCallbackException(new SwitchIncorrectMeterException(datapathId, meterConfig, expectedSchema, actualSchema, isInaccurate));
}
}
use of org.openkilda.model.of.MeterSchema in project open-kilda by telstra.
the class MeterVerifyCommand method handleMeterStats.
private MeterSchema handleMeterStats(List<OFMeterConfigStatsReply> meterStatResponses) {
Optional<OFMeterConfig> target = Optional.empty();
for (OFMeterConfigStatsReply meterConfigReply : meterStatResponses) {
target = findMeter(meterConfigReply);
if (target.isPresent()) {
break;
}
}
if (!target.isPresent()) {
throw maskCallbackException(new SwitchMissingMeterException(getSw().getId(), meterConfig.getId()));
}
boolean isInaccurate = getSwitchFeatures().contains(SwitchFeature.INACCURATE_METER);
MeterSchema schema = MeterSchemaMapper.INSTANCE.map(getSw().getId(), target.get(), isInaccurate);
validateMeterConfig(schema, isInaccurate);
return schema;
}
use of org.openkilda.model.of.MeterSchema in project open-kilda by telstra.
the class MeterSchemaMapper method map.
/**
* Produce {@code MeterSchema} from {@code OFMeterConfig}.
*/
public MeterSchema map(DatapathId datapathId, OFMeterConfig meterConfig, boolean isInaccurate) {
MeterSchema.MeterSchemaBuilder schema = MeterSchema.builder().switchId(new SwitchId(datapathId.getLong())).meterId(new MeterId(meterConfig.getMeterId()));
fillFlags(schema, meterConfig.getFlags());
fillBands(schema, meterConfig.getEntries(), isInaccurate);
return schema.build();
}
use of org.openkilda.model.of.MeterSchema in project open-kilda by telstra.
the class MeterSchemaMapper method map.
/**
* Produce {@code MeterSchema} from {@code OFMeterMod}.
*/
public MeterSchema map(DatapathId datapathId, OFMeterMod meterMod) {
MeterSchema.MeterSchemaBuilder schema = MeterSchema.builder().switchId(new SwitchId(datapathId.getLong())).meterId(new MeterId(meterMod.getMeterId()));
fillFlags(schema, meterMod.getFlags());
fillBands(schema, OfAdapter.INSTANCE.getMeterBands(meterMod));
return schema.build();
}
use of org.openkilda.model.of.MeterSchema in project open-kilda by telstra.
the class MeterInstallCommandTest method expectVerifyMeter.
private void expectVerifyMeter() {
MeterSchema schema = MeterSchema.builder().switchId(mapSwitchId(dpId)).meterId(meterConfig.getId()).build();
expectVerifyMeter(new MeterVerifyReport(command, schema));
}
Aggregations