use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class OneSwitchFlowInstallFlowModFactoryTest method makeForwardingMessage.
// --- service methods
private OFFlowAdd makeForwardingMessage(OneSwitchFlowInstallCommand command, int priorityOffset, Match match, TableId tableId, List<Integer> vlanStack) {
List<OFAction> applyActions = new ArrayList<>();
List<OFInstruction> instructions = new ArrayList<>();
if (command.getMeterConfig() != null) {
OfAdapter.INSTANCE.makeMeterCall(of, command.getMeterConfig().getId(), applyActions, instructions);
}
applyActions.addAll(OfAdapter.INSTANCE.makeVlanReplaceActions(of, vlanStack, command.getEgressEndpoint().getVlanStack()));
FlowEndpoint ingress = command.getEndpoint();
FlowEndpoint egress = command.getEgressEndpoint();
OFPort outPort = ingress.getPortNumber() == egress.getPortNumber() ? OFPort.IN_PORT : OFPort.of(egress.getPortNumber());
applyActions.add(of.actions().buildOutput().setPort(outPort).build());
instructions.add(of.instructions().applyActions(applyActions));
getGoToTableInstruction().ifPresent(instructions::add);
getWriteMetadataInstruction().ifPresent(instructions::add);
return of.buildFlowAdd().setTableId(tableId).setPriority(OneSwitchFlowInstallCommand.FLOW_PRIORITY + priorityOffset).setCookie(U64.of(command.getCookie().getValue())).setMatch(match).setInstructions(instructions).build();
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class OneSwitchFlowInstallFlowModFactoryTest method testMakeDoubleVlanForwardMessageVlanEncoded.
private void testMakeDoubleVlanForwardMessageVlanEncoded(MeterConfig meter) {
OneSwitchFlowInstallCommand command = makeCommand(endpointDoubleVlan, egressEndpointDoubleVlan, meter);
FlowEndpoint endpoint = command.getEndpoint();
RoutingMetadata metadata = RoutingMetadata.builder().outerVlanId(endpoint.getOuterVlanId()).build(Collections.emptySet());
OFFlowAdd expected = makeForwardingMessage(command, 10, OfAdapter.INSTANCE.matchVlanId(of, of.buildMatch(), endpoint.getInnerVlanId()).setExact(MatchField.IN_PORT, OFPort.of(endpoint.getPortNumber())).setMasked(MatchField.METADATA, OFMetadata.of(metadata.getValue()), OFMetadata.of(metadata.getMask())).build(), getTargetIngressTableId(), FlowEndpoint.makeVlanStack(endpoint.getInnerVlanId()));
IngressFlowModFactory factory = makeFactory(command);
verifyOfMessageEquals(expected, factory.makeDoubleVlanForwardMessage(new EffectiveIds(getEffectiveMeterId(command.getMeterConfig()), null)));
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class OneSwitchFlowInstallFlowModFactoryTest method testMakeSingleVlanForwardMessage.
private void testMakeSingleVlanForwardMessage(MeterConfig meter) {
OneSwitchFlowInstallCommand command = makeCommand(endpointSingleVlan, egressEndpointSingleVlan, meter);
FlowEndpoint endpoint = command.getEndpoint();
RoutingMetadata metadata = RoutingMetadata.builder().outerVlanId(endpoint.getOuterVlanId()).build(Collections.emptySet());
OFFlowAdd expected = makeForwardingMessage(command, 0, of.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(endpoint.getPortNumber())).setMasked(MatchField.METADATA, OFMetadata.of(metadata.getValue()), OFMetadata.of(metadata.getMask())).build(), getTargetIngressTableId(), FlowEndpoint.makeVlanStack(endpoint.getInnerVlanId()));
IngressFlowModFactory factory = makeFactory(command);
verifyOfMessageEquals(expected, factory.makeSingleVlanForwardMessage(new EffectiveIds(getEffectiveMeterId(command.getMeterConfig()), null)));
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class EgressFlowSegmentCommandTest method errorOnFlowMod.
@Test
public void errorOnFlowMod() {
switchFeaturesSetup(sw, true);
replayAll();
FlowEndpoint ingressEndpoint = new FlowEndpoint(mapSwitchId(dpId), 1, 0);
EgressFlowSegmentCommand command = makeCommand(endpointEgressZeroVlan, ingressEndpoint, encapsulationVlan);
CompletableFuture<FlowSegmentReport> result = command.execute(commandProcessor);
getWriteRecord(0).getFuture().completeExceptionally(new SwitchErrorResponseException(dpIdNext, of.errorMsgs().buildBadRequestErrorMsg().setCode(OFBadRequestCode.BAD_LEN).build()));
verifyErrorCompletion(result, SwitchOperationException.class);
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class EgressFlowSegmentCommandJsonTest method makeRequest.
@Override
protected EgressFlowSegmentRequest makeRequest() {
SwitchId swId = new SwitchId(1);
EgressFlowSegmentRequestFactory factory = new EgressFlowSegmentRequestFactory(new MessageContext(), new FlowSegmentMetadata("egress-flow-segment-install-request", new Cookie(2), false), new FlowEndpoint(swId, 3, 4), new FlowEndpoint(new SwitchId(swId.toLong() + 1), 6, 7), 9, new FlowTransitEncapsulation(10, FlowEncapsulationType.TRANSIT_VLAN), MirrorConfig.builder().build());
return makeRequest(factory);
}
Aggregations