Search in sources :

Example 6 with TableBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder in project openflowplugin by opendaylight.

the class MultipartRequestInputMessageFactory method setTable.

private MultipartRequestTableCase setTable(ByteBuf input) {
    MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder();
    MultipartRequestTableBuilder tableBuilder = new MultipartRequestTableBuilder();
    tableBuilder.setEmpty(true);
    caseBuilder.setMultipartRequestTable(tableBuilder.build());
    return caseBuilder.build();
}
Also used : MultipartRequestTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder) MultipartRequestTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder)

Example 7 with TableBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder in project openflowplugin by opendaylight.

the class MultipartRequestInputMessageFactory method createTableFeaturesProperties.

private List<TableFeatureProperties> createTableFeaturesProperties(ByteBuf input, int length) {
    List<TableFeatureProperties> properties = new ArrayList<>();
    int tableFeaturesLength = length;
    while (tableFeaturesLength > 0) {
        int propStartIndex = input.readerIndex();
        TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder();
        TableFeaturesPropType type = TableFeaturesPropType.forValue(input.readUnsignedShort());
        builder.setType(type);
        int propertyLength = input.readUnsignedShort();
        int paddingRemainder = propertyLength % EncodeConstants.PADDING;
        tableFeaturesLength -= propertyLength;
        if (type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONS) || type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS)) {
            InstructionRelatedTableFeaturePropertyBuilder insBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
            CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
            List<Instruction> instructions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry);
            insBuilder.setInstruction(instructions);
            builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insBuilder.build());
        } else if (type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLES) || type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS)) {
            propertyLength -= COMMON_PROPERTY_LENGTH;
            NextTableRelatedTableFeaturePropertyBuilder tableBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
            List<NextTableIds> ids = new ArrayList<>();
            while (propertyLength > 0) {
                NextTableIdsBuilder nextTableIdsBuilder = new NextTableIdsBuilder();
                nextTableIdsBuilder.setTableId(input.readUnsignedByte());
                ids.add(nextTableIdsBuilder.build());
                propertyLength--;
            }
            tableBuilder.setNextTableIds(ids);
            builder.addAugmentation(NextTableRelatedTableFeatureProperty.class, tableBuilder.build());
        } else if (type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONS) || type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS) || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONS) || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS)) {
            ActionRelatedTableFeaturePropertyBuilder actionBuilder = new ActionRelatedTableFeaturePropertyBuilder();
            CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
            List<Action> actions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry);
            actionBuilder.setAction(actions);
            builder.addAugmentation(ActionRelatedTableFeatureProperty.class, actionBuilder.build());
        } else if (type.equals(TableFeaturesPropType.OFPTFPTMATCH) || type.equals(TableFeaturesPropType.OFPTFPTWILDCARDS) || type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELD) || type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS) || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD) || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS)) {
            OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
            CodeKeyMaker keyMaker = CodeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);
            List<MatchEntry> entries = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry);
            oxmBuilder.setMatchEntry(entries);
            builder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
        } else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER) || type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS)) {
            long expId = input.readUnsignedInt();
            input.readerIndex(propStartIndex);
            OFDeserializer<TableFeatureProperties> propDeserializer = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId));
            TableFeatureProperties expProp = propDeserializer.deserialize(input);
            properties.add(expProp);
            continue;
        }
        if (paddingRemainder != 0) {
            input.skipBytes(EncodeConstants.PADDING - paddingRemainder);
            tableFeaturesLength -= EncodeConstants.PADDING - paddingRemainder;
        }
        properties.add(builder.build());
    }
    return properties;
}
Also used : TableFeaturesPropType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) NextTableIdsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder) OxmRelatedTableFeatureProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty) TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) ArrayList(java.util.ArrayList) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction) NextTableRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder) NextTableRelatedTableFeatureProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty) InstructionRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder) ActionRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder) TableFeaturePropertiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder) CodeKeyMaker(org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker) List(java.util.List) ArrayList(java.util.ArrayList) OxmRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder)

Example 8 with TableBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder in project openflowplugin by opendaylight.

the class OF10StatsRequestInputFactory method setTable.

private MultipartRequestTableCase setTable(ByteBuf input) {
    MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder();
    MultipartRequestTableBuilder tableBuilder = new MultipartRequestTableBuilder();
    tableBuilder.setEmpty(true);
    caseBuilder.setMultipartRequestTable(tableBuilder.build());
    return caseBuilder.build();
}
Also used : MultipartRequestTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder) MultipartRequestTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder)

Example 9 with TableBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder in project openflowplugin by opendaylight.

the class DeviceFlowRegistryImplTest method testFill.

@Test
public void testFill() throws Exception {
    final InstanceIdentifier<FlowCapableNode> path = nodeInstanceIdentifier.augmentation(FlowCapableNode.class);
    final Flow flow = new FlowBuilder().setTableId((short) 1).setPriority(10).setCookie(new FlowCookie(BigInteger.TEN)).setId(new FlowId("HELLO")).build();
    final Table table = new TableBuilder().setFlow(Collections.singletonList(flow)).build();
    final FlowCapableNode flowCapableNode = new FlowCapableNodeBuilder().setTable(Collections.singletonList(table)).build();
    final Map<FlowRegistryKey, FlowDescriptor> allFlowDescriptors = fillRegistry(path, flowCapableNode);
    key = FlowRegistryKeyFactory.create(OFConstants.OFP_VERSION_1_3, flow);
    InOrder order = inOrder(dataBroker, readOnlyTransaction);
    order.verify(dataBroker).newReadOnlyTransaction();
    order.verify(readOnlyTransaction).read(LogicalDatastoreType.CONFIGURATION, path);
    order.verify(dataBroker).newReadOnlyTransaction();
    order.verify(readOnlyTransaction).read(LogicalDatastoreType.OPERATIONAL, path);
    assertTrue(allFlowDescriptors.containsKey(key));
    deviceFlowRegistry.addMark(key);
}
Also used : Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) InOrder(org.mockito.InOrder) FlowRegistryKey(org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey) FlowDescriptor(org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) FlowCapableNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder) TableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) Test(org.junit.Test)

Example 10 with TableBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder in project openflowplugin by opendaylight.

the class DeviceFlowRegistryImplTest method testFailedFill.

@Test
public void testFailedFill() throws Exception {
    final InstanceIdentifier<FlowCapableNode> path = nodeInstanceIdentifier.augmentation(FlowCapableNode.class);
    fillRegistry(path, null);
    fillRegistry(path, new FlowCapableNodeBuilder().setTable(null).build());
    fillRegistry(path, new FlowCapableNodeBuilder().setTable(Collections.singletonList(null)).build());
    fillRegistry(path, new FlowCapableNodeBuilder().setTable(Collections.singletonList(new TableBuilder().setFlow(null).build())).build());
    fillRegistry(path, new FlowCapableNodeBuilder().setTable(Collections.singletonList(new TableBuilder().setFlow(Collections.singletonList(null)).build())).build());
    fillRegistry(path, new FlowCapableNodeBuilder().setTable(Collections.singletonList(new TableBuilder().setFlow(Collections.singletonList(new FlowBuilder().setId(null).build())).build())).build());
    verify(dataBroker, times(12)).newReadOnlyTransaction();
    verify(readOnlyTransaction, times(6)).read(LogicalDatastoreType.CONFIGURATION, path);
    verify(readOnlyTransaction, times(6)).read(LogicalDatastoreType.OPERATIONAL, path);
    Assert.assertEquals(1, deviceFlowRegistry.getAllFlowDescriptors().size());
}
Also used : FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) FlowCapableNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder) TableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder) Test(org.junit.Test)

Aggregations

FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)14 TableBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder)14 Test (org.junit.Test)13 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)9 FlowCapableNodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder)7 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)7 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)7 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)6 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)6 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)6 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)5 StaleFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlow)5 StaleFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlowBuilder)5 StaleFlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlowKey)5 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)5 FRMTest (test.mock.util.FRMTest)5 Optional (com.google.common.base.Optional)4 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)4 AddFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput)4 MultipartRequestTableCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder)4