Search in sources :

Example 1 with OFMeterBand

use of org.projectfloodlight.openflow.protocol.meterband.OFMeterBand in project open-kilda by telstra.

the class AbstractMeterInstall method makeMeterMessage.

protected OFMeterMod makeMeterMessage(OFMeterModCommand commandType) {
    final OFFactory ofFactory = getSw().getOFFactory();
    OFMeterMod.Builder meterModBuilder = ofFactory.buildMeterMod().setMeterId(meterConfig.getId().getValue()).setCommand(commandType).setFlags(makeMeterFlags());
    // NB: some switches might replace 0 burst size value with some predefined value
    List<OFMeterBand> meterBand = makeMeterBands();
    if (ofFactory.getVersion().compareTo(OF_13) > 0) {
        meterModBuilder.setBands(meterBand);
    } else {
        meterModBuilder.setMeters(meterBand);
    }
    return meterModBuilder.build();
}
Also used : OFMeterBand(org.projectfloodlight.openflow.protocol.meterband.OFMeterBand) OFMeterMod(org.projectfloodlight.openflow.protocol.OFMeterMod) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory)

Example 2 with OFMeterBand

use of org.projectfloodlight.openflow.protocol.meterband.OFMeterBand in project open-kilda by telstra.

the class OfMeterConverter method convertToMeterSpeakerData.

/**
 * Convert meter config.
 */
public MeterSpeakerData convertToMeterSpeakerData(OFMeterConfig meterConfig, boolean inaccurate) {
    MeterId meterId = new MeterId(meterConfig.getMeterId());
    long rate = 0;
    long burst = 0;
    for (OFMeterBand band : meterConfig.getEntries()) {
        if (band instanceof OFMeterBandDrop) {
            rate = ((OFMeterBandDrop) band).getRate();
            burst = ((OFMeterBandDrop) band).getBurstSize();
        }
    }
    return MeterSpeakerData.builder().meterId(meterId).burst(burst).rate(rate).flags(fromOfMeterFlags(meterConfig.getFlags())).inaccurate(inaccurate).build();
}
Also used : OFMeterBand(org.projectfloodlight.openflow.protocol.meterband.OFMeterBand) OFMeterBandDrop(org.projectfloodlight.openflow.protocol.meterband.OFMeterBandDrop) MeterId(org.openkilda.model.MeterId)

Example 3 with OFMeterBand

use of org.projectfloodlight.openflow.protocol.meterband.OFMeterBand in project open-kilda by telstra.

the class MeterSchemaMapper method fillBands.

private void fillBands(MeterSchema.MeterSchemaBuilder schema, List<OFMeterBand> bandsSequence, boolean isInaccurate) {
    for (OFMeterBand rawBand : bandsSequence) {
        MeterSchemaBand.MeterSchemaBandBuilder band = MeterSchemaBand.builder().type(rawBand.getType()).inaccurate(isInaccurate);
        if (rawBand instanceof OFMeterBandDrop) {
            OFMeterBandDrop actualBand = (OFMeterBandDrop) rawBand;
            band.rate(actualBand.getRate());
            band.burstSize(actualBand.getBurstSize());
        }
        // do not make detailed parsing of other meter's band types
        schema.band(band.build());
    }
}
Also used : OFMeterBand(org.projectfloodlight.openflow.protocol.meterband.OFMeterBand) MeterSchemaBand(org.openkilda.model.of.MeterSchemaBand) OFMeterBandDrop(org.projectfloodlight.openflow.protocol.meterband.OFMeterBandDrop)

Aggregations

OFMeterBand (org.projectfloodlight.openflow.protocol.meterband.OFMeterBand)3 OFMeterBandDrop (org.projectfloodlight.openflow.protocol.meterband.OFMeterBandDrop)2 MeterId (org.openkilda.model.MeterId)1 MeterSchemaBand (org.openkilda.model.of.MeterSchemaBand)1 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)1 OFMeterMod (org.projectfloodlight.openflow.protocol.OFMeterMod)1