Search in sources :

Example 21 with TableFeatures

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures in project openflowplugin by opendaylight.

the class MultipartRequestInputMessageFactory method setTableFeatures.

private MultipartRequestTableFeaturesCase setTableFeatures(ByteBuf input) {
    MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
    MultipartRequestTableFeaturesBuilder tableFeaturesBuilder = new MultipartRequestTableFeaturesBuilder();
    List<TableFeatures> features = new ArrayList<>();
    while (input.readableBytes() > 0) {
        TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder();
        final int length = input.readUnsignedShort();
        featuresBuilder.setTableId(input.readUnsignedByte());
        input.skipBytes(PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES);
        featuresBuilder.setName(ByteBufUtils.decodeNullTerminatedString(input, MAX_TABLE_NAME_LENGTH));
        byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(metadataMatch);
        featuresBuilder.setMetadataMatch(new BigInteger(1, metadataMatch));
        byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(metadataWrite);
        featuresBuilder.setMetadataWrite(new BigInteger(1, metadataWrite));
        featuresBuilder.setConfig(createTableConfig(input.readUnsignedInt()));
        featuresBuilder.setMaxEntries(input.readUnsignedInt());
        featuresBuilder.setTableFeatureProperties(createTableFeaturesProperties(input, length - MULTIPART_REQUEST_TABLE_FEATURES_STRUCTURE_LENGTH));
        features.add(featuresBuilder.build());
    }
    tableFeaturesBuilder.setTableFeatures(features);
    caseBuilder.setMultipartRequestTableFeatures(tableFeaturesBuilder.build());
    return caseBuilder.build();
}
Also used : MultipartRequestTableFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder) MultipartRequestTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures) ArrayList(java.util.ArrayList) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeaturesBuilder) MultipartRequestTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder) BigInteger(java.math.BigInteger)

Example 22 with TableFeatures

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures 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)

Example 23 with TableFeatures

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures in project openflowplugin by opendaylight.

the class TableFeaturesResponseConvertor method convert.

@Override
public List<TableFeatures> convert(MultipartReplyTableFeatures source, VersionConvertorData data) {
    if (source == null || source.getTableFeatures() == null) {
        return Collections.emptyList();
    }
    List<TableFeatures> salTableFeaturesList = new ArrayList<>();
    TableFeaturesBuilder salTableFeatures = new TableFeaturesBuilder();
    for (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 ofTableFeatures : source.getTableFeatures()) {
        salTableFeatures.setTableId(ofTableFeatures.getTableId());
        salTableFeatures.setName(ofTableFeatures.getName());
        if (ofTableFeatures.getMetadataMatch() != null) {
            salTableFeatures.setMetadataMatch(new BigInteger(OFConstants.SIGNUM_UNSIGNED, ofTableFeatures.getMetadataMatch()));
        }
        if (ofTableFeatures.getMetadataWrite() != null) {
            salTableFeatures.setMetadataWrite(new BigInteger(OFConstants.SIGNUM_UNSIGNED, ofTableFeatures.getMetadataWrite()));
        }
        if (ofTableFeatures.getConfig() != null) {
            salTableFeatures.setConfig(new TableConfig(ofTableFeatures.getConfig().isOFPTCDEPRECATEDMASK()));
        }
        salTableFeatures.setMaxEntries(ofTableFeatures.getMaxEntries());
        salTableFeatures.setTableProperties(toTableProperties(ofTableFeatures.getTableFeatureProperties()));
        salTableFeaturesList.add(salTableFeatures.build());
    }
    return salTableFeaturesList;
}
Also used : ArrayList(java.util.ArrayList) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder) 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) BigInteger(java.math.BigInteger) TableConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig)

Example 24 with TableFeatures

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures in project openflowplugin by opendaylight.

the class TableFeaturesResponseConvertorTest method test2.

/**
 * Incorrect / empty input test.
 */
@Test
public void test2() {
    MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
    List<TableFeatures> list = convert(builder.build());
    Assert.assertEquals("Returned list is not empty", 0, list.size());
}
Also used : 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) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder) Test(org.junit.Test)

Example 25 with TableFeatures

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures in project openflowplugin by opendaylight.

the class SalTableServiceImplTest method prepareUpdateTable.

private UpdateTableInput prepareUpdateTable() {
    UpdateTableInputBuilder updateTableInputBuilder = new UpdateTableInputBuilder();
    UpdatedTableBuilder updatedTableBuilder = new UpdatedTableBuilder();
    updatedTableBuilder.setTableFeatures(Collections.<TableFeatures>emptyList());
    updateTableInputBuilder.setUpdatedTable(updatedTableBuilder.build());
    return updateTableInputBuilder.build();
}
Also used : UpdatedTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder) UpdateTableInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInputBuilder)

Aggregations

ArrayList (java.util.ArrayList)13 TableFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures)13 Test (org.junit.Test)12 BigInteger (java.math.BigInteger)8 MultipartReplyTableFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures)8 TableConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig)7 ByteBuf (io.netty.buffer.ByteBuf)6 TableFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures)6 TableFeatureProperties (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties)6 MultipartReplyTableFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder)5 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)5 TableFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeaturesBuilder)5 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)4 NextTableIds (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds)4 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)4 MultipartRequestTableFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder)4 TableFeaturePropertiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder)4 UpdatedTableBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder)4 TableFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder)4 ActionRelatedTableFeaturePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder)3