use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class EgressRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
if (flowPath.isOneSwitchFlow() || flowPath.getSegments().isEmpty()) {
return new ArrayList<>();
}
PathSegment lastSegment = flowPath.getSegments().get(flowPath.getSegments().size() - 1);
FlowEndpoint endpoint = checkAndBuildEgressEndpoint(flow, flowPath, sw.getSwitchId());
return Lists.newArrayList(buildEgressCommand(sw, lastSegment.getDestPort(), endpoint));
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class FlowPathMapper method mapToPathNodes.
/**
* Convert {@link FlowPath} to {@link PathNodePayload}.
*/
public List<PathNodePayload> mapToPathNodes(FlowPath flowPath) {
List<PathNodePayload> resultList = new ArrayList<>();
Flow flow = flowPath.getFlow();
FlowEndpoint ingress = FlowSideAdapter.makeIngressAdapter(flow, flowPath).getEndpoint();
FlowEndpoint egress = FlowSideAdapter.makeEgressAdapter(flow, flowPath).getEndpoint();
List<PathSegment> pathSegments = flowPath.getSegments();
Iterator<PathSegment> leftIter = pathSegments.iterator();
Iterator<PathSegment> rightIter = pathSegments.iterator();
if (!rightIter.hasNext()) {
resultList.add(new PathNodePayload(flowPath.getSrcSwitchId(), ingress.getPortNumber(), egress.getPortNumber()));
} else {
PathSegment left;
PathSegment right = rightIter.next();
resultList.add(new PathNodePayload(ingress.getSwitchId(), ingress.getPortNumber(), right.getSrcPort()));
while (rightIter.hasNext()) {
left = leftIter.next();
right = rightIter.next();
resultList.add(new PathNodePayload(left.getDestSwitchId(), left.getDestPort(), right.getSrcPort()));
}
resultList.add(new PathNodePayload(egress.getSwitchId(), right.getDestPort(), egress.getPortNumber()));
}
return resultList;
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class EgressFlowSegmentInstallCommandTest method makeCommand.
protected EgressFlowSegmentInstallCommand makeCommand(FlowEndpoint endpoint, FlowEndpoint ingressEndpoint, FlowTransitEncapsulation encapsulation, FlowSegmentMetadata metadata) {
MessageContext messageContext = new MessageContext();
UUID commandId = UUID.randomUUID();
int islPort = 6;
return new EgressFlowSegmentInstallCommand(messageContext, commandId, metadata, endpoint, ingressEndpoint, islPort, encapsulation, null);
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class EgressFlowSegmentRemoveCommandTest method happyPathTransitVlan.
@Test
public void happyPathTransitVlan() throws Exception {
FlowEndpoint ingressEndpoint = new FlowEndpoint(mapSwitchId(dpId), 1, 0);
EgressFlowSegmentRemoveCommand command = makeCommand(endpointEgressZeroVlan, ingressEndpoint, encapsulationVlan);
executeCommand(command, 1);
OFFlowDeleteStrict expected = of.buildFlowDeleteStrict().setPriority(EgressFlowSegmentRemoveCommand.FLOW_PRIORITY).setCookie(U64.of(command.getCookie().getValue())).setCookieMask(U64.NO_MASK).setMatch(OfAdapter.INSTANCE.matchVlanId(of, of.buildMatch(), command.getEncapsulation().getId()).setExact(MatchField.IN_PORT, OFPort.of(command.getIngressIslPort())).build()).build();
verifyOfMessageEquals(expected, getWriteRecord(0).getRequest());
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class EgressFlowSegmentRemoveCommandTest method makeCommand.
@Override
protected EgressFlowSegmentRemoveCommand makeCommand(FlowEndpoint endpoint, FlowEndpoint ingressEndpoint, FlowTransitEncapsulation encapsulation) {
MessageContext messageContext = new MessageContext();
UUID commandId = UUID.randomUUID();
FlowSegmentMetadata metadata = new FlowSegmentMetadata("egress-flow-segment-remove-flow-id", new Cookie(101), false);
int islPort = 8;
return new EgressFlowSegmentRemoveCommand(messageContext, commandId, metadata, endpoint, ingressEndpoint, islPort, encapsulation, null);
}
Aggregations