Search in sources :

Example 51 with GroupId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId in project openflowplugin by opendaylight.

the class DeviceGroupRegistryImplTest method setUp.

@Before
public void setUp() throws Exception {
    deviceGroupRegistry = new DeviceGroupRegistryImpl();
    groupId = new GroupId(42L);
    groupId2 = new GroupId(84L);
    Assert.assertEquals(0, deviceGroupRegistry.getAllGroupIds().size());
    deviceGroupRegistry.store(groupId);
    Assert.assertEquals(1, deviceGroupRegistry.getAllGroupIds().size());
}
Also used : GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) Before(org.junit.Before)

Example 52 with GroupId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method testMultipartReplyGroupBody.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyGroupBody() {
    ByteBuf bb = BufferHelper.buildBuffer("00 06 00 01 00 00 00 00 " + // length
    "00 48 " + // pad1
    "00 00 " + // groupId
    "00 00 00 10 " + // refCount
    "00 00 00 12 " + // pad2
    "00 00 00 00 " + // packetCount
    "FF 01 01 01 01 01 01 01 " + // byteCount
    "FF 01 01 01 01 01 01 01 " + // durationSec
    "00 00 00 08 " + // durationNsec
    "00 00 00 09 " + // packetCountBucket
    "FF 01 01 01 01 01 01 01 " + // byteCountBucket
    "FF 01 01 01 01 01 01 01 " + // packetCountBucket_2
    "FF 02 02 02 02 02 02 02 " + // byteCountBucket_2
    "FF 02 02 02 02 02 02 02 " + // length_2
    "00 48 " + // pad1.2
    "00 00 " + // groupId_2
    "00 00 00 10 " + // refCount_2
    "00 00 00 12 " + // pad2.2
    "00 00 00 00 " + // packetCount_2
    "FF 01 01 01 01 01 01 01 " + // byteCount_2
    "FF 01 01 01 01 01 01 01 " + // durationSec_2
    "00 00 00 08 " + // durationNsec_2
    "00 00 00 09 " + // packetCountBucket_1.2
    "FF 01 01 01 01 01 01 01 " + // byteCountBucket_1.2
    "FF 01 01 01 01 01 01 01 " + // packetCountBucket_2.2
    "FF 02 02 02 02 02 02 02 " + // byteCountBucket_2.2
    "FF 02 02 02 02 02 02 02");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyGroupCase messageCase = (MultipartReplyGroupCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyGroup message = messageCase.getMultipartReplyGroup();
    Assert.assertEquals("Wrong groupId", 16, message.getGroupStats().get(0).getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong refCount", 18, message.getGroupStats().get(0).getRefCount().intValue());
    Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(0).getPacketCount());
    Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(0).getByteCount());
    Assert.assertEquals("Wrong durationSec", 8, message.getGroupStats().get(0).getDurationSec().intValue());
    Assert.assertEquals("Wrong durationNsec", 9, message.getGroupStats().get(0).getDurationNsec().intValue());
    Assert.assertEquals("Wrong packetCountBucket", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(0).getBucketStats().get(0).getPacketCount());
    Assert.assertEquals("Wrong byteCountBucket", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(0).getBucketStats().get(0).getByteCount());
    Assert.assertEquals("Wrong packetCountBucket_2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getGroupStats().get(0).getBucketStats().get(1).getPacketCount());
    Assert.assertEquals("Wrong byteCountBucket_2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getGroupStats().get(0).getBucketStats().get(1).getByteCount());
    Assert.assertEquals("Wrong groupId_2", 16, message.getGroupStats().get(1).getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong refCount_2", 18, message.getGroupStats().get(1).getRefCount().intValue());
    Assert.assertEquals("Wrong packetCount_2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(1).getPacketCount());
    Assert.assertEquals("Wrong byteCount_2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(1).getByteCount());
    Assert.assertEquals("Wrong durationSec_2", 8, message.getGroupStats().get(1).getDurationSec().intValue());
    Assert.assertEquals("Wrong durationNsec_2", 9, message.getGroupStats().get(1).getDurationNsec().intValue());
    Assert.assertEquals("Wrong packetCountBucket_1.2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(1).getBucketStats().get(0).getPacketCount());
    Assert.assertEquals("Wrong byteCountBucket_1.2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(1).getBucketStats().get(0).getByteCount());
    Assert.assertEquals("Wrong packetCountBucket_2.2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getGroupStats().get(1).getBucketStats().get(1).getPacketCount());
    Assert.assertEquals("Wrong byteCountBucket_2.2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getGroupStats().get(1).getBucketStats().get(1).getByteCount());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase) MultipartReplyGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup) BigInteger(java.math.BigInteger) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 53 with GroupId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method testMultipartReplyGroupDescBody01.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 * Test covers bodies of actions Output, Copy TTL Out, Copy TTL In.
 */
@Test
public void testMultipartReplyGroupDescBody01() {
    ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 " + // len
    "00 38 " + // type
    "01 " + // pad
    "00 " + // groupId
    "00 00 00 08 " + // bucketLen
    "00 30 " + // bucketWeight
    "00 06 " + // bucketWatchPort
    "00 00 00 05 " + // bucketWatchGroup
    "00 00 00 04 " + // bucketPad
    "00 00 00 00 " + // outputType
    "00 00 " + // outputLen
    "00 10 " + // outputPort
    "00 00 10 FF " + // outputMaxLen
    "FF FF " + // outputPad
    "00 00 00 00 00 00 " + // copyTTLOutType
    "00 0B " + // copyTTLOutLen
    "00 08 " + // copyTTLOutPad
    "00 00 00 00 " + // copyTTLIntType
    "00 0C " + // copyTTLIntLen
    "00 08 " + // copyTTLInPad
    "00 00 00 00");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
    Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue());
    Assert.assertEquals("Wrong groupId", 8, message.getGroupDesc().get(0).getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong bucketWeight", 6, message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
    Assert.assertEquals("Wrong bucketWatchPort", 5, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue());
    Assert.assertEquals("Wrong bucketWatchGroup", 4, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
    Assert.assertTrue("Wrong outputType", message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0).getActionChoice() instanceof OutputActionCase);
    Assert.assertEquals("Wrong outputPort", 4351, ((OutputActionCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0).getActionChoice()).getOutputAction().getPort().getValue().intValue());
    Assert.assertEquals("Wrong outputMaxLen", 65535, ((OutputActionCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0).getActionChoice()).getOutputAction().getMaxLength().intValue());
    Assert.assertTrue("Wrong copyTtlOutType", message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1).getActionChoice() instanceof CopyTtlOutCase);
    Assert.assertTrue("Wrong copyTtlInType", message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2).getActionChoice() instanceof CopyTtlInCase);
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyGroupDescCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase) MultipartReplyGroupDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc) CopyTtlOutCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCase) ByteBuf(io.netty.buffer.ByteBuf) OutputActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase) CopyTtlInCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase) Test(org.junit.Test)

Example 54 with GroupId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId in project openflowplugin by opendaylight.

the class GroupModInputMessageFactoryTest method test.

@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("00 02 03 00 00 00 01 00 00 10 00 0a 00 " + "00 00 41 00 00 00 16 00 00 00 00");
    GroupModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(deserializedMessage);
    // Test Message
    Assert.assertEquals("Wrong command", GroupModCommand.forValue(2), deserializedMessage.getCommand());
    Assert.assertEquals("Wrong type", GroupType.forValue(3), deserializedMessage.getType());
    Assert.assertEquals("Wrong group id", new GroupId(256L), deserializedMessage.getGroupId());
    BucketsList bucket = deserializedMessage.getBucketsList().get(0);
    Assert.assertEquals("Wrong weight", 10, bucket.getWeight().intValue());
    Assert.assertEquals("Wrong watch port", new PortNumber(65L), bucket.getWatchPort());
    Assert.assertEquals("Wrong watch group", 22L, bucket.getWatchGroup().longValue());
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) BucketsList(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) GroupModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId) Test(org.junit.Test)

Example 55 with GroupId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactory method setGroup.

private static MultipartReplyGroupCase setGroup(final ByteBuf input) {
    MultipartReplyGroupCaseBuilder caseBuilder = new MultipartReplyGroupCaseBuilder();
    MultipartReplyGroupBuilder builder = new MultipartReplyGroupBuilder();
    List<GroupStats> groupStatsList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        GroupStatsBuilder groupStatsBuilder = new GroupStatsBuilder();
        final int bodyLength = input.readUnsignedShort();
        input.skipBytes(PADDING_IN_GROUP_HEADER_01);
        groupStatsBuilder.setGroupId(new GroupId(input.readUnsignedInt()));
        groupStatsBuilder.setRefCount(input.readUnsignedInt());
        input.skipBytes(PADDING_IN_GROUP_HEADER_02);
        byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(packetCount);
        groupStatsBuilder.setPacketCount(new BigInteger(1, packetCount));
        byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(byteCount);
        groupStatsBuilder.setByteCount(new BigInteger(1, byteCount));
        groupStatsBuilder.setDurationSec(input.readUnsignedInt());
        groupStatsBuilder.setDurationNsec(input.readUnsignedInt());
        int actualLength = GROUP_BODY_LENGTH;
        List<BucketStats> bucketStatsList = new ArrayList<>();
        while (actualLength < bodyLength) {
            BucketStatsBuilder bucketStatsBuilder = new BucketStatsBuilder();
            byte[] packetCountBucket = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
            input.readBytes(packetCountBucket);
            bucketStatsBuilder.setPacketCount(new BigInteger(1, packetCountBucket));
            byte[] byteCountBucket = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
            input.readBytes(byteCountBucket);
            bucketStatsBuilder.setByteCount(new BigInteger(1, byteCountBucket));
            bucketStatsList.add(bucketStatsBuilder.build());
            actualLength += BUCKET_COUNTER_LENGTH;
        }
        groupStatsBuilder.setBucketStats(bucketStatsList);
        groupStatsList.add(groupStatsBuilder.build());
    }
    builder.setGroupStats(groupStatsList);
    caseBuilder.setMultipartReplyGroup(builder.build());
    return caseBuilder.build();
}
Also used : MultipartReplyGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCaseBuilder) MultipartReplyGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroupBuilder) ArrayList(java.util.ArrayList) BucketStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStatsBuilder) GroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId) GroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats) BigInteger(java.math.BigInteger) BucketStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats)

Aggregations

ArrayList (java.util.ArrayList)41 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)36 Test (org.junit.Test)28 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)27 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId)22 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)21 BigInteger (java.math.BigInteger)19 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)18 GroupBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder)12 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)11 BucketsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder)10 BucketBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder)10 ByteBuf (io.netty.buffer.ByteBuf)9 GroupKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey)9 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)8 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)8 AddGroupInput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput)8 AddGroupInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder)8 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)7 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)6