Search in sources :

Example 51 with InstructionsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder in project openflowplugin by opendaylight.

the class FlowConvertorTest method testInstructionsTranslation.

/**
 * Tests {@link FlowConvertor#convert(Flow, VersionDatapathIdConvertorData)} }.
 */
@Test
public void testInstructionsTranslation() {
    InstructionBuilder instructionBuilder = new InstructionBuilder();
    GoToTableCaseBuilder goToCaseBuilder = new GoToTableCaseBuilder();
    GoToTableBuilder goToBuilder = new GoToTableBuilder();
    goToBuilder.setTableId((short) 1);
    goToCaseBuilder.setGoToTable(goToBuilder.build());
    instructionBuilder.setInstruction(goToCaseBuilder.build());
    instructionBuilder.setOrder(0);
    List<Instruction> instructions = new ArrayList<>();
    instructions.add(instructionBuilder.build());
    instructionBuilder = new InstructionBuilder();
    WriteMetadataCaseBuilder metaCaseBuilder = new WriteMetadataCaseBuilder();
    WriteMetadataBuilder metaBuilder = new WriteMetadataBuilder();
    metaBuilder.setMetadata(new BigInteger("2"));
    metaBuilder.setMetadataMask(new BigInteger("3"));
    metaCaseBuilder.setWriteMetadata(metaBuilder.build());
    instructionBuilder.setInstruction(metaCaseBuilder.build());
    instructionBuilder.setOrder(1);
    instructions.add(instructionBuilder.build());
    instructionBuilder = new InstructionBuilder();
    WriteActionsCaseBuilder writeCaseBuilder = new WriteActionsCaseBuilder();
    WriteActionsBuilder writeBuilder = new WriteActionsBuilder();
    List<Action> actions = new ArrayList<>();
    writeBuilder.setAction(actions);
    writeCaseBuilder.setWriteActions(writeBuilder.build());
    instructionBuilder.setInstruction(writeCaseBuilder.build());
    instructionBuilder.setOrder(2);
    instructions.add(instructionBuilder.build());
    instructionBuilder = new InstructionBuilder();
    ApplyActionsCaseBuilder applyCaseBuilder = new ApplyActionsCaseBuilder();
    ApplyActionsBuilder applyBuilder = new ApplyActionsBuilder();
    actions = new ArrayList<>();
    applyBuilder.setAction(actions);
    applyCaseBuilder.setApplyActions(applyBuilder.build());
    instructionBuilder.setInstruction(applyCaseBuilder.build());
    instructionBuilder.setOrder(3);
    instructions.add(instructionBuilder.build());
    instructionBuilder = new InstructionBuilder();
    ClearActionsCaseBuilder clearCaseBuilder = new ClearActionsCaseBuilder();
    ClearActionsBuilder clearBuilder = new ClearActionsBuilder();
    actions = new ArrayList<>();
    clearBuilder.setAction(actions);
    clearCaseBuilder.setClearActions(clearBuilder.build());
    instructionBuilder.setInstruction(clearCaseBuilder.build());
    instructionBuilder.setOrder(4);
    instructions.add(instructionBuilder.build());
    instructionBuilder = new InstructionBuilder();
    MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
    MeterBuilder meterBuilder = new MeterBuilder();
    meterBuilder.setMeterId(new MeterId(5L));
    meterCaseBuilder.setMeter(meterBuilder.build());
    instructionBuilder.setInstruction(meterCaseBuilder.build());
    instructionBuilder.setOrder(5);
    instructions.add(instructionBuilder.build());
    InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
    instructionsBuilder.setInstruction(instructions);
    AddFlowInputBuilder flowBuilder = new AddFlowInputBuilder();
    flowBuilder.setInstructions(instructionsBuilder.build());
    AddFlowInput flow = flowBuilder.build();
    VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
    data.setDatapathId(new BigInteger("42"));
    List<FlowModInputBuilder> flowMod = convert(flow, data);
    Assert.assertEquals("Wrong version", 1, flowMod.get(0).getVersion().intValue());
    Assert.assertEquals("Wrong command", FlowModCommand.OFPFCADD, flowMod.get(0).getCommand());
    Assert.assertEquals("Wrong instructions size", 6, flowMod.get(0).getInstruction().size());
    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction instruction = flowMod.get(0).getInstruction().get(0);
    Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase", instruction.getInstructionChoice().getImplementedInterface().getName());
    GotoTableCase gotoTableCase = (GotoTableCase) instruction.getInstructionChoice();
    Assert.assertEquals("Wrong table id", 1, gotoTableCase.getGotoTable().getTableId().intValue());
    instruction = flowMod.get(0).getInstruction().get(1);
    Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase", instruction.getInstructionChoice().getImplementedInterface().getName());
    WriteMetadataCase writeMetadataCase = (WriteMetadataCase) instruction.getInstructionChoice();
    Assert.assertArrayEquals("Wrong metadata", new byte[] { 0, 0, 0, 0, 0, 0, 0, 2 }, writeMetadataCase.getWriteMetadata().getMetadata());
    Assert.assertArrayEquals("Wrong metadata mask", new byte[] { 0, 0, 0, 0, 0, 0, 0, 3 }, writeMetadataCase.getWriteMetadata().getMetadataMask());
    instruction = flowMod.get(0).getInstruction().get(2);
    Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase", instruction.getInstructionChoice().getImplementedInterface().getName());
    WriteActionsCase writeActionsCase = (WriteActionsCase) instruction.getInstructionChoice();
    Assert.assertEquals("Wrong actions size", 0, writeActionsCase.getWriteActions().getAction().size());
    instruction = flowMod.get(0).getInstruction().get(3);
    Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase", instruction.getInstructionChoice().getImplementedInterface().getName());
    ApplyActionsCase applyActionsCase = (ApplyActionsCase) instruction.getInstructionChoice();
    Assert.assertEquals("Wrong actions size", 0, applyActionsCase.getApplyActions().getAction().size());
    instruction = flowMod.get(0).getInstruction().get(4);
    Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase", instruction.getInstructionChoice().getImplementedInterface().getName());
    instruction = flowMod.get(0).getInstruction().get(5);
    Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".instruction.rev130731.instruction.grouping.instruction.choice.MeterCase", instruction.getInstructionChoice().getImplementedInterface().getName());
    MeterCase meterCase = (MeterCase) instruction.getInstructionChoice();
    Assert.assertEquals("Wrong meter id", 5, meterCase.getMeter().getMeterId().intValue());
}
Also used : MeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder) InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) 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) AddFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput) 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) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder) AddFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder) 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) 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) FlowModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder) BigInteger(java.math.BigInteger) ApplyActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase) Test(org.junit.Test)

Example 52 with InstructionsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder in project openflowplugin by opendaylight.

the class FlowUtils method createDirectMacToMacFlow.

/**
 * Returns a {@link FlowBuilder} forwarding all packets to controller port.
 */
public static FlowBuilder createDirectMacToMacFlow(final Short tableId, final int priority, final MacAddress srcMac, final MacAddress dstMac, final NodeConnectorRef dstPort) {
    FlowBuilder macToMacFlow = new FlowBuilder().setTableId(tableId).setFlowName("mac2mac");
    macToMacFlow.setId(new FlowId(Long.toString(macToMacFlow.hashCode())));
    EthernetMatch ethernetMatch = new EthernetMatchBuilder().setEthernetSource(new EthernetSourceBuilder().setAddress(srcMac).build()).setEthernetDestination(new EthernetDestinationBuilder().setAddress(dstMac).build()).build();
    MatchBuilder match = new MatchBuilder();
    match.setEthernetMatch(ethernetMatch);
    Uri outputPort = dstPort.getValue().firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId();
    Action outputToControllerAction = new ActionBuilder().setOrder(0).setAction(new OutputActionCaseBuilder().setOutputAction(new OutputActionBuilder().setMaxLength(Integer.valueOf(0xffff)).setOutputNodeConnector(outputPort).build()).build()).build();
    // Create an Apply Action
    ApplyActions applyActions = new ApplyActionsBuilder().setAction(ImmutableList.of(outputToControllerAction)).build();
    // Wrap our Apply Action in an Instruction
    Instruction applyActionsInstruction = new InstructionBuilder().setOrder(0).setInstruction(new ApplyActionsCaseBuilder().setApplyActions(applyActions).build()).build();
    // Put our Instruction in a list of Instructions
    macToMacFlow.setMatch(new MatchBuilder().setEthernetMatch(ethernetMatch).build()).setInstructions(new InstructionsBuilder().setInstruction(ImmutableList.of(applyActionsInstruction)).build()).setPriority(priority).setBufferId(OFConstants.OFP_NO_BUFFER).setHardTimeout(0).setIdleTimeout(0).setFlags(new FlowModFlags(false, false, false, false, false));
    return macToMacFlow;
}
Also used : OutputActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder) InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder) NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) EthernetDestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder) EthernetMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) EthernetSourceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder) ApplyActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey) ApplyActions(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActions)

Example 53 with InstructionsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder in project openflowplugin by opendaylight.

the class FlowInstructionResponseConvertor method convert.

@Override
public Instructions convert(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction> source, VersionConvertorData data) {
    InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
    List<Instruction> salInstructionList = new ArrayList<>();
    int instructionTreeNodekey = 0;
    org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction salInstruction;
    for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction switchInst : source) {
        if (switchInst.getInstructionChoice() instanceof ApplyActionsCase) {
            ApplyActionsCase actionsInstruction = (ApplyActionsCase) switchInst.getInstructionChoice();
            ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
            ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
            final ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(data.getVersion());
            actionResponseConvertorData.setActionPath(ActionPath.FLOWS_STATISTICS_UPDATE_APPLY_ACTIONS);
            final Optional<List<Action>> actions = getConvertorExecutor().convert(actionsInstruction.getApplyActions().getAction(), actionResponseConvertorData);
            applyActionsBuilder.setAction(FlowConvertorUtil.wrapActionList(actions.orElse(Collections.emptyList())));
            applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
            salInstruction = applyActionsCaseBuilder.build();
        } else if (switchInst.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase) {
            ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
            salInstruction = clearActionsCaseBuilder.build();
        } else if (switchInst.getInstructionChoice() instanceof GotoTableCase) {
            GotoTableCase gotoTableCase = (GotoTableCase) switchInst.getInstructionChoice();
            GoToTableCaseBuilder goToTableCaseBuilder = new GoToTableCaseBuilder();
            GoToTableBuilder goToTableBuilder = new GoToTableBuilder();
            goToTableBuilder.setTableId(gotoTableCase.getGotoTable().getTableId());
            goToTableCaseBuilder.setGoToTable(goToTableBuilder.build());
            salInstruction = goToTableCaseBuilder.build();
        } else if (switchInst.getInstructionChoice() instanceof MeterCase) {
            MeterCase meterIdInstruction = (MeterCase) switchInst.getInstructionChoice();
            MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
            MeterBuilder meterBuilder = new MeterBuilder();
            meterBuilder.setMeterId(new MeterId(meterIdInstruction.getMeter().getMeterId()));
            meterCaseBuilder.setMeter(meterBuilder.build());
            salInstruction = meterCaseBuilder.build();
        } else if (switchInst.getInstructionChoice() instanceof WriteActionsCase) {
            WriteActionsCase writeActionsCase = (WriteActionsCase) switchInst.getInstructionChoice();
            WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
            WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
            final ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(data.getVersion());
            actionResponseConvertorData.setActionPath(ActionPath.FLOWS_STATISTICS_UPDATE_WRITE_ACTIONS);
            final Optional<List<Action>> actions = getConvertorExecutor().convert(writeActionsCase.getWriteActions().getAction(), actionResponseConvertorData);
            writeActionsBuilder.setAction(FlowConvertorUtil.wrapActionList(actions.orElse(Collections.emptyList())));
            writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
            salInstruction = writeActionsCaseBuilder.build();
        } else if (switchInst.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase) {
            org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase writeMetadataCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase) switchInst.getInstructionChoice();
            WriteMetadataCaseBuilder writeMetadataCaseBuilder = new WriteMetadataCaseBuilder();
            WriteMetadataBuilder writeMetadataBuilder = new WriteMetadataBuilder();
            writeMetadataBuilder.setMetadata(new BigInteger(OFConstants.SIGNUM_UNSIGNED, writeMetadataCase.getWriteMetadata().getMetadata()));
            writeMetadataBuilder.setMetadataMask(new BigInteger(OFConstants.SIGNUM_UNSIGNED, writeMetadataCase.getWriteMetadata().getMetadataMask()));
            writeMetadataCaseBuilder.setWriteMetadata(writeMetadataBuilder.build());
            salInstruction = writeMetadataCaseBuilder.build();
        } else {
            continue;
        }
        InstructionBuilder instBuilder = new InstructionBuilder();
        instBuilder.setInstruction(salInstruction);
        instBuilder.setKey(new InstructionKey(instructionTreeNodekey));
        instBuilder.setOrder(instructionTreeNodekey);
        instructionTreeNodekey++;
        salInstructionList.add(instBuilder.build());
    }
    instructionsBuilder.setInstruction(salInstructionList);
    return instructionsBuilder.build();
}
Also used : MeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder) InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder) WriteMetadataCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder) 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) InstructionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) 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) ArrayList(java.util.ArrayList) List(java.util.List) 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) 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) GoToTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder) BigInteger(java.math.BigInteger) ActionResponseConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData) ApplyActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase)

Example 54 with InstructionsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder in project netvirt by opendaylight.

the class OpenFlow13Utils method wrapActionsIntoApplyActionsInstruction.

public static InstructionsBuilder wrapActionsIntoApplyActionsInstruction(List<Action> theActions) {
    // Create an Apply Action
    ApplyActionsBuilder aab = new ApplyActionsBuilder();
    aab.setAction(theActions);
    // Wrap our Apply Action in an Instruction
    InstructionBuilder ib = new InstructionBuilder();
    ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
    ib.setOrder(0);
    ib.setKey(new InstructionKey(0));
    // Put our Instruction in a list of Instructions
    List<Instruction> instructions = new ArrayList<>();
    instructions.add(ib.build());
    return new InstructionsBuilder().setInstruction(instructions);
}
Also used : InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder) NxActionRegMoveNodesNodeTableFlowApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegMoveNodesNodeTableFlowApplyActionsCaseBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder) NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder) NxActionPushNshNodesNodeTableFlowApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionPushNshNodesNodeTableFlowApplyActionsCaseBuilder) NxActionPopNshNodesNodeTableFlowApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionPopNshNodesNodeTableFlowApplyActionsCaseBuilder) ArrayList(java.util.ArrayList) InstructionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) ApplyActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder)

Example 55 with InstructionsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder in project netvirt by opendaylight.

the class OpenFlow13Utils method createFlowBuilder.

public static FlowBuilder createFlowBuilder(final short table, final int priority, final BigInteger cookieValue, final String flowName, final String flowIdStr, MatchBuilder match, InstructionsBuilder isb) {
    FlowBuilder flow = new FlowBuilder();
    flow.setId(new FlowId(flowIdStr));
    flow.setKey(new FlowKey(new FlowId(flowIdStr)));
    flow.setTableId(table);
    flow.setFlowName(flowName);
    flow.setCookie(new FlowCookie(cookieValue));
    flow.setCookieMask(new FlowCookie(cookieValue));
    flow.setContainerName(null);
    flow.setStrict(false);
    flow.setMatch(match.build());
    flow.setInstructions(isb.build());
    flow.setPriority(priority);
    flow.setHardTimeout(0);
    flow.setIdleTimeout(0);
    flow.setFlags(new FlowModFlags(false, false, false, false, false));
    if (null == flow.isBarrier()) {
        flow.setBarrier(Boolean.FALSE);
    }
    return flow;
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) NxAugMatchNodesNodeTableFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) GeneralAugMatchNodesNodeTableFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlowBuilder) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags)

Aggregations

InstructionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder)121 ArrayList (java.util.ArrayList)114 InstructionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder)106 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)102 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)101 ApplyActionsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder)95 ApplyActionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder)94 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)89 DropActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder)82 GroupActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder)82 ControllerActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder)81 DropAction (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction)81 PushMplsActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder)81 PushPbbActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder)81 SetVlanIdActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder)81 OutputActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder)77 FloodAllActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.all.action._case.FloodAllActionBuilder)74 SetDlSrcActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder)74 SetNwDstActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder)74 SetNwSrcActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder)74