Search in sources :

Example 16 with TableFeatures

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

the class TableForwarder method update.

@Override
public void update(final InstanceIdentifier<TableFeatures> identifier, final TableFeatures original, final TableFeatures update, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
    LOG.debug("Received the Table Update request [Tbl id, node Id, original, upd" + " " + identifier + " " + nodeIdent + " " + original + " " + update);
    final TableFeatures originalTableFeatures = original;
    TableFeatures updatedTableFeatures;
    if (null == update) {
        updatedTableFeatures = original;
    } else {
        updatedTableFeatures = update;
    }
    final UpdateTableInputBuilder builder = new UpdateTableInputBuilder();
    builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
    // TODO: reconsider model - this particular field is not used in service
    // implementation
    builder.setTableRef(new TableRef(identifier));
    builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
    builder.setUpdatedTable(new UpdatedTableBuilder().setTableFeatures(Collections.singletonList(updatedTableFeatures)).build());
    builder.setOriginalTable(new OriginalTableBuilder().setTableFeatures(Collections.singletonList(originalTableFeatures)).build());
    LOG.debug("Invoking SalTableService ");
    if (this.provider.getSalTableService() != null) {
        LOG.debug(" Handle to SalTableServices" + this.provider.getSalTableService());
    }
    final Future<RpcResult<UpdateTableOutput>> resultFuture = this.provider.getSalTableService().updateTable(builder.build());
    JdkFutures.addErrorLogging(resultFuture, LOG, "updateTable");
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) OriginalTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.OriginalTableBuilder) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) 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) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) TableRef(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableRef)

Example 17 with TableFeatures

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

the class MultipartReplyMessageFactory method setTableFeatures.

private MultipartReplyTableFeaturesCase setTableFeatures(final ByteBuf input) {
    MultipartReplyTableFeaturesCaseBuilder caseBuilder = new MultipartReplyTableFeaturesCaseBuilder();
    MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
    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_REPLY_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(metadataMatch);
        byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(metadataWrite);
        featuresBuilder.setMetadataWrite(metadataWrite);
        featuresBuilder.setConfig(createTableConfig(input.readUnsignedInt()));
        featuresBuilder.setMaxEntries(input.readUnsignedInt());
        featuresBuilder.setTableFeatureProperties(createTableFeaturesProperties(input, length - MULTIPART_REPLY_TABLE_FEATURES_STRUCTURE_LENGTH));
        features.add(featuresBuilder.build());
    }
    builder.setTableFeatures(features);
    caseBuilder.setMultipartReplyTableFeatures(builder.build());
    return caseBuilder.build();
}
Also used : 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) ArrayList(java.util.ArrayList) MultipartReplyTableFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCaseBuilder) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder) 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) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder)

Example 18 with TableFeatures

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

the class MultipartRequestInputFactory method serializeTableFeaturesBody.

private void serializeTableFeaturesBody(final MultipartRequestBody multipartRequestBody, final ByteBuf output) {
    if (multipartRequestBody != null) {
        MultipartRequestTableFeaturesCase tableFeaturesCase = (MultipartRequestTableFeaturesCase) multipartRequestBody;
        MultipartRequestTableFeatures tableFeatures = tableFeaturesCase.getMultipartRequestTableFeatures();
        if (tableFeatures.getTableFeatures() != null) {
            for (TableFeatures currTableFeature : tableFeatures.getTableFeatures()) {
                final int tableFeatureLengthIndex = output.writerIndex();
                output.writeShort(EncodeConstants.EMPTY_LENGTH);
                output.writeByte(currTableFeature.getTableId());
                output.writeZero(PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY);
                final byte[] nameBytes = currTableFeature.getName().getBytes(StandardCharsets.UTF_8);
                output.writeBytes(nameBytes);
                output.writeZero(32 - nameBytes.length);
                output.writeLong(currTableFeature.getMetadataMatch().longValue());
                output.writeLong(currTableFeature.getMetadataWrite().longValue());
                output.writeInt(createTableConfigBitmask(currTableFeature.getConfig()));
                output.writeInt(currTableFeature.getMaxEntries().intValue());
                writeTableFeatureProperties(output, currTableFeature.getTableFeatureProperties());
                output.setShort(tableFeatureLengthIndex, output.writerIndex() - tableFeatureLengthIndex);
            }
        }
    }
}
Also used : MultipartRequestTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeatures) 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) MultipartRequestTableFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCase) MultipartRequestTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeatures)

Example 19 with TableFeatures

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

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

the class TableFeaturesConvertor method convert.

@Override
public List<TableFeatures> convert(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures source, VersionConvertorData data) {
    List<TableFeatures> ofTableFeaturesList = new ArrayList<>();
    TableFeaturesBuilder ofTableFeatures = new TableFeaturesBuilder();
    for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures salTableFeatures : source.getTableFeatures()) {
        ofTableFeatures.setTableId(salTableFeatures.getTableId());
        ofTableFeatures.setName(salTableFeatures.getName());
        ofTableFeatures.setMetadataMatch(salTableFeatures.getMetadataMatch());
        ofTableFeatures.setMetadataWrite(salTableFeatures.getMetadataWrite());
        ofTableFeatures.setMaxEntries(salTableFeatures.getMaxEntries());
        if (salTableFeatures.getConfig() != null) {
            ofTableFeatures.setConfig(new TableConfig(salTableFeatures.getConfig().isDEPRECATEDMASK()));
        }
        ofTableFeatures.setTableFeatureProperties(toTableProperties(salTableFeatures.getTableProperties()));
        ofTableFeaturesList.add(ofTableFeatures.build());
    }
    return ofTableFeaturesList;
}
Also used : 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) TableConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig)

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