use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId in project openflowplugin by opendaylight.
the class MeterConvertorTest method testMeterModCommandConvertorBandDataisNULL.
@Test
public void testMeterModCommandConvertorBandDataisNULL() {
AddMeterInputBuilder addMeterFromSAL = new AddMeterInputBuilder();
// 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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId in project openflowplugin by opendaylight.
the class MeterCase method process.
@Override
public Optional<Instruction> process(@Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
Meter meter = source.getMeter();
MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
MeterBuilder meterBuilder = new MeterBuilder();
Long meterId = meter.getMeterId().getValue();
meterBuilder.setMeterId(meterId);
meterCaseBuilder.setMeter(meterBuilder.build());
InstructionBuilder instructionBuilder = new InstructionBuilder();
instructionBuilder.setInstructionChoice(meterCaseBuilder.build());
return Optional.of(instructionBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId in project openflowplugin by opendaylight.
the class MeterListenerTest method updateMeterTest.
@Test
public void updateMeterTest() throws Exception {
addFlowCapableNode(NODE_KEY);
MeterKey meterKey = new MeterKey(new MeterId((long) 2000));
InstanceIdentifier<Meter> meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Meter.class, meterKey);
Meter meter = new MeterBuilder().setKey(meterKey).setMeterName("meter_one").setBarrier(false).build();
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
assertCommit(writeTx.submit());
SalMeterServiceMock salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
List<AddMeterInput> addMeterCalls = salMeterService.getAddMeterCalls();
assertEquals(1, addMeterCalls.size());
assertEquals("DOM-0", addMeterCalls.get(0).getTransactionUri().getValue());
meter = new MeterBuilder().setKey(meterKey).setMeterName("meter_two").setBarrier(true).build();
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
assertCommit(writeTx.submit());
salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
List<UpdateMeterInput> updateMeterCalls = salMeterService.getUpdateMeterCalls();
assertEquals(1, updateMeterCalls.size());
assertEquals("DOM-1", updateMeterCalls.get(0).getTransactionUri().getValue());
assertEquals(meterII, updateMeterCalls.get(0).getMeterRef().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId in project openflowplugin by opendaylight.
the class MeterListenerTest method addTwoMetersTest.
@Test
public void addTwoMetersTest() throws Exception {
addFlowCapableNode(NODE_KEY);
MeterKey meterKey = new MeterKey(new MeterId((long) 2000));
InstanceIdentifier<Meter> meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Meter.class, meterKey);
Meter meter = new MeterBuilder().setKey(meterKey).setMeterName("meter_one").build();
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
assertCommit(writeTx.submit());
SalMeterServiceMock salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
List<AddMeterInput> addMeterCalls = salMeterService.getAddMeterCalls();
assertEquals(1, addMeterCalls.size());
assertEquals("DOM-0", addMeterCalls.get(0).getTransactionUri().getValue());
meterKey = new MeterKey(new MeterId((long) 2001));
meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Meter.class, meterKey);
meter = new MeterBuilder().setKey(meterKey).setMeterName("meter_two").setBarrier(true).build();
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
assertCommit(writeTx.submit());
salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
addMeterCalls = salMeterService.getAddMeterCalls();
assertEquals(2, addMeterCalls.size());
assertEquals("DOM-1", addMeterCalls.get(1).getTransactionUri().getValue());
assertEquals(meterII, addMeterCalls.get(1).getMeterRef().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId 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();
}
Aggregations