use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method createMeterStats.
private static List<MeterStats> createMeterStats() {
MeterStatsBuilder builder = new MeterStatsBuilder();
builder.setMeterId(new MeterId(1L));
builder.setFlowCount(1L);
builder.setPacketInCount(BigInteger.valueOf(1L));
builder.setByteInCount(BigInteger.valueOf(1L));
builder.setDurationSec(1L);
builder.setDurationNsec(1L);
builder.setMeterBandStats(createMeterBandStats());
List<MeterStats> list = new ArrayList<>();
list.add(builder.build());
return list;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createMeterInstructions.
private static InstructionsBuilder createMeterInstructions() {
final MeterBuilder aab = new MeterBuilder();
aab.setMeterId(new MeterId(1L));
final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new MeterCaseBuilder().setMeter(aab.build()).build());
// Put our Instruction in a list of Instructions
final InstructionsBuilder isb = new InstructionsBuilder();
final List<Instruction> instructions = new ArrayList<>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId 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());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId 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());
}
}
}
Aggregations