Search in sources :

Example 11 with Bands

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands in project openflowplugin by opendaylight.

the class MeterModInputMessageFactoryTest method createBandsList.

private static List<Bands> createBandsList() {
    final List<Bands> bandsList = new ArrayList<>();
    final BandsBuilder bandsBuilder = new BandsBuilder();
    final MeterBandDropCaseBuilder dropCaseBuilder = new MeterBandDropCaseBuilder();
    MeterBandDropBuilder dropBand = new MeterBandDropBuilder();
    dropBand.setType(MeterBandType.OFPMBTDROP);
    dropBand.setRate(1L);
    dropBand.setBurstSize(2L);
    dropCaseBuilder.setMeterBandDrop(dropBand.build());
    bandsList.add(bandsBuilder.setMeterBand(dropCaseBuilder.build()).build());
    final MeterBandDscpRemarkCaseBuilder dscpCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
    MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder();
    dscpRemarkBand.setType(MeterBandType.OFPMBTDSCPREMARK);
    dscpRemarkBand.setRate(1L);
    dscpRemarkBand.setBurstSize(2L);
    dscpRemarkBand.setPrecLevel((short) 3);
    dscpCaseBuilder.setMeterBandDscpRemark(dscpRemarkBand.build());
    bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build());
    return bandsList;
}
Also used : 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.meter.mod.Bands) MeterBandDropCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder) 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) BandsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder)

Example 12 with Bands

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands in project openflowplugin by opendaylight.

the class MeterConvertor method convert.

@Override
public MeterModInputBuilder convert(Meter source, VersionConvertorData data) {
    MeterModInputBuilder meterModInputBuilder = new MeterModInputBuilder();
    List<Bands> bands = new ArrayList<>();
    if (source instanceof AddMeterInput) {
        meterModInputBuilder.setCommand(MeterModCommand.OFPMCADD);
    } else if (source instanceof RemoveMeterInput) {
        meterModInputBuilder.setCommand(MeterModCommand.OFPMCDELETE);
    } else if (source instanceof UpdatedMeter) {
        meterModInputBuilder.setCommand(MeterModCommand.OFPMCMODIFY);
    }
    meterModInputBuilder.setMeterId(new MeterId(source.getMeterId().getValue()));
    if (null != source.getFlags()) {
        meterModInputBuilder.setFlags(new MeterFlags(source.getFlags().isMeterBurst(), source.getFlags().isMeterKbps(), source.getFlags().isMeterPktps(), source.getFlags().isMeterStats()));
    } else {
        /*
             * As per 0F1.3.1,The rate field indicates the rate value above
             * which the corresponding band may apply to packets (see 5.7.1).
             * The rate value is in kilobit per seconds, unless the flags eld
             * includes OFPMF_PKTPS, in which case the rate is in packets per
             * seconds.
             */
        meterModInputBuilder.setFlags(new MeterFlags(false, false, true, false));
    }
    if (source.getMeterBandHeaders() != null) {
        getBandsFromSAL(source.getMeterBandHeaders(), bands);
        meterModInputBuilder.setBands(bands);
    } else {
        LOG.error("For this meter Id" + source.getMeterId().getValue() + ",no associated band data found!");
    }
    meterModInputBuilder.setVersion(data.getVersion());
    return meterModInputBuilder;
}
Also used : MeterModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder) Bands(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands) AddMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags) ArrayList(java.util.ArrayList) UpdatedMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeter) RemoveMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId)

Example 13 with Bands

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands in project openflowplugin by opendaylight.

the class MeterConvertorTest method testMeterModCommandConvertorwithNoFlags.

@Test
public void testMeterModCommandConvertorwithNoFlags() {
    long burstSize = 10L;
    long dropRate = 20L;
    // / DROP Band
    MeterBandTypesBuilder meterBandTypesB = new MeterBandTypesBuilder();
    MeterBandType bandFlag = new MeterBandType(true, false, false);
    // _ofpmbtDrop
    meterBandTypesB.setFlags(bandFlag);
    DropBuilder drop = new DropBuilder();
    drop.setDropBurstSize(burstSize);
    drop.setDropRate(dropRate);
    Drop drp = drop.build();
    MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder();
    meterBandHeaderBuilder.setBandType(drp);
    meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesB.build());
    final MeterBandHeader meterBH = meterBandHeaderBuilder.build();
    // DSCP Mark
    final long dscpRemarkBurstSize = 11L;
    final long dscpRemarkRate = 21L;
    final short dscpPercLevel = 1;
    MeterBandTypesBuilder meterBandTypesB1 = new MeterBandTypesBuilder();
    MeterBandType bandFlag1 = new MeterBandType(false, true, false);
    meterBandTypesB1.setFlags(bandFlag1);
    DscpRemarkBuilder dscp = new DscpRemarkBuilder();
    dscp.setDscpRemarkBurstSize(dscpRemarkBurstSize);
    dscp.setDscpRemarkRate(dscpRemarkRate);
    dscp.setPrecLevel(dscpPercLevel);
    DscpRemark dscpRemark = dscp.build();
    MeterBandHeaderBuilder meterBandHeaderBuilder1 = new MeterBandHeaderBuilder();
    meterBandHeaderBuilder1.setBandType(dscpRemark);
    meterBandHeaderBuilder1.setMeterBandTypes(meterBandTypesB1.build());
    final MeterBandHeader meterBH1 = meterBandHeaderBuilder1.build();
    // Experimental
    final long expBurstSize = 12L;
    final long expRate = 22L;
    final long expExperimenter = 23L;
    MeterBandTypesBuilder meterBandTypesB2 = new MeterBandTypesBuilder();
    MeterBandType bandFlag2 = new MeterBandType(false, false, true);
    meterBandTypesB2.setFlags(bandFlag2);
    ExperimenterBuilder exp = new ExperimenterBuilder();
    exp.setExperimenterBurstSize(expBurstSize);
    exp.setExperimenterRate(expRate);
    exp.setExperimenter(expExperimenter);
    Experimenter experimenter = exp.build();
    MeterBandHeaderBuilder meterBandHeaderBuilder2 = new MeterBandHeaderBuilder();
    meterBandHeaderBuilder2.setBandType(experimenter);
    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));
    AddMeterInput meterInputCommand = addMeterFromSAL.build();
    MeterModInputBuilder outMeterModInput = convert(meterInputCommand, new VersionConvertorData((short) 0X4));
    assertEquals(MeterModCommand.OFPMCADD, outMeterModInput.getCommand());
    assertFalse(outMeterModInput.getFlags().isOFPMFBURST());
    assertTrue(outMeterModInput.getFlags().isOFPMFPKTPS());
    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(burstSize, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getBurstSize());
            assertEquals(dropRate, (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(dscpRemarkBurstSize, (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getBurstSize());
            assertEquals(dscpRemarkRate, (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getRate());
            assertEquals(dscpPercLevel, (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(expBurstSize, (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getBurstSize());
            assertEquals(expRate, (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getRate());
            ExperimenterIdMeterBand expBand = ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getAugmentation(ExperimenterIdMeterBand.class);
            assertEquals(expExperimenter, (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) 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) DropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DropBuilder) 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) Drop(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop) 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 14 with Bands

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands in project openflowplugin by opendaylight.

the class MeterConvertorTest method testMeterModCommandConvertorwithAllParameters.

@Test
public void testMeterModCommandConvertorwithAllParameters() {
    long burstSize = 10L;
    long dropRate = 20L;
    // / DROP Band
    MeterBandTypesBuilder meterBandTypesB = new MeterBandTypesBuilder();
    MeterBandType bandFlag = new MeterBandType(true, false, false);
    // _ofpmbtDrop
    meterBandTypesB.setFlags(bandFlag);
    DropBuilder drop = new DropBuilder();
    drop.setDropBurstSize(burstSize);
    drop.setDropRate(dropRate);
    Drop drp = drop.build();
    MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder();
    meterBandHeaderBuilder.setBandType(drp);
    meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesB.build());
    final MeterBandHeader meterBH = meterBandHeaderBuilder.build();
    // DSCP Mark
    final long dscpRemarkBurstSize = 11L;
    final long dscpRemarkRate = 21L;
    final short dscpPercLevel = 1;
    MeterBandTypesBuilder meterBandTypesB1 = new MeterBandTypesBuilder();
    MeterBandType bandFlag1 = new MeterBandType(false, true, false);
    meterBandTypesB1.setFlags(bandFlag1);
    DscpRemarkBuilder dscp = new DscpRemarkBuilder();
    dscp.setDscpRemarkBurstSize(dscpRemarkBurstSize);
    dscp.setDscpRemarkRate(dscpRemarkRate);
    dscp.setPrecLevel(dscpPercLevel);
    DscpRemark dscpRemark = dscp.build();
    MeterBandHeaderBuilder meterBandHeaderBuilder1 = new MeterBandHeaderBuilder();
    meterBandHeaderBuilder1.setBandType(dscpRemark);
    meterBandHeaderBuilder1.setMeterBandTypes(meterBandTypesB1.build());
    final MeterBandHeader meterBH1 = meterBandHeaderBuilder1.build();
    // Experimental
    final long expBurstSize = 12L;
    final long expRate = 22L;
    final long expExperimenter = 23L;
    MeterBandTypesBuilder meterBandTypesB2 = new MeterBandTypesBuilder();
    MeterBandType bandFlag2 = new MeterBandType(false, false, true);
    meterBandTypesB2.setFlags(bandFlag2);
    ExperimenterBuilder exp = new ExperimenterBuilder();
    exp.setExperimenterBurstSize(expBurstSize);
    exp.setExperimenterRate(expRate);
    exp.setExperimenter(expExperimenter);
    Experimenter experimenter = exp.build();
    MeterBandHeaderBuilder meterBandHeaderBuilder2 = new MeterBandHeaderBuilder();
    meterBandHeaderBuilder2.setBandType(experimenter);
    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(burstSize, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getBurstSize());
            assertEquals(dropRate, (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(dscpRemarkBurstSize, (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getBurstSize());
            assertEquals(dscpRemarkRate, (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getRate());
            assertEquals(dscpPercLevel, (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(expBurstSize, (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getBurstSize());
            assertEquals(expRate, (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getRate());
            ExperimenterIdMeterBand expBand = ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getAugmentation(ExperimenterIdMeterBand.class);
            assertEquals(expExperimenter, (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) DropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DropBuilder) 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) Drop(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop) 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 15 with Bands

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactory method setMeterConfig.

private MultipartReplyMeterConfigCase setMeterConfig(final ByteBuf input) {
    MultipartReplyMeterConfigCaseBuilder caseBuilder = new MultipartReplyMeterConfigCaseBuilder();
    MultipartReplyMeterConfigBuilder builder = new MultipartReplyMeterConfigBuilder();
    List<MeterConfig> meterConfigList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        MeterConfigBuilder meterConfigBuilder = new MeterConfigBuilder();
        int meterConfigBodyLength = input.readUnsignedShort();
        meterConfigBuilder.setFlags(createMeterFlags(input.readUnsignedShort()));
        meterConfigBuilder.setMeterId(new MeterId(input.readUnsignedInt()));
        int actualLength = METER_CONFIG_LENGTH;
        List<Bands> bandsList = new ArrayList<>();
        while (actualLength < meterConfigBodyLength) {
            int bandStartIndex = input.readerIndex();
            BandsBuilder bandsBuilder = new BandsBuilder();
            int bandType = input.readUnsignedShort();
            switch(bandType) {
                case 1:
                    final MeterBandDropCaseBuilder bandDropCaseBuilder = new MeterBandDropCaseBuilder();
                    MeterBandDropBuilder bandDropBuilder = new MeterBandDropBuilder();
                    bandDropBuilder.setType(MeterBandType.forValue(bandType));
                    actualLength += input.readUnsignedShort();
                    bandDropBuilder.setRate(input.readUnsignedInt());
                    bandDropBuilder.setBurstSize(input.readUnsignedInt());
                    input.skipBytes(PADDING_IN_METER_BAND_DROP_HEADER);
                    bandDropCaseBuilder.setMeterBandDrop(bandDropBuilder.build());
                    bandsBuilder.setMeterBand(bandDropCaseBuilder.build());
                    break;
                case 2:
                    final MeterBandDscpRemarkCaseBuilder bandDscpRemarkCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
                    MeterBandDscpRemarkBuilder bandDscpRemarkBuilder = new MeterBandDscpRemarkBuilder();
                    bandDscpRemarkBuilder.setType(MeterBandType.forValue(bandType));
                    actualLength += input.readUnsignedShort();
                    bandDscpRemarkBuilder.setRate(input.readUnsignedInt());
                    bandDscpRemarkBuilder.setBurstSize(input.readUnsignedInt());
                    bandDscpRemarkBuilder.setPrecLevel(input.readUnsignedByte());
                    input.skipBytes(PADDING_IN_METER_BAND_DSCP_HEADER);
                    bandDscpRemarkCaseBuilder.setMeterBandDscpRemark(bandDscpRemarkBuilder.build());
                    bandsBuilder.setMeterBand(bandDscpRemarkCaseBuilder.build());
                    break;
                case 0xFFFF:
                    actualLength += input.readUnsignedShort();
                    final long expId = input.getUnsignedInt(input.readerIndex() + 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES);
                    input.readerIndex(bandStartIndex);
                    OFDeserializer<MeterBandExperimenterCase> deserializer = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId));
                    bandsBuilder.setMeterBand(deserializer.deserialize(input));
                    break;
                default:
                    break;
            }
            bandsList.add(bandsBuilder.build());
        }
        meterConfigBuilder.setBands(bandsList);
        meterConfigList.add(meterConfigBuilder.build());
    }
    builder.setMeterConfig(meterConfigList);
    caseBuilder.setMultipartReplyMeterConfig(builder.build());
    return caseBuilder.build();
}
Also used : MultipartReplyMeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfigBuilder) 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) MultipartReplyMeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfigBuilder) 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) 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) MeterBandExperimenterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase) 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) MeterBandDropCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder) MultipartReplyMeterConfigCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCaseBuilder) 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)

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