Search in sources :

Example 1 with MeterSchema

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));
    }
}
Also used : MeterSchema(org.openkilda.model.of.MeterSchema) SwitchIncorrectMeterException(org.openkilda.floodlight.error.SwitchIncorrectMeterException) DatapathId(org.projectfloodlight.openflow.types.DatapathId)

Example 2 with MeterSchema

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;
}
Also used : MeterSchema(org.openkilda.model.of.MeterSchema) OFMeterConfigStatsReply(org.projectfloodlight.openflow.protocol.OFMeterConfigStatsReply) SwitchMissingMeterException(org.openkilda.floodlight.error.SwitchMissingMeterException) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig)

Example 3 with MeterSchema

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();
}
Also used : MeterSchema(org.openkilda.model.of.MeterSchema) SwitchId(org.openkilda.model.SwitchId) MeterId(org.openkilda.model.MeterId)

Example 4 with MeterSchema

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();
}
Also used : MeterSchema(org.openkilda.model.of.MeterSchema) SwitchId(org.openkilda.model.SwitchId) MeterId(org.openkilda.model.MeterId)

Example 5 with MeterSchema

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));
}
Also used : MeterSchema(org.openkilda.model.of.MeterSchema)

Aggregations

MeterSchema (org.openkilda.model.of.MeterSchema)5 MeterId (org.openkilda.model.MeterId)2 SwitchId (org.openkilda.model.SwitchId)2 SwitchIncorrectMeterException (org.openkilda.floodlight.error.SwitchIncorrectMeterException)1 SwitchMissingMeterException (org.openkilda.floodlight.error.SwitchMissingMeterException)1 OFMeterConfig (org.projectfloodlight.openflow.protocol.OFMeterConfig)1 OFMeterConfigStatsReply (org.projectfloodlight.openflow.protocol.OFMeterConfigStatsReply)1 DatapathId (org.projectfloodlight.openflow.types.DatapathId)1