Search in sources :

Example 11 with GoToTableBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder in project openflowplugin by opendaylight.

the class OpenflowPluginBulkGroupTransactionProvider method createGotoTableInstructions.

private static InstructionsBuilder createGotoTableInstructions() {
    GoToTableBuilder aab = new GoToTableBuilder();
    aab.setTableId((short) 2);
    InstructionBuilder ib = new InstructionBuilder();
    ib.setInstruction(new GoToTableCaseBuilder().setGoToTable(aab.build()).build());
    // Put our Instruction in a list of Instructions
    InstructionsBuilder isb = new InstructionsBuilder();
    List<Instruction> instructions = new ArrayList<>();
    instructions.add(ib.build());
    isb.setInstruction(instructions);
    return isb;
}
Also used : InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder) ArrayList(java.util.ArrayList) GoToTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) GoToTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder)

Example 12 with GoToTableBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder in project openflowplugin by opendaylight.

the class FlowModInputMessageFactoryTest method createInstructions.

private List<Instruction> createInstructions() {
    final List<Instruction> instructions = new ArrayList<>();
    InstructionBuilder insBuilder = new InstructionBuilder();
    GotoTableCaseBuilder goToCaseBuilder = new GotoTableCaseBuilder();
    GotoTableBuilder instructionBuilder = new GotoTableBuilder();
    instructionBuilder.setTableId((short) 43);
    goToCaseBuilder.setGotoTable(instructionBuilder.build());
    insBuilder.setInstructionChoice(goToCaseBuilder.build());
    instructions.add(insBuilder.build());
    WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder();
    WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder();
    byte[] metadata = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 };
    metadataBuilder.setMetadata(metadata);
    byte[] metadataMask = new byte[] { (byte) 0xFF, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30 };
    metadataBuilder.setMetadataMask(metadataMask);
    metadataCaseBuilder.setWriteMetadata(metadataBuilder.build());
    insBuilder.setInstructionChoice(metadataCaseBuilder.build());
    instructions.add(insBuilder.build());
    insBuilder = new InstructionBuilder();
    final ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
    final ApplyActionsBuilder actionsBuilder = new ApplyActionsBuilder();
    final List<Action> actions = new ArrayList<>();
    final ActionBuilder actionBuilder = new ActionBuilder();
    OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
    OutputActionBuilder outputBuilder = new OutputActionBuilder();
    outputBuilder.setPort(new PortNumber(42L));
    outputBuilder.setMaxLength(52);
    caseBuilder.setOutputAction(outputBuilder.build());
    actionBuilder.setActionChoice(caseBuilder.build());
    actions.add(actionBuilder.build());
    actionsBuilder.setAction(actions);
    applyActionsCaseBuilder.setApplyActions(actionsBuilder.build());
    insBuilder.setInstructionChoice(applyActionsCaseBuilder.build());
    instructions.add(insBuilder.build());
    return instructions;
}
Also used : InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder) OutputActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) WriteMetadataCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder) ArrayList(java.util.ArrayList) GotoTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction) WriteMetadataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) GotoTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) ApplyActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder)

Example 13 with GoToTableBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder in project openflowplugin by opendaylight.

the class TableFeaturesResponseConvertor method setInstructionTableFeatureProperty.

private static List<Instruction> setInstructionTableFeatureProperty(final TableFeatureProperties properties) {
    List<Instruction> instructionList = new ArrayList<>();
    org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder();
    int index = 0;
    for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction currInstruction : properties.getAugmentation(InstructionRelatedTableFeatureProperty.class).getInstruction()) {
        InstructionChoice currInstructionType = currInstruction.getInstructionChoice();
        if (currInstructionType instanceof GotoTableCase) {
            builder.setInstruction(new GoToTableCaseBuilder().setGoToTable(new GoToTableBuilder().build()).build());
        } else if (currInstructionType instanceof WriteMetadataCase) {
            builder.setInstruction(new WriteMetadataCaseBuilder().setWriteMetadata(new WriteMetadataBuilder().build()).build());
        } else if (currInstructionType instanceof WriteActionsCase) {
            builder.setInstruction(new WriteActionsCaseBuilder().setWriteActions(new WriteActionsBuilder().build()).build());
        } else if (currInstructionType instanceof ApplyActionsCase) {
            builder.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(new ApplyActionsBuilder().build()).build());
        } else if (currInstructionType instanceof ClearActionsCase) {
            builder.setInstruction(new ClearActionsCaseBuilder().setClearActions(new ClearActionsBuilder().build()).build());
        } else if (currInstructionType instanceof MeterCase) {
            builder.setInstruction(new MeterCaseBuilder().setMeter(new MeterBuilder().build()).build());
        }
        // TODO: Experimenter instructions are unhandled
        builder.setOrder(index);
        index += 1;
        instructionList.add(builder.build());
    }
    return instructionList;
}
Also used : MeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder) WriteMetadataCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder) WriteMetadataCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase) MeterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase) ArrayList(java.util.ArrayList) WriteActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) WriteMetadataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder) ClearActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder) ApplyActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder) GoToTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder) MeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder) GotoTableCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase) InstructionRelatedTableFeatureProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty) WriteActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActionsBuilder) WriteActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCaseBuilder) ClearActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.clear.actions._case.ClearActionsBuilder) GoToTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder) ClearActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase) InstructionChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.InstructionChoice) ApplyActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase)

Example 14 with GoToTableBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder in project openflowplugin by opendaylight.

the class GoToTableCase method process.

@Override
public Optional<Instruction> process(@Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
    GoToTable goToTable = source.getGoToTable();
    GotoTableCaseBuilder gotoTableCaseBuilder = new GotoTableCaseBuilder();
    GotoTableBuilder gotoTableBuilder = new GotoTableBuilder();
    gotoTableBuilder.setTableId(goToTable.getTableId());
    gotoTableCaseBuilder.setGotoTable(gotoTableBuilder.build());
    InstructionBuilder instructionBuilder = new InstructionBuilder();
    instructionBuilder.setInstructionChoice(gotoTableCaseBuilder.build());
    return Optional.of(instructionBuilder.build());
}
Also used : InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder) GoToTable(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTable) GotoTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder) GotoTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder)

Example 15 with GoToTableBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder in project openflowplugin by opendaylight.

the class GoToTableInstructionSerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final short table = 2;
    final Instruction instruction = new GoToTableCaseBuilder().setGoToTable(new GoToTableBuilder().setTableId(table).build()).build();
    assertInstruction(instruction, out -> {
        assertEquals(out.readUnsignedByte(), table);
        out.skipBytes(InstructionConstants.PADDING_IN_GOTO_TABLE);
    });
}
Also used : Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction) GoToTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder) GoToTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)12 GoToTableBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder)8 GotoTableCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder)8 GotoTableBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder)8 InstructionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder)8 GoToTableCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder)7 Test (org.junit.Test)6 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)6 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)6 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)6 ApplyActionsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder)6 WriteMetadataCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder)6 ApplyActionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder)6 WriteMetadataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder)6 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction)6 InstructionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder)5 InstructionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder)5 BigInteger (java.math.BigInteger)4 OutputActionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder)4 OutputActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder)4