Search in sources :

Example 96 with Action

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

the class BroadCastDiscoveryRuleGeneratorTest method checkGroupInstructions.

private void checkGroupInstructions(Instructions instructions, MeterId meterId, GroupId groupId) {
    assertEquals(1, instructions.getApplyActions().size());
    Action action = instructions.getApplyActions().get(0);
    checkGroupAction(action, groupId);
    assertNull(instructions.getWriteActions());
    assertEquals(instructions.getGoToMeter(), meterId);
    assertNull(instructions.getGoToTable());
}
Also used : MeterAction(org.openkilda.rulemanager.action.MeterAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction)

Example 97 with Action

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

the class BroadCastDiscoveryRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    List<SpeakerData> commands = new ArrayList<>();
    List<Action> actions = new ArrayList<>();
    Instructions instructions = Instructions.builder().applyActions(actions).build();
    FlowSpeakerData flowCommand = buildRule(sw, instructions);
    commands.add(flowCommand);
    MeterId meterId = createMeterIdForDefaultRule(VERIFICATION_BROADCAST_RULE_COOKIE);
    SpeakerData meterCommand = generateMeterCommandForServiceRule(sw, meterId, config.getBroadcastRateLimit(), config.getSystemMeterBurstSizeInPackets(), config.getDiscoPacketSize());
    if (meterCommand != null) {
        commands.add(meterCommand);
        addMeterToInstructions(meterId, sw, instructions);
    }
    GroupSpeakerData groupCommand = null;
    if (sw.getFeatures().contains(SwitchFeature.GROUP_PACKET_OUT_CONTROLLER)) {
        groupCommand = getRoundTripLatencyGroup(sw);
        actions.add(new GroupAction(groupCommand.getGroupId()));
        commands.add(groupCommand);
    } else {
        actions.add(new PortOutAction(new PortNumber(SpecialPortType.CONTROLLER)));
    }
    if (meterCommand != null) {
        flowCommand.getDependsOn().add(meterCommand.getUuid());
    }
    if (groupCommand != null) {
        flowCommand.getDependsOn().add(groupCommand.getUuid());
    }
    return commands;
}
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) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) ArrayList(java.util.ArrayList) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) Instructions(org.openkilda.rulemanager.Instructions) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) MeterId(org.openkilda.model.MeterId)

Example 98 with Action

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

the class MeteredServiceRuleGenerator method buildSendToControllerInstructions.

protected static Instructions buildSendToControllerInstructions() {
    List<Action> actions = new ArrayList<>();
    actions.add(new PortOutAction(new PortNumber(SpecialPortType.CONTROLLER)));
    return Instructions.builder().applyActions(actions).build();
}
Also used : Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) ArrayList(java.util.ArrayList) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Example 99 with Action

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

the class UnicastVerificationVxlanRuleGenerator method buildUnicastVerificationRuleVxlan.

private FlowSpeakerData buildUnicastVerificationRuleVxlan(Switch sw, Cookie cookie) {
    List<Action> actions = new ArrayList<>();
    if (sw.getFeatures().contains(NOVIFLOW_PUSH_POP_VXLAN)) {
        actions.add(new PopVxlanAction(ActionType.POP_VXLAN_NOVIFLOW));
    } else {
        actions.add(new PopVxlanAction(ActionType.POP_VXLAN_OVS));
    }
    actions.add(new PortOutAction(new PortNumber(SpecialPortType.CONTROLLER)));
    // todo remove unnecessary action
    actions.add(SetFieldAction.builder().field(ETH_DST).value(sw.getSwitchId().toLong()).build());
    Instructions instructions = Instructions.builder().applyActions(actions).build();
    long ethSrc = new SwitchId(config.getFlowPingMagicSrcMacAddress()).toLong();
    Set<FieldMatch> match = Sets.newHashSet(FieldMatch.builder().field(ETH_SRC).value(ethSrc).mask(NO_MASK).build(), FieldMatch.builder().field(ETH_DST).value(sw.getSwitchId().toLong()).mask(NO_MASK).build(), FieldMatch.builder().field(ETH_TYPE).value(EthType.IPv4).build(), FieldMatch.builder().field(IP_PROTO).value(IpProto.UDP).build(), FieldMatch.builder().field(UDP_SRC).value(STUB_VXLAN_UDP_SRC).build());
    return FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(cookie).table(OfTable.INPUT).priority(VERIFICATION_RULE_VXLAN_PRIORITY).match(match).instructions(instructions).build();
}
Also used : Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) ArrayList(java.util.ArrayList) Instructions(org.openkilda.rulemanager.Instructions) SwitchId(org.openkilda.model.SwitchId) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Example 100 with Action

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

the class MultiTableIngressRuleGenerator method buildFlowIngressCommand.

private FlowSpeakerData buildFlowIngressCommand(Switch sw, FlowEndpoint ingressEndpoint) {
    // TODO should we check if switch supports encapsulation?
    List<Action> actions = new ArrayList<>(buildTransformActions(ingressEndpoint.getInnerVlanId(), sw.getFeatures()));
    actions.add(new PortOutAction(getOutPort(flowPath, flow)));
    FlowSpeakerDataBuilder<?, ?> builder = FlowSpeakerData.builder().switchId(ingressEndpoint.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(flowPath.getCookie()).table(OfTable.INGRESS).priority(getPriority(ingressEndpoint)).match(buildIngressMatch(ingressEndpoint, sw.getFeatures())).instructions(buildInstructions(sw, actions));
    if (sw.getFeatures().contains(SwitchFeature.RESET_COUNTS_FLAG)) {
        builder.flags(Sets.newHashSet(OfFlowFlag.RESET_COUNTERS));
    }
    return builder.build();
}
Also used : Action(org.openkilda.rulemanager.action.Action) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) ArrayList(java.util.ArrayList)

Aggregations

Action (org.openkilda.rulemanager.action.Action)196 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)195 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)168 Test (org.junit.Test)151 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)149 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)146 Flow (org.openkilda.model.Flow)136 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)117 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)67 SpeakerData (org.openkilda.rulemanager.SpeakerData)67 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)59 GroupAction (org.openkilda.rulemanager.action.GroupAction)55 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)47 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)46 Instructions (org.openkilda.rulemanager.Instructions)34 ArrayList (java.util.ArrayList)29 FlowPath (org.openkilda.model.FlowPath)27 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)23 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)21 CopyFieldAction (org.openkilda.rulemanager.action.noviflow.CopyFieldAction)20