Search in sources :

Example 11 with PushVlanActionBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder in project openflowplugin by opendaylight.

the class SalToOfPushVlanActionCase method process.

@Nonnull
@Override
public Optional<Action> process(@Nonnull final PushVlanActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
    PushVlanAction pushVlanAction = source.getPushVlanAction();
    PushVlanCaseBuilder pushVlanCaseBuilder = new PushVlanCaseBuilder();
    PushVlanActionBuilder pushVlanBuilder = new PushVlanActionBuilder();
    if (pushVlanAction.getEthernetType() != null) {
        pushVlanBuilder.setEthertype(new EtherType(pushVlanAction.getEthernetType()));
    }
    pushVlanCaseBuilder.setPushVlanAction(pushVlanBuilder.build());
    return Optional.of(new ActionBuilder().setActionChoice(pushVlanCaseBuilder.build()).build());
}
Also used : PushVlanCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) PushVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder) PushVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder) PushVlanAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanAction) EtherType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType) Nonnull(javax.annotation.Nonnull)

Example 12 with PushVlanActionBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder in project openflowplugin by opendaylight.

the class FlowConvertor method injectPushActionToInstruction.

private static List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> injectPushActionToInstruction(final Flow sourceFlow) {
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> srcInstructionList = sourceFlow.getInstructions().getInstruction();
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> targetInstructionList = new ArrayList<>(srcInstructionList.size());
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> targetActionList = new ArrayList<>();
    org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder instructionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder();
    for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction srcInstruction : srcInstructionList) {
        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curSrcInstruction = srcInstruction.getInstruction();
        if (curSrcInstruction instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) {
            org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase applyActionscase = (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) curSrcInstruction;
            ApplyActions applyActions = applyActionscase.getApplyActions();
            List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> srcActionList = applyActions.getAction();
            int offset = 0;
            for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action actionItem : srcActionList) {
                if (actionItem.getAction() instanceof SetVlanIdActionCase) {
                    SetVlanIdActionCase setVlanIdActionCase = (SetVlanIdActionCase) actionItem.getAction();
                    PushVlanActionCaseBuilder pushVlanActionCaseBuilder = new PushVlanActionCaseBuilder();
                    PushVlanActionBuilder pushVlanActionBuilder = new PushVlanActionBuilder();
                    pushVlanActionBuilder.setCfi(new VlanCfi(1)).setVlanId(setVlanIdActionCase.getSetVlanIdAction().getVlanId()).setEthernetType(PUSH_VLAN).setTag(PUSH_VLAN);
                    pushVlanActionCaseBuilder.setPushVlanAction(pushVlanActionBuilder.build());
                    PushVlanActionCase injectedAction = pushVlanActionCaseBuilder.build();
                    ActionBuilder actionBuilder = new ActionBuilder();
                    actionBuilder.setAction(injectedAction).setKey(actionItem.getKey()).setOrder(actionItem.getOrder() + offset);
                    targetActionList.add(actionBuilder.build());
                    offset++;
                }
                if (offset > 0) {
                    // we need to increment the order for all the actions added after injection
                    ActionBuilder actionBuilder = new ActionBuilder(actionItem);
                    actionBuilder.setOrder(actionItem.getOrder() + offset);
                    actionItem = actionBuilder.build();
                }
                targetActionList.add(actionItem);
            }
            ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
            ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
            applyActionsBuilder.setAction(targetActionList);
            applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
            instructionBuilder.setInstruction(applyActionsCaseBuilder.build());
        } else {
            instructionBuilder.setInstruction(curSrcInstruction);
        }
        instructionBuilder.setKey(srcInstruction.getKey()).setOrder(srcInstruction.getOrder());
        targetInstructionList.add(instructionBuilder.build());
    }
    return targetInstructionList;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) PushVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder) ArrayList(java.util.ArrayList) PushVlanActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction) VlanCfi(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.VlanCfi) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder) PushVlanActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder) ApplyActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder) ApplyActions(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActions) SetVlanIdActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase) PushVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder) ApplyActionsCase(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.cases.ApplyActionsCase)

Example 13 with PushVlanActionBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder in project openflowplugin by opendaylight.

the class PacketOutInputMessageFactoryTest method createAction.

private List<Action> createAction() {
    final List<Action> actions = new ArrayList<>();
    ActionBuilder actionBuilder = new ActionBuilder();
    PushVlanCaseBuilder pushVlanCaseBuilder = new PushVlanCaseBuilder();
    PushVlanActionBuilder pushVlanBuilder = new PushVlanActionBuilder();
    pushVlanBuilder.setEthertype(new EtherType(new EtherType(25)));
    pushVlanCaseBuilder.setPushVlanAction(pushVlanBuilder.build());
    actionBuilder.setActionChoice(pushVlanCaseBuilder.build());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(new PopVlanCaseBuilder().build());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(new PopVlanCaseBuilder().build());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(new PopVlanCaseBuilder().build());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(new PopVlanCaseBuilder().build());
    actions.add(actionBuilder.build());
    return actions;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) PushVlanCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) PushVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder) PushVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder) PopVlanCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCaseBuilder) ArrayList(java.util.ArrayList) EtherType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType)

Example 14 with PushVlanActionBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder in project openflowplugin by opendaylight.

the class PushVlanActionSerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final int ethType = 10;
    final Action action = new PushVlanActionCaseBuilder().setPushVlanAction(new PushVlanActionBuilder().setEthernetType(ethType).build()).build();
    assertAction(action, out -> {
        assertEquals(out.readUnsignedShort(), ethType);
        out.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);
    });
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action) PushVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder) PushVlanActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder) Test(org.junit.Test)

Example 15 with PushVlanActionBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder in project openflowplugin by opendaylight.

the class OpenflowPluginBulkGroupTransactionProvider method createPushVlanAction.

private List<Action> createPushVlanAction() {
    PushVlanActionBuilder vlan = new PushVlanActionBuilder();
    vlan.setEthernetType(0x8100);
    VlanId vlanId = new VlanId(2);
    vlan.setVlanId(vlanId);
    ActionBuilder action = new ActionBuilder();
    action.setAction(new PushVlanActionCaseBuilder().setPushVlanAction(vlan.build()).build());
    List<Action> actions = new ArrayList<>();
    actions.add(action.build());
    return actions;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) DropAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction) ControllerActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder) SetVlanIdActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder) PushVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder) PopPbbActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder) DropActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder) GroupActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder) PushMplsActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder) PopVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder) PushPbbActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder) PopMplsActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder) PushVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder) ArrayList(java.util.ArrayList) PushVlanActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId)

Aggregations

ArrayList (java.util.ArrayList)12 PushVlanCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder)10 PushVlanActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder)9 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)9 EtherType (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType)9 PushVlanActionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder)8 PushVlanActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder)8 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)8 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)5 PopVlanCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCaseBuilder)5 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)5 Test (org.junit.Test)4 GroupActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder)4 PopMplsActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder)4 PopPbbActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder)4 PopVlanActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder)4 PushMplsActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder)4 PushPbbActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder)4 OutputActionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder)4 PopPbbCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder)4