use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.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();
}
Aggregations