Search in sources :

Example 1 with WriteActionsCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase in project genius by opendaylight.

the class FlowBasedServicesUtils method installLPortDispatcherFlow.

public static void installLPortDispatcherFlow(BigInteger dpId, BoundServices boundService, String interfaceName, WriteTransaction writeTransaction, int interfaceTag, short currentServiceIndex, short nextServiceIndex) {
    String serviceRef = boundService.getServiceName();
    List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForDispatcherTable(interfaceTag, currentServiceIndex);
    // Get the metadata and mask from the service's write metadata
    // instruction
    StypeOpenflow stypeOpenFlow = boundService.getAugmentation(StypeOpenflow.class);
    List<Instruction> serviceInstructions = stypeOpenFlow.getInstruction();
    int instructionSize = serviceInstructions != null ? serviceInstructions.size() : 0;
    BigInteger[] metadataValues = IfmUtil.mergeOpenflowMetadataWriteInstructions(serviceInstructions);
    BigInteger metadata = MetaDataUtil.getMetaDataForLPortDispatcher(interfaceTag, nextServiceIndex, metadataValues[0]);
    BigInteger metadataMask = MetaDataUtil.getWriteMetaDataMaskForDispatcherTable();
    // build the final instruction for LPort Dispatcher table flow entry
    List<Instruction> instructions = new ArrayList<>();
    instructions.add(MDSALUtil.buildAndGetWriteMetadaInstruction(metadata, metadataMask, ++instructionSize));
    if (serviceInstructions != null && !serviceInstructions.isEmpty()) {
        for (Instruction info : serviceInstructions) {
            // Skip meta data write as that is handled already
            if (info.getInstruction() instanceof WriteMetadataCase) {
                continue;
            } else if (info.getInstruction() instanceof WriteActionsCase) {
                info = MDSALUtil.buildWriteActionsInstruction(ActionConverterUtil.convertServiceActionToFlowAction(((WriteActionsCase) info.getInstruction()).getWriteActions().getAction()));
            } else if (info.getInstruction() instanceof ApplyActionsCase) {
                info = MDSALUtil.buildApplyActionsInstruction(ActionConverterUtil.convertServiceActionToFlowAction(((ApplyActionsCase) info.getInstruction()).getApplyActions().getAction()));
            }
            instructions.add(info);
        }
    }
    // build the flow and install it
    String flowRef = getFlowRef(dpId, NwConstants.LPORT_DISPATCHER_TABLE, interfaceName, currentServiceIndex);
    Flow ingressFlow = MDSALUtil.buildFlowNew(NwConstants.LPORT_DISPATCHER_TABLE, flowRef, DEFAULT_DISPATCHER_PRIORITY, serviceRef, 0, 0, stypeOpenFlow.getFlowCookie(), matches, instructions);
    LOG.debug("Installing LPort Dispatcher Flow on DPN {}, for interface {}, with flowRef {}", dpId, interfaceName, flowRef);
    installFlow(dpId, ingressFlow, writeTransaction);
}
Also used : WriteMetadataCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase) StypeOpenflow(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.StypeOpenflow) ArrayList(java.util.ArrayList) WriteActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) BigInteger(java.math.BigInteger) ApplyActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase)

Example 2 with WriteActionsCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase in project genius by opendaylight.

the class MDSALUtil method buildWriteActionsInstruction.

/**
 * Build write actions instruction with the given actions and key.
 *
 * @param actions the actions.
 * @param instructionKey the instruction key.
 * @return the instruction.
 */
public static Instruction buildWriteActionsInstruction(List<Action> actions, int instructionKey) {
    WriteActions writeActions = new WriteActionsBuilder().setAction(actions).build();
    WriteActionsCase writeActionsCase = new WriteActionsCaseBuilder().setWriteActions(writeActions).build();
    InstructionBuilder instructionBuilder = new InstructionBuilder();
    instructionBuilder.setInstruction(writeActionsCase);
    instructionBuilder.setKey(new InstructionKey(instructionKey));
    return instructionBuilder.build();
}
Also used : InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder) 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) WriteActions(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActions) WriteActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase) InstructionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey)

Example 3 with WriteActionsCase

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

the class TableFeaturesConvertor method setInstructionTableFeatureProperty.

private static void setInstructionTableFeatureProperty(final TableFeaturePropertiesBuilder builder, final TableFeaturesPropType type, final List<Instruction> instructionList) {
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction> instructionTypeList = new ArrayList<>();
    for (Instruction currInstruction : instructionList) {
        InstructionBuilder instructionType = new InstructionBuilder();
        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction instruction = currInstruction.getInstruction();
        if (instruction instanceof GoToTableCase) {
            GotoTableCaseBuilder goToTableCaseBuilder = new GotoTableCaseBuilder();
            instructionType.setInstructionChoice(goToTableCaseBuilder.build());
        } else if (instruction instanceof WriteMetadataCase) {
            WriteMetadataCaseBuilder writeMetadataCaseBuilder = new WriteMetadataCaseBuilder();
            instructionType.setInstructionChoice(writeMetadataCaseBuilder.build());
        } else if (instruction instanceof WriteActionsCase) {
            WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
            instructionType.setInstructionChoice(writeActionsCaseBuilder.build());
        } else if (instruction instanceof ApplyActionsCase) {
            ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
            instructionType.setInstructionChoice(applyActionsCaseBuilder.build());
        } else if (instruction instanceof ClearActionsCase) {
            ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
            instructionType.setInstructionChoice(clearActionsCaseBuilder.build());
        } else if (instruction instanceof MeterCase) {
            MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
            instructionType.setInstructionChoice(meterCaseBuilder.build());
        }
        // TODO: Experimenter instructions are unhandled
        instructionTypeList.add(instructionType.build());
    }
    InstructionRelatedTableFeaturePropertyBuilder propBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
    propBuilder.setInstruction(instructionTypeList);
    builder.setType(type);
    builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, propBuilder.build());
}
Also used : InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder) WriteMetadataCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder) WriteMetadataCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase) MeterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCase) ArrayList(java.util.ArrayList) GotoTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder) WriteActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) InstructionRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder) GoToTableCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCase) ClearActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder) MeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder) WriteActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder) ClearActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCase) ApplyActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase)

Example 4 with WriteActionsCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase 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 5 with WriteActionsCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase 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)

Aggregations

WriteActionsCase (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase)8 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)8 ArrayList (java.util.ArrayList)7 WriteActionsCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase)6 BigInteger (java.math.BigInteger)5 Test (org.junit.Test)5 ApplyActionsCase (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase)5 ApplyActionsCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase)5 GotoTableCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase)5 MeterCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase)5 ByteBuf (io.netty.buffer.ByteBuf)4 WriteActionsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCaseBuilder)4 WriteMetadataCase (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase)4 WriteActionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActionsBuilder)4 WriteMetadataCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase)4 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)3 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)3 ApplyActionsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder)3 ClearActionsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder)3 GoToTableCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder)3