use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder 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.TableFeaturesBuilder 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.TableFeaturesBuilder in project openflowplugin by opendaylight.
the class SalTableServiceImplTest method testUpdateTableSuccess.
@Test
public void testUpdateTableSuccess() throws ExecutionException, InterruptedException {
Mockito.doAnswer((Answer<Void>) invocation -> {
TableFeaturesBuilder tableFeaturesBld = new TableFeaturesBuilder().setTableId((short) 0).setName("Zafod").setMaxEntries(42L).setTableFeatureProperties(Collections.<TableFeatureProperties>emptyList());
MultipartReplyTableFeaturesBuilder mpTableFeaturesBld = new MultipartReplyTableFeaturesBuilder().setTableFeatures(Collections.singletonList(tableFeaturesBld.build()));
MultipartReplyTableFeaturesCaseBuilder mpBodyBld = new MultipartReplyTableFeaturesCaseBuilder().setMultipartReplyTableFeatures(mpTableFeaturesBld.build());
MultipartReplyMessageBuilder mpResultBld = new MultipartReplyMessageBuilder().setType(MultipartType.OFPMPTABLEFEATURES).setMultipartReplyBody(mpBodyBld.build()).setXid(21L);
final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder.success(Collections.singletonList((MultipartReply) mpResultBld.build())).build();
handleResultFuture.set(rpcResult);
return null;
}).when(multiMessageCollector).endCollecting(Matchers.<EventIdentifier>any());
final Future<RpcResult<UpdateTableOutput>> rpcResultFuture = salTableService.updateTable(prepareUpdateTable());
Assert.assertNotNull(rpcResultFuture);
verify(mockedRequestContextStack).createRequestContext();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder in project openflowplugin by opendaylight.
the class OpenflowpluginTableFeaturesTestCommandProvider method createTestTableFeatures.
private TableFeaturesBuilder createTestTableFeatures(String tableFeatureTypeArg) {
String tableFeatureType = tableFeatureTypeArg;
if (tableFeatureType == null) {
tableFeatureType = "t1";
}
final TableFeaturesBuilder tableFeature = new TableFeaturesBuilder();
// Sample data , committing to DataStore
if (!tableFeatureType.equals("t1")) {
tableFeature.setTableId((short) 0);
tableFeature.setName("Table 0");
tableFeature.setMetadataMatch(BigInteger.valueOf(10));
tableFeature.setMetadataWrite(BigInteger.valueOf(10));
tableFeature.setMaxEntries(10000L);
tableFeature.setConfig(new TableConfig(false));
List<TableFeatureProperties> properties = new ArrayList<>();
switch(tableFeatureType) {
case "t2":
// To set the ApplyActionsMiss
properties.add(createApplyActionsMissTblFeatureProp().build());
break;
case "t3":
// To set the Next Table
properties.add(createNextTblFeatureProp().build());
break;
case "t4":
// To set the Next Table Miss
properties.add(createNextTableMissTblFeatureProp().build());
break;
case "t5":
// To set the ApplyActions
properties.add(createApplyActionsTblFeatureProp().build());
break;
case "t6":
// To set the instructions
properties.add(createInstructionsTblFeatureProp().build());
break;
case "t7":
// To set the instructions miss
properties.add(createInstructionsMissTblFeatureProp().build());
break;
case "t8":
// To set the write actions
properties.add(createWriteActionsTblFeatureProp().build());
break;
case "t9":
// To set the write actions miss
properties.add(createWriteActionsMissTblFeatureProp().build());
break;
case "t10":
// To set the match field
properties.add(createMatchFieldTblFeatureProp().build());
break;
case "t11":
// To set the write set-field
properties.add(createWriteSetFieldTblFeatureProp().build());
break;
case "t12":
// To set the write set-field miss
properties.add(createWriteSetFieldMissTblFeatureProp().build());
break;
case "t13":
// To set the apply set field
properties.add(createApplySetFieldTblFeatureProp().build());
break;
case "t14":
// To set the apply set field miss
properties.add(createApplySetFieldMissTblFeatureProp().build());
break;
case "t15":
// To set the wildcards set field match
properties.add(createWildCardsTblFeatureProp().build());
break;
default:
break;
}
TablePropertiesBuilder propertyBld = new TablePropertiesBuilder();
propertyBld.setTableFeatureProperties(properties);
tableFeature.setTableProperties(propertyBld.build());
}
return tableFeature;
}
Aggregations