Search in sources :

Example 1 with SetFieldAction

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

the class BroadCastDiscoveryRuleGeneratorTest method checkGroupCommand.

private void checkGroupCommand(GroupSpeakerData groupCommandData) {
    assertEquals(GroupId.ROUND_TRIP_LATENCY_GROUP_ID, groupCommandData.getGroupId());
    assertEquals(GroupType.ALL, groupCommandData.getType());
    List<Bucket> buckets = groupCommandData.getBuckets();
    assertEquals(2, buckets.size());
    Bucket first = buckets.get(0);
    assertEquals(2, first.getWriteActions().size());
    SetFieldAction setEthDstAction = getActionByType(SetFieldAction.class, first.getWriteActions());
    assertEquals(Field.ETH_DST, setEthDstAction.getField());
    assertEquals(sw.getSwitchId().toLong(), setEthDstAction.getValue());
    PortOutAction sendToControllerAction = getActionByType(PortOutAction.class, first.getWriteActions());
    assertEquals(SpecialPortType.CONTROLLER, sendToControllerAction.getPortNumber().getPortType());
    Bucket second = buckets.get(1);
    assertEquals(2, second.getWriteActions().size());
    SetFieldAction setUdpDstAction = getActionByType(SetFieldAction.class, second.getWriteActions());
    assertEquals(Field.UDP_DST, setUdpDstAction.getField());
    assertEquals(LATENCY_PACKET_UDP_PORT, setUdpDstAction.getValue());
    PortOutAction sendToPortInAction = getActionByType(PortOutAction.class, second.getWriteActions());
    assertEquals(SpecialPortType.IN_PORT, sendToPortInAction.getPortNumber().getPortType());
}
Also used : Bucket(org.openkilda.rulemanager.group.Bucket) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction)

Example 2 with SetFieldAction

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

the class UniCastDiscoveryRuleGeneratorTest method checkSetFieldAction.

private void checkSetFieldAction(Action action) {
    assertTrue(action instanceof SetFieldAction);
    SetFieldAction setFieldAction = (SetFieldAction) action;
    assertEquals(Field.ETH_DST, setFieldAction.getField());
    assertEquals(sw.getSwitchId().toLong(), setFieldAction.getValue());
}
Also used : SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction)

Example 3 with SetFieldAction

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

the class GroupEntryConverter method addAction.

private void addAction(BucketEntryBuilder builder, Action action) {
    switch(action.getType()) {
        case PORT_OUT:
            PortOutAction portOutAction = (PortOutAction) action;
            builder.port(convertPortNumber(portOutAction.getPortNumber()));
            return;
        case SET_FIELD:
            SetFieldAction setFieldAction = (SetFieldAction) action;
            if (setFieldAction.getField() == Field.VLAN_VID) {
                builder.vlan((int) setFieldAction.getValue());
            }
            return;
        case PUSH_VXLAN_NOVIFLOW:
        case PUSH_VXLAN_OVS:
            PushVxlanAction pushVxlanAction = (PushVxlanAction) action;
            builder.vni(pushVxlanAction.getVni());
            return;
        default:
    }
}
Also used : PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction)

Example 4 with SetFieldAction

use of org.openkilda.rulemanager.action.SetFieldAction 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

SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)4 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)3 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)2 FlowCopyFieldAction (org.openkilda.messaging.info.rule.FlowCopyFieldAction)1 FlowSetFieldAction (org.openkilda.messaging.info.rule.FlowSetFieldAction)1 FlowSwapFieldAction (org.openkilda.messaging.info.rule.FlowSwapFieldAction)1 GroupAction (org.openkilda.rulemanager.action.GroupAction)1 MeterAction (org.openkilda.rulemanager.action.MeterAction)1 SwapFieldAction (org.openkilda.rulemanager.action.SwapFieldAction)1 CopyFieldAction (org.openkilda.rulemanager.action.noviflow.CopyFieldAction)1 Bucket (org.openkilda.rulemanager.group.Bucket)1