Search in sources :

Example 1 with Bands

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands in project openflowplugin by opendaylight.

the class MeterConvertorTest method testMeterModCommandConvertorNoValidBandData.

@Test
public void testMeterModCommandConvertorNoValidBandData() {
    // / DROP Band
    MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder();
    MeterBandTypesBuilder meterBandTypesB = new MeterBandTypesBuilder();
    MeterBandType bandFlag = new MeterBandType(true, false, false);
    // _ofpmbtDrop
    meterBandTypesB.setFlags(bandFlag);
    meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesB.build());
    final MeterBandHeader meterBH = meterBandHeaderBuilder.build();
    // DSCP Mark
    MeterBandTypesBuilder meterBandTypesB1 = new MeterBandTypesBuilder();
    MeterBandType bandFlag1 = new MeterBandType(false, true, false);
    meterBandTypesB1.setFlags(bandFlag1);
    DscpRemarkBuilder dscp = new DscpRemarkBuilder();
    dscp.setDscpRemarkBurstSize(11L);
    dscp.setDscpRemarkRate(21L);
    dscp.setPrecLevel((short) 1);
    DscpRemark dscpRemark = dscp.build();
    MeterBandHeaderBuilder meterBandHeaderBuilder1 = new MeterBandHeaderBuilder();
    meterBandHeaderBuilder1.setBandType(dscpRemark);
    meterBandHeaderBuilder1.setMeterBandTypes(meterBandTypesB1.build());
    final MeterBandHeader meterBH1 = meterBandHeaderBuilder1.build();
    // Experimental
    ExperimenterBuilder exp = new ExperimenterBuilder();
    exp.setExperimenterBurstSize(12L);
    exp.setExperimenterRate(22L);
    exp.setExperimenter(23L);
    Experimenter experimenter = exp.build();
    MeterBandHeaderBuilder meterBandHeaderBuilder2 = new MeterBandHeaderBuilder();
    meterBandHeaderBuilder2.setBandType(experimenter);
    MeterBandTypesBuilder meterBandTypesB2 = new MeterBandTypesBuilder();
    meterBandHeaderBuilder2.setMeterBandTypes(meterBandTypesB2.build());
    MeterBandHeader meterBH2 = meterBandHeaderBuilder2.build();
    List<MeterBandHeader> meterBandList = new ArrayList<>();
    meterBandList.add(0, meterBH);
    meterBandList.add(1, meterBH1);
    meterBandList.add(2, meterBH2);
    // Constructing List of Bands
    MeterBandHeadersBuilder meterBandHeadersBuilder = new MeterBandHeadersBuilder();
    meterBandHeadersBuilder.setMeterBandHeader(meterBandList);
    MeterBandHeaders meterBandHeaders = meterBandHeadersBuilder.build();
    AddMeterInputBuilder addMeterFromSAL = new AddMeterInputBuilder();
    // MeterBands
    addMeterFromSAL.setMeterBandHeaders(meterBandHeaders);
    // NodeKey key = new NodeKey(new NodeId("24"));
    // InstanceIdentifier<Node> path =
    // InstanceIdentifier.builder().node(Nodes.class).node(Node.class,
    // key).build();
    addMeterFromSAL.setMeterId(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId(10L));
    MeterFlags flagV = new MeterFlags(true, true, true, true);
    addMeterFromSAL.setFlags(flagV);
    AddMeterInput meterInputCommand = addMeterFromSAL.build();
    MeterModInputBuilder outMeterModInput = convert(meterInputCommand, new VersionConvertorData((short) 0X4));
    assertEquals(MeterModCommand.OFPMCADD, outMeterModInput.getCommand());
    assertTrue(outMeterModInput.getFlags().isOFPMFBURST());
    assertEquals(Long.valueOf(10L), outMeterModInput.getMeterId().getValue());
    // BandInformation starts here:
    List<Bands> bands = outMeterModInput.getBands();
    for (Bands currentBand : bands) {
        MeterBand meterBand = currentBand.getMeterBand();
        if (meterBand instanceof MeterBandDropCase) {
            assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType.OFPMBTDROP, ((MeterBandDropCase) meterBand).getMeterBandDrop().getType());
            assertEquals((long) 20, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getBurstSize());
            assertEquals((long) 10, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getRate());
        }
        if (meterBand instanceof MeterBandDscpRemarkCase) {
            assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType.OFPMBTDSCPREMARK, ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getType());
            assertEquals((long) 11, (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getBurstSize());
            assertEquals((long) 21, (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getRate());
            assertEquals((short) 1, (short) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getPrecLevel());
        }
        if (meterBand instanceof MeterBandExperimenterCase) {
            assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType.OFPMBTEXPERIMENTER, ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getType());
            assertEquals((long) 12, (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getBurstSize());
            assertEquals((long) 22, (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getRate());
            ExperimenterIdMeterBand expBand = ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getAugmentation(ExperimenterIdMeterBand.class);
            assertEquals((long) 23, (long) expBand.getExperimenter().getValue());
        }
    }
}
Also used : MeterBand(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.MeterBand) ExperimenterIdMeterBand(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMeterBand) DscpRemark(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemark) MeterModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder) ArrayList(java.util.ArrayList) MeterBandDscpRemarkCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase) AddMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterFlags) MeterBandHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader) DscpRemarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemarkBuilder) MeterBandType(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType) MeterBandTypesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder) Experimenter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Experimenter) MeterBandHeaderBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder) MeterBandHeaders(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeaders) MeterBandExperimenterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase) MeterBandDropCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) Bands(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands) MeterBandHeadersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder) ExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.ExperimenterBuilder) ExperimenterIdMeterBand(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMeterBand) AddMeterInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInputBuilder) Test(org.junit.Test)

Example 2 with Bands

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands in project openflowplugin by opendaylight.

the class MeterMessageDeserializer method deserialize.

@Override
public MeterMessage deserialize(ByteBuf message) {
    final MeterMessageBuilder builder = new MeterMessageBuilder().setVersion((short) EncodeConstants.OF13_VERSION_ID).setXid(message.readUnsignedInt()).setCommand(MeterModCommand.forValue(message.readUnsignedShort())).setFlags(readMeterFlags(message)).setMeterId(new MeterId(message.readUnsignedInt()));
    final List<MeterBandHeader> bands = new ArrayList<>();
    while (message.readableBytes() > 0) {
        final MeterBandHeaderBuilder bandBuilder = new MeterBandHeaderBuilder();
        final int bandStartIndex = message.readerIndex();
        final int bandType = message.readUnsignedShort();
        switch(bandType) {
            case OFPMBTDROP:
                {
                    bandBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(true, false, false)).build()).setBandType(new DropBuilder().setDropRate(message.readUnsignedInt()).setDropBurstSize(message.readUnsignedInt()).build());
                    message.skipBytes(PADDING_IN_METER_BAND_DROP_HEADER);
                    break;
                }
            case OFPMBTDSCP:
                {
                    bandBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(false, true, false)).build()).setBandType(new DscpRemarkBuilder().setDscpRemarkRate(message.readUnsignedInt()).setDscpRemarkBurstSize(message.readUnsignedInt()).setPrecLevel(message.readUnsignedByte()).build());
                    message.skipBytes(PADDING_IN_METER_BAND_DSCP_HEADER);
                    break;
                }
            case OFPMBTEXPERIMENTER:
                {
                    // TODO: Finish meter band experimenter deserialization
                    long expId = message.getUnsignedInt(message.readerIndex() + 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES);
                    message.readerIndex(bandStartIndex);
                    OFDeserializer<Experimenter> deserializer = registry.getDeserializer(new ExperimenterIdDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId, Experimenter.class));
                    bandBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(false, false, true)).build()).setBandType(deserializer.deserialize(message));
                    break;
                }
            default:
        }
        bands.add(bandBuilder.build());
    }
    return builder.setMeterBandHeaders(new MeterBandHeadersBuilder().setMeterBandHeader(bands).build()).build();
}
Also used : OFDeserializer(org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer) DscpRemarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemarkBuilder) MeterBandType(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType) MeterBandTypesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder) ArrayList(java.util.ArrayList) MeterBandHeaderBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder) DropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DropBuilder) ExperimenterIdDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) MeterBandHeadersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder) MeterMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterMessageBuilder) MeterBandHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader)

Example 3 with Bands

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands in project openflowplugin by opendaylight.

the class MeterConfigStatsResponseConvertor method convert.

@Override
public List<MeterConfigStats> convert(List<MeterConfig> source, VersionConvertorData data) {
    List<MeterConfigStats> listMeterConfigStats = new ArrayList<>();
    for (MeterConfig meterConfig : source) {
        MeterConfigStatsBuilder meterConfigStatsBuilder = new MeterConfigStatsBuilder();
        meterConfigStatsBuilder.setMeterId(new MeterId(meterConfig.getMeterId().getValue()));
        meterConfigStatsBuilder.setKey(new MeterConfigStatsKey(meterConfigStatsBuilder.getMeterId()));
        MeterBandHeadersBuilder meterBandHeadersBuilder = new MeterBandHeadersBuilder();
        List<Bands> bands = meterConfig.getBands();
        MeterFlags meterFlags = new MeterFlags(meterConfig.getFlags().isOFPMFBURST(), meterConfig.getFlags().isOFPMFKBPS(), meterConfig.getFlags().isOFPMFPKTPS(), meterConfig.getFlags().isOFPMFSTATS());
        meterConfigStatsBuilder.setFlags(meterFlags);
        List<MeterBandHeader> listBandHeaders = new ArrayList<>();
        int bandKey = 0;
        for (Bands band : bands) {
            MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder();
            if (band.getMeterBand() instanceof MeterBandDropCase) {
                MeterBandDropCase dropCaseBand = (MeterBandDropCase) band.getMeterBand();
                MeterBandDrop dropBand = dropCaseBand.getMeterBandDrop();
                DropBuilder dropBuilder = new DropBuilder();
                dropBuilder.setDropBurstSize(dropBand.getBurstSize());
                dropBuilder.setDropRate(dropBand.getRate());
                meterBandHeaderBuilder.setBandType(dropBuilder.build());
                meterBandHeaderBuilder.setBandBurstSize(dropBand.getBurstSize());
                meterBandHeaderBuilder.setBandRate(dropBand.getRate());
                BandId bandId = new BandId((long) bandKey);
                meterBandHeaderBuilder.setKey(new MeterBandHeaderKey(bandId));
                meterBandHeaderBuilder.setBandId(bandId);
                MeterBandTypesBuilder meterBandTypesBuilder = new MeterBandTypesBuilder();
                meterBandTypesBuilder.setFlags(new MeterBandType(true, false, false));
                meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesBuilder.build());
                listBandHeaders.add(meterBandHeaderBuilder.build());
            } else if (band.getMeterBand() instanceof MeterBandDscpRemarkCase) {
                MeterBandDscpRemarkCase dscpRemarkCaseBand = (MeterBandDscpRemarkCase) band.getMeterBand();
                MeterBandDscpRemark dscpRemarkBand = dscpRemarkCaseBand.getMeterBandDscpRemark();
                DscpRemarkBuilder dscpRemarkBuilder = new DscpRemarkBuilder();
                dscpRemarkBuilder.setDscpRemarkBurstSize(dscpRemarkBand.getBurstSize());
                dscpRemarkBuilder.setDscpRemarkRate(dscpRemarkBand.getRate());
                dscpRemarkBuilder.setPrecLevel(dscpRemarkBand.getPrecLevel());
                meterBandHeaderBuilder.setBandType(dscpRemarkBuilder.build());
                meterBandHeaderBuilder.setBandBurstSize(dscpRemarkBand.getBurstSize());
                meterBandHeaderBuilder.setBandRate(dscpRemarkBand.getRate());
                BandId bandId = new BandId((long) bandKey);
                meterBandHeaderBuilder.setKey(new MeterBandHeaderKey(bandId));
                meterBandHeaderBuilder.setBandId(bandId);
                MeterBandTypesBuilder meterBandTypesBuilder = new MeterBandTypesBuilder();
                meterBandTypesBuilder.setFlags(new MeterBandType(false, true, false));
                meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesBuilder.build());
                listBandHeaders.add(meterBandHeaderBuilder.build());
            } else if (band.getMeterBand() instanceof MeterBandExperimenterCase) {
                MeterBandExperimenterCase experimenterCaseBand = (MeterBandExperimenterCase) band.getMeterBand();
                MeterBandExperimenter experimenterBand = experimenterCaseBand.getMeterBandExperimenter();
                ExperimenterBuilder experimenterBuilder = new ExperimenterBuilder();
                experimenterBuilder.setExperimenterBurstSize(experimenterBand.getBurstSize());
                experimenterBuilder.setExperimenterRate(experimenterBand.getRate());
                meterBandHeaderBuilder.setBandType(experimenterBuilder.build());
                meterBandHeaderBuilder.setBandBurstSize(experimenterBand.getBurstSize());
                meterBandHeaderBuilder.setBandRate(experimenterBand.getRate());
                BandId bandId = new BandId((long) bandKey);
                meterBandHeaderBuilder.setKey(new MeterBandHeaderKey(bandId));
                meterBandHeaderBuilder.setBandId(bandId);
                MeterBandTypesBuilder meterBandTypesBuilder = new MeterBandTypesBuilder();
                meterBandTypesBuilder.setFlags(new MeterBandType(false, false, true));
                meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesBuilder.build());
                listBandHeaders.add(meterBandHeaderBuilder.build());
            }
            bandKey++;
        }
        meterBandHeadersBuilder.setMeterBandHeader(listBandHeaders);
        meterConfigStatsBuilder.setMeterBandHeaders(meterBandHeadersBuilder.build());
        listMeterConfigStats.add(meterConfigStatsBuilder.build());
    }
    return listMeterConfigStats;
}
Also used : ArrayList(java.util.ArrayList) MeterConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfig) MeterBandDscpRemarkCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterFlags) MeterBandHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader) MeterConfigStatsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStatsKey) MeterConfigStats(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats) MeterConfigStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStatsBuilder) DscpRemarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemarkBuilder) MeterBandExperimenter(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter) MeterBandType(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType) MeterBandTypesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder) MeterBandHeaderBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder) DropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DropBuilder) MeterBandHeaderKey(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderKey) MeterBandExperimenterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase) MeterBandDropCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase) Bands(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands) MeterBandHeadersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder) ExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.ExperimenterBuilder) MeterBandDrop(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDrop) BandId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId) MeterBandDscpRemark(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemark)

Example 4 with Bands

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands in project openflowplugin by opendaylight.

the class MeterConfigStatsResponseConvertorTest method createMeterConfigList.

private List<MeterConfig> createMeterConfigList() {
    List<MeterConfig> meterConfigs = new ArrayList<>();
    MeterConfigBuilder meterConfigBuilder = new MeterConfigBuilder();
    for (int i = 0; i < PRESET_COUNT; i++) {
        meterConfigBuilder.setMeterId(new MeterId((long) i));
        List<Bands> bandses = new ArrayList<>();
        BandsBuilder bandsBuilder = new BandsBuilder();
        bandsBuilder.setMeterBand(new MeterBandDropCaseBuilder().setMeterBandDrop(new MeterBandDropBuilder().build()).build());
        bandses.add(bandsBuilder.build());
        bandsBuilder = new BandsBuilder();
        bandsBuilder.setMeterBand(new MeterBandDscpRemarkCaseBuilder().setMeterBandDscpRemark(new MeterBandDscpRemarkBuilder().build()).build());
        bandses.add(bandsBuilder.build());
        bandsBuilder = new BandsBuilder();
        bandsBuilder.setMeterBand(new MockMeterBandBuilder());
        bandses.add(bandsBuilder.build());
        bandsBuilder = new BandsBuilder();
        bandsBuilder.setMeterBand(new MeterBandExperimenterCaseBuilder().setMeterBandExperimenter(new MeterBandExperimenterBuilder().build()).build());
        bandses.add(bandsBuilder.build());
        meterConfigBuilder.setBands(bandses);
        meterConfigBuilder.setFlags(new MeterFlags(true, false, true, false));
        meterConfigs.add(meterConfigBuilder.build());
    }
    return meterConfigs;
}
Also used : MeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfigBuilder) MeterBandDscpRemarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder) ArrayList(java.util.ArrayList) MeterBandDropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder) MeterBandExperimenterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCaseBuilder) MeterConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfig) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId) MeterBandDscpRemarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder) Bands(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands) MeterBandExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenterBuilder) MeterBandDropCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags) BandsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.BandsBuilder)

Example 5 with Bands

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactory method serializeMeterConfigBody.

private void serializeMeterConfigBody(final MultipartReplyBody body, final ByteBuf outBuffer) {
    MultipartReplyMeterConfigCase meterConfigCase = (MultipartReplyMeterConfigCase) body;
    MultipartReplyMeterConfig meter = meterConfigCase.getMultipartReplyMeterConfig();
    for (MeterConfig meterConfig : meter.getMeterConfig()) {
        ByteBuf meterConfigBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
        meterConfigBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
        writeMeterFlags(meterConfig.getFlags(), meterConfigBuff);
        meterConfigBuff.writeInt(meterConfig.getMeterId().getValue().intValue());
        for (Bands currentBand : meterConfig.getBands()) {
            MeterBand meterBand = currentBand.getMeterBand();
            if (meterBand instanceof MeterBandDropCase) {
                MeterBandDropCase dropBandCase = (MeterBandDropCase) meterBand;
                MeterBandDrop dropBand = dropBandCase.getMeterBandDrop();
                writeBandCommonFields(dropBand, meterConfigBuff);
            } else if (meterBand instanceof MeterBandDscpRemarkCase) {
                MeterBandDscpRemarkCase dscpRemarkBandCase = (MeterBandDscpRemarkCase) meterBand;
                MeterBandDscpRemark dscpRemarkBand = dscpRemarkBandCase.getMeterBandDscpRemark();
                writeBandCommonFields(dscpRemarkBand, meterConfigBuff);
            } else if (meterBand instanceof MeterBandExperimenterCase) {
                MeterBandExperimenterCase experimenterBandCase = (MeterBandExperimenterCase) meterBand;
                MeterBandExperimenter experimenterBand = experimenterBandCase.getMeterBandExperimenter();
                writeBandCommonFields(experimenterBand, meterConfigBuff);
            }
        }
        meterConfigBuff.setShort(METER_CONFIG_LENGTH_INDEX, meterConfigBuff.readableBytes());
        outBuffer.writeBytes(meterConfigBuff);
    }
}
Also used : MeterBand(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.MeterBand) Bands(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands) MeterBandExperimenter(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter) MeterBandDrop(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDrop) MultipartReplyMeterConfigCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase) MultipartReplyMeterConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig) MeterConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfig) ByteBuf(io.netty.buffer.ByteBuf) MeterBandDscpRemarkCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase) MeterBandDscpRemark(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemark) MeterBandExperimenterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase) MultipartReplyMeterConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig) MeterBandDropCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase)

Aggregations

ArrayList (java.util.ArrayList)14 MeterBandDropCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder)9 MeterBandDscpRemarkCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder)9 MeterBandDropBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder)9 MeterBandDscpRemarkBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder)9 Bands (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands)9 MeterBandExperimenterCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase)8 Test (org.junit.Test)7 MeterBandHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader)6 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId)6 MeterModInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder)6 MeterBand (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.MeterBand)6 MeterBandDropCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase)6 MeterBandDscpRemarkCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase)6 Bands (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands)6 MeterBandType (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType)5 DscpRemarkBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemarkBuilder)5 MeterBandHeadersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder)5 MeterBandHeaderBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder)5 MeterBandTypesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder)5