Search in sources :

Example 6 with MultipartReplyTableFeaturesCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase in project openflowplugin by opendaylight.

the class MultipartReplyTableFeaturesTest method testMultipartReplyTableFeatures2.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyTableFeatures2() {
    ByteBuf bb = BufferHelper.buildBuffer(// 
    "00 0C 00 00 00 00 00 00 " + // length, tableId, padding
    "00 B0 01 00 00 00 00 00 " + // 
    "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 " + // name
    "00 00 00 00 00 00 00 00 00 00 00 00 00 " + // metadata match
    "00 00 00 00 00 00 00 01 " + // metadata write
    "00 00 00 00 00 00 00 02 " + // config
    "00 00 00 00 " + // max entries
    "00 00 00 2A " + // 
    "00 00 00 04 00 00 00 00 " + // 
    "00 01 00 04 00 00 00 00 " + // 
    "00 02 00 08 01 02 03 04 " + // 
    "00 03 00 07 05 06 07 00 " + // 
    "00 04 00 04 00 00 00 00 " + // 
    "00 05 00 04 00 00 00 00 " + // 
    "00 06 00 04 00 00 00 00 " + // 
    "00 07 00 04 00 00 00 00 " + // 
    "00 08 00 04 00 00 00 00 " + // 
    "00 0A 00 04 00 00 00 00 " + // 
    "00 0C 00 04 00 00 00 00 " + // 
    "00 0D 00 04 00 00 00 00 " + // 
    "00 0E 00 04 00 00 00 00 " + "00 0F 00 04 00 00 00 00");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures();
    Assert.assertEquals("Wrong table features size", 1, message.getTableFeatures().size());
    TableFeatures feature = message.getTableFeatures().get(0);
    Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue());
    Assert.assertEquals("Wrong name", "Opendaylight", feature.getName());
    Assert.assertArrayEquals("Wrong metadata match", new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, feature.getMetadataMatch());
    Assert.assertArrayEquals("Wrong metadata write", new byte[] { 0, 0, 0, 0, 0, 0, 0, 2 }, feature.getMetadataWrite());
    Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK());
    Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue());
    Assert.assertEquals("Wrong properties size", 14, feature.getTableFeatureProperties().size());
    Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTINSTRUCTIONS, feature.getTableFeatureProperties().get(0).getType());
    Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, feature.getTableFeatureProperties().get(1).getType());
    TableFeatureProperties property = feature.getTableFeatureProperties().get(2);
    Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTNEXTTABLES, property.getType());
    List<NextTableIds> tableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class).getNextTableIds();
    Assert.assertEquals("Wrong next table id size", 4, tableIds.size());
    Assert.assertEquals("Wrong next table id", 1, tableIds.get(0).getTableId().intValue());
    Assert.assertEquals("Wrong next table id", 2, tableIds.get(1).getTableId().intValue());
    Assert.assertEquals("Wrong next table id", 3, tableIds.get(2).getTableId().intValue());
    Assert.assertEquals("Wrong next table id", 4, tableIds.get(3).getTableId().intValue());
    property = feature.getTableFeatureProperties().get(3);
    Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTNEXTTABLESMISS, property.getType());
    tableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class).getNextTableIds();
    Assert.assertEquals("Wrong next table id size", 3, tableIds.size());
    Assert.assertEquals("Wrong next table id", 5, tableIds.get(0).getTableId().intValue());
    Assert.assertEquals("Wrong next table id", 6, tableIds.get(1).getTableId().intValue());
    Assert.assertEquals("Wrong next table id", 7, tableIds.get(2).getTableId().intValue());
    Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITEACTIONS, feature.getTableFeatureProperties().get(4).getType());
    Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, feature.getTableFeatureProperties().get(5).getType());
    Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYACTIONS, feature.getTableFeatureProperties().get(6).getType());
    Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, feature.getTableFeatureProperties().get(7).getType());
    Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTMATCH, feature.getTableFeatureProperties().get(8).getType());
    Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWILDCARDS, feature.getTableFeatureProperties().get(9).getType());
    Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITESETFIELD, feature.getTableFeatureProperties().get(10).getType());
    Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, feature.getTableFeatureProperties().get(11).getType());
    Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, feature.getTableFeatureProperties().get(12).getType());
    Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, feature.getTableFeatureProperties().get(13).getType());
}
Also used : MultipartReplyTableFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures) TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) NextTableIds(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds) ByteBuf(io.netty.buffer.ByteBuf) NextTableRelatedTableFeatureProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures) Test(org.junit.Test)

Example 7 with MultipartReplyTableFeaturesCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase in project openflowplugin by opendaylight.

the class MultiLayerTableMultipartService method convertToSalTableFeatures.

protected List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> convertToSalTableFeatures(final List<MultipartReply> multipartReplies) {
    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeaturesAll = new ArrayList<>();
    for (final MultipartReply multipartReply : multipartReplies) {
        if (multipartReply.getType().equals(MultipartType.OFPMPTABLEFEATURES)) {
            final MultipartReplyBody multipartReplyBody = multipartReply.getMultipartReplyBody();
            if (multipartReplyBody instanceof MultipartReplyTableFeaturesCase) {
                final MultipartReplyTableFeaturesCase tableFeaturesCase = (MultipartReplyTableFeaturesCase) multipartReplyBody;
                final MultipartReplyTableFeatures salTableFeatures = tableFeaturesCase.getMultipartReplyTableFeatures();
                final Optional<List<TableFeatures>> salTableFeaturesPartial = convertorExecutor.convert(salTableFeatures, data);
                salTableFeaturesPartial.ifPresent(salTableFeaturesAll::addAll);
                LOG.debug("TableFeature {} for xid {}.", salTableFeatures, multipartReply.getXid());
            }
        }
    }
    return salTableFeaturesAll;
}
Also used : MultipartReplyTableFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase) MultipartReplyBody(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) ArrayList(java.util.ArrayList) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures) ArrayList(java.util.ArrayList) List(java.util.List) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures)

Aggregations

MultipartReplyTableFeaturesCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase)6 MultipartReplyTableFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures)6 ByteBuf (io.netty.buffer.ByteBuf)4 TableFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)3 List (java.util.List)2 TableFeatureProperties (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties)2 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)1 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)1 NextTableRelatedTableFeatureProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty)1 NextTableIds (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds)1 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)1 MultipartReplyBody (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody)1 MultipartReplyTableFeaturesCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCaseBuilder)1 MultipartReplyTableFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder)1 TableFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder)1 MultipartReplyTableFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder)1 TableFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures)1