use of org.openkilda.rulemanager.action.PortOutAction in project open-kilda by telstra.
the class OfGroupConverterTest method testConvertToGroupSpeakerData.
@Test
public void testConvertToGroupSpeakerData() {
OFFactoryVer13 factory = new OFFactoryVer13();
Builder builder = factory.buildGroupDescStatsReply();
List<OFGroupDescStatsEntry> entries = new ArrayList<>();
entries.add(getOfGroupEntry(factory));
builder.setEntries(entries);
List<GroupSpeakerData> groupSpeakerDataList = OfGroupConverter.INSTANCE.convertToGroupSpeakerData(builder.build());
assertEquals(1, groupSpeakerDataList.size());
GroupSpeakerData groupSpeakerData = groupSpeakerDataList.get(0);
assertEquals(new GroupId(GROUP_ID), groupSpeakerData.getGroupId());
assertEquals(GroupType.ALL, groupSpeakerData.getType());
List<Bucket> buckets = groupSpeakerData.getBuckets();
Set<Bucket> expectedBuckets = new HashSet<>();
expectedBuckets.add(Bucket.builder().watchPort(WatchPort.ANY).watchGroup(WatchGroup.ALL).writeActions(Sets.newHashSet(new PortOutAction(new PortNumber(2, null)))).build());
expectedBuckets.add(Bucket.builder().watchPort(WatchPort.ANY).watchGroup(WatchGroup.ALL).writeActions(Sets.newHashSet(new PortOutAction(new PortNumber(1, null)))).build());
assertEquals(expectedBuckets, new HashSet<>(buckets));
}
use of org.openkilda.rulemanager.action.PortOutAction in project open-kilda by telstra.
the class MultiTableIngressYRuleGenerator method buildFlowIngressCommand.
private FlowSpeakerData buildFlowIngressCommand(Switch sw, FlowEndpoint ingressEndpoint) {
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().toBuilder().yFlow(true).build()).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();
}
use of org.openkilda.rulemanager.action.PortOutAction in project open-kilda by telstra.
the class SingleTableIngressRuleGenerator method buildFlowIngressCommand.
private FlowSpeakerData buildFlowIngressCommand(Switch sw, FlowEndpoint ingressEndpoint) {
List<Action> actions = new ArrayList<>();
Instructions instructions = Instructions.builder().applyActions(actions).build();
// TODO should we check if switch supports encapsulation?
actions.addAll(buildTransformActions(ingressEndpoint.getOuterVlanId(), sw.getFeatures()));
actions.add(new PortOutAction(getOutPort(flowPath, flow)));
addMeterToInstructions(flowPath.getMeterId(), sw, instructions);
FlowSpeakerDataBuilder<?, ?> builder = FlowSpeakerData.builder().switchId(ingressEndpoint.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(flowPath.getCookie()).table(OfTable.INPUT).priority(isFullPortEndpoint(ingressEndpoint) ? Constants.Priority.DEFAULT_FLOW_PRIORITY : Constants.Priority.FLOW_PRIORITY).match(buildMatch(ingressEndpoint, sw.getFeatures())).instructions(instructions);
if (sw.getFeatures().contains(SwitchFeature.RESET_COUNTS_FLAG)) {
builder.flags(Sets.newHashSet(OfFlowFlag.RESET_COUNTERS));
}
return builder.build();
}
use of org.openkilda.rulemanager.action.PortOutAction in project open-kilda by telstra.
the class FlowLoopTransitRuleGenerator method buildInstructions.
private Instructions buildInstructions(SwitchId switchId) {
List<Action> applyActions = new ArrayList<>();
if (FlowEncapsulationType.VXLAN.equals(encapsulation.getType())) {
// After turning of VXLAN packet we must update eth_dst header because egress rule on the last switch
// will match the packet by this field.
applyActions.add(SetFieldAction.builder().field(ETH_SRC).value(switchId.toMacAddressAsLong()).build());
applyActions.add(SetFieldAction.builder().field(ETH_DST).value(flowPath.getSrcSwitchId().toMacAddressAsLong()).build());
}
applyActions.add(new PortOutAction(new PortNumber(SpecialPortType.IN_PORT)));
return Instructions.builder().applyActions(applyActions).build();
}
use of org.openkilda.rulemanager.action.PortOutAction in project open-kilda by telstra.
the class RoundTripLatencyRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
if (!sw.getFeatures().contains(NOVIFLOW_COPY_FIELD)) {
return Collections.emptyList();
}
Set<FieldMatch> match = roundTripLatencyRuleMatch(sw);
List<Action> actions = ImmutableList.of(actionAddRxTimestamp(), new PortOutAction(new PortNumber(SpecialPortType.CONTROLLER)));
Instructions instructions = Instructions.builder().applyActions(actions).build();
return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(new Cookie(ROUND_TRIP_LATENCY_RULE_COOKIE)).table(OfTable.INPUT).priority(ROUND_TRIP_LATENCY_RULE_PRIORITY).match(match).instructions(instructions).build());
}
Aggregations