Search in sources :

Example 41 with MeterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.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());
}
Also used : MeterModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) AddMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterFlags) AddMeterInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInputBuilder) Test(org.junit.Test)

Example 42 with MeterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.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());
}
Also used : MeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.meter._case.MeterBuilder) InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.Meter) MeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder)

Example 43 with MeterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.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());
}
Also used : MeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder) StaleMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterBuilder) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) StaleMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeter) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) UpdateMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) MeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey) StaleMeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterKey) SalMeterServiceMock(test.mock.util.SalMeterServiceMock) AddMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput) FRMTest(test.mock.util.FRMTest) Test(org.junit.Test)

Example 44 with MeterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.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());
}
Also used : MeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey) StaleMeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterKey) MeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder) StaleMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterBuilder) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) SalMeterServiceMock(test.mock.util.SalMeterServiceMock) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) StaleMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeter) AddMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) FRMTest(test.mock.util.FRMTest) Test(org.junit.Test)

Example 45 with MeterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.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();
}
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

MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId)32 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)24 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId)23 ByteBuf (io.netty.buffer.ByteBuf)11 AddMeterInput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput)10 MeterFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags)9 MeterBandType (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType)8 DscpRemarkBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemarkBuilder)8 MeterBandHeadersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder)8 MeterBandHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader)8 MeterBandHeaderBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder)8 MeterBandTypesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder)8 MeterModInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder)8 MeterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder)7 MeterKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey)7 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)6 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)6 MeterCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder)6 MeterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder)6