Search in sources :

Example 46 with GroupAction

use of org.openkilda.rulemanager.action.GroupAction in project open-kilda by telstra.

the class EgressMirrorRuleGeneratorTest method buildVxlanMultiTableOuterInnerVlanEgressMirrorRuleTest.

@Test
public void buildVxlanMultiTableOuterInnerVlanEgressMirrorRuleTest() {
    FlowPath path = buildPathWithMirror(true);
    Flow flow = buildFlow(path, OUTER_VLAN_ID, INNER_VLAN_ID);
    EgressMirrorRuleGenerator generator = buildGenerator(path, flow, VXLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_2);
    assertEquals(2, commands.size());
    FlowSpeakerData egressCommand = getCommand(FlowSpeakerData.class, commands);
    GroupSpeakerData groupCommand = getCommand(GroupSpeakerData.class, commands);
    ArrayList<Action> expectedApplyActions = Lists.newArrayList(new PopVxlanAction(ActionType.POP_VXLAN_NOVIFLOW), new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(INNER_VLAN_ID).build(), new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID).build(), new GroupAction(GROUP_ID));
    assertEgressCommand(egressCommand, OfTable.EGRESS, VXLAN_ENCAPSULATION, expectedApplyActions, groupCommand.getUuid());
    assertGroupCommand(groupCommand);
}
Also used : GroupAction(org.openkilda.rulemanager.action.GroupAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) FlowPath(org.openkilda.model.FlowPath) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 47 with GroupAction

use of org.openkilda.rulemanager.action.GroupAction in project open-kilda by telstra.

the class EgressMirrorRuleGeneratorTest method buildVlanMultiTableOuterVlanEgressMirrorRuleTest.

@Test
public void buildVlanMultiTableOuterVlanEgressMirrorRuleTest() {
    FlowPath path = buildPathWithMirror(true);
    Flow flow = buildFlow(path, OUTER_VLAN_ID, 0);
    EgressMirrorRuleGenerator generator = buildGenerator(path, flow, VLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_2);
    assertEquals(2, commands.size());
    FlowSpeakerData egressCommand = getCommand(FlowSpeakerData.class, commands);
    GroupSpeakerData groupCommand = getCommand(GroupSpeakerData.class, commands);
    ArrayList<Action> expectedApplyActions = Lists.newArrayList(SetFieldAction.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID).build(), new GroupAction(GROUP_ID));
    assertEgressCommand(egressCommand, OfTable.EGRESS, VLAN_ENCAPSULATION, expectedApplyActions, groupCommand.getUuid());
    assertGroupCommand(groupCommand);
}
Also used : GroupAction(org.openkilda.rulemanager.action.GroupAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) FlowPath(org.openkilda.model.FlowPath) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 48 with GroupAction

use of org.openkilda.rulemanager.action.GroupAction in project open-kilda by telstra.

the class IngressMirrorRuleGenerator method buildIngressActions.

@VisibleForTesting
List<Action> buildIngressActions(FlowEndpoint ingressEndpoint, GroupId groupId) {
    List<Integer> currentStack;
    if (multiTable) {
        currentStack = makeVlanStack(ingressEndpoint.getInnerVlanId());
    } else {
        currentStack = makeVlanStack(ingressEndpoint.getOuterVlanId());
    }
    List<Integer> targetStack;
    if (flowPath.isOneSwitchFlow()) {
        targetStack = FlowSideAdapter.makeEgressAdapter(flow, flowPath).getEndpoint().getVlanStack();
    } else {
        targetStack = new ArrayList<>();
    }
    List<Action> actions = new ArrayList<>(Utils.makeVlanReplaceActions(currentStack, targetStack));
    actions.add(new GroupAction(groupId));
    return actions;
}
Also used : GroupAction(org.openkilda.rulemanager.action.GroupAction) Action(org.openkilda.rulemanager.action.Action) GroupAction(org.openkilda.rulemanager.action.GroupAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) ArrayList(java.util.ArrayList) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 49 with GroupAction

use of org.openkilda.rulemanager.action.GroupAction in project open-kilda by telstra.

the class FlowEntryConverter method addAction.

private void addAction(FlowApplyActionsBuilder builder, Action action) {
    switch(action.getType()) {
        case GROUP:
            GroupAction groupAction = (GroupAction) action;
            builder.group(String.valueOf(groupAction.getGroupId().getValue()));
            return;
        case PORT_OUT:
            PortOutAction portOutAction = (PortOutAction) action;
            builder.flowOutput(portOutAction.getPortNumber().toString());
            return;
        case POP_VLAN:
            builder.popVlan("");
            return;
        case PUSH_VLAN:
            builder.pushVlan("");
            return;
        case POP_VXLAN_NOVIFLOW:
        case POP_VXLAN_OVS:
            // todo handle pop vxlan
            return;
        case PUSH_VXLAN_NOVIFLOW:
        case PUSH_VXLAN_OVS:
            PushVxlanAction pushVxlanAction = (PushVxlanAction) action;
            builder.pushVxlan(String.valueOf(pushVxlanAction.getVni()));
            return;
        case METER:
            MeterAction meterAction = (MeterAction) action;
            builder.meter(String.valueOf(meterAction.getMeterId().getValue()));
            return;
        case NOVI_COPY_FIELD:
            CopyFieldAction copyFieldAction = (CopyFieldAction) action;
            builder.copyFieldAction(FlowCopyFieldAction.builder().bits(String.valueOf(copyFieldAction.getNumberOfBits())).srcOffset(String.valueOf(copyFieldAction.getSrcOffset())).dstOffset(String.valueOf(copyFieldAction.getDstOffset())).srcOxm(copyFieldAction.getOxmSrcHeader().toString()).dstOxm(copyFieldAction.getOxmDstHeader().toString()).build());
            return;
        case NOVI_SWAP_FIELD:
        case KILDA_SWAP_FIELD:
            SwapFieldAction swapFieldAction = (SwapFieldAction) action;
            builder.swapFieldAction(FlowSwapFieldAction.builder().bits(String.valueOf(swapFieldAction.getNumberOfBits())).srcOffset(String.valueOf(swapFieldAction.getSrcOffset())).dstOffset(String.valueOf(swapFieldAction.getDstOffset())).srcOxm(swapFieldAction.getOxmSrcHeader().toString()).dstOxm(swapFieldAction.getOxmDstHeader().toString()).build());
            return;
        case SET_FIELD:
            SetFieldAction setFieldAction = (SetFieldAction) action;
            builder.setFieldAction(FlowSetFieldAction.builder().fieldName(setFieldAction.getField().toString()).fieldValue(String.valueOf(setFieldAction.getValue())).build());
            return;
        default:
            throw new IllegalStateException(format("Unknown action type %s", action.getType()));
    }
}
Also used : GroupAction(org.openkilda.rulemanager.action.GroupAction) FlowCopyFieldAction(org.openkilda.messaging.info.rule.FlowCopyFieldAction) CopyFieldAction(org.openkilda.rulemanager.action.noviflow.CopyFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) MeterAction(org.openkilda.rulemanager.action.MeterAction) SwapFieldAction(org.openkilda.rulemanager.action.SwapFieldAction) FlowSwapFieldAction(org.openkilda.messaging.info.rule.FlowSwapFieldAction) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) FlowSetFieldAction(org.openkilda.messaging.info.rule.FlowSetFieldAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction)

Aggregations

GroupAction (org.openkilda.rulemanager.action.GroupAction)49 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)48 Action (org.openkilda.rulemanager.action.Action)46 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)45 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)44 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)44 Test (org.junit.Test)41 Flow (org.openkilda.model.Flow)41 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)31 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)18 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)18 SpeakerData (org.openkilda.rulemanager.SpeakerData)18 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)16 FlowPath (org.openkilda.model.FlowPath)13 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)7 ArrayList (java.util.ArrayList)4 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)4 MeterAction (org.openkilda.rulemanager.action.MeterAction)3 CopyFieldAction (org.openkilda.rulemanager.action.noviflow.CopyFieldAction)3 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)2