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());
}
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;
}
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();
}
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();
}
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();
}
Aggregations