use of org.openkilda.model.PathSegment in project open-kilda by telstra.
the class RuleManagerImpl method findPathSegmentsForSwitch.
private SwitchPathSegments findPathSegmentsForSwitch(SwitchId switchId, List<PathSegment> pathSegments) {
SwitchPathSegments result = null;
for (int i = 1; i < pathSegments.size(); i++) {
PathSegment firstSegment = pathSegments.get(i - 1);
PathSegment secondSegment = pathSegments.get(i);
if (switchId.equals(firstSegment.getDestSwitchId()) && switchId.equals(secondSegment.getSrcSwitchId())) {
result = new SwitchPathSegments(firstSegment, secondSegment);
break;
}
}
return result;
}
use of org.openkilda.model.PathSegment in project open-kilda by telstra.
the class PingProducer method getIslPort.
private int getIslPort(Flow flow, FlowPath flowPath) {
List<PathSegment> segments = flowPath.getSegments();
if (segments.isEmpty()) {
throw new IllegalArgumentException(format("Path segments not provided, flow_id: %s", flow.getFlowId()));
}
PathSegment ingressSegment = segments.get(0);
if (!ingressSegment.getSrcSwitchId().equals(flowPath.getSrcSwitchId())) {
throw new IllegalStateException(format("FlowSegment was not found for ingress flow rule, flow_id: %s", flow.getFlowId()));
}
return ingressSegment.getSrcPort();
}
use of org.openkilda.model.PathSegment in project open-kilda by telstra.
the class SpeakerFlowSegmentRequestBuilderTest method setSegmentsWithTransitSwitches.
private void setSegmentsWithTransitSwitches(FlowPath forward, FlowPath reverse) {
PathSegment switch1ToSwitch2 = PathSegment.builder().pathId(forward.getPathId()).srcSwitch(forward.getSrcSwitch()).srcPort(12).destSwitch(Switch.builder().switchId(SWITCH_2).build()).destPort(21).build();
PathSegment switch2ToSwitch3 = PathSegment.builder().pathId(forward.getPathId()).srcSwitch(Switch.builder().switchId(SWITCH_2).build()).srcPort(23).destSwitch(forward.getDestSwitch()).destPort(32).build();
forward.setSegments(ImmutableList.of(switch1ToSwitch2, switch2ToSwitch3));
PathSegment switch3ToSwitch2 = PathSegment.builder().pathId(reverse.getPathId()).srcSwitch(reverse.getSrcSwitch()).srcPort(32).destSwitch(Switch.builder().switchId(SWITCH_2).build()).destPort(23).build();
PathSegment switch2ToSwitch1 = PathSegment.builder().pathId(reverse.getPathId()).srcSwitch(Switch.builder().switchId(SWITCH_2).build()).srcPort(21).destSwitch(reverse.getDestSwitch()).destPort(12).build();
reverse.setSegments(ImmutableList.of(switch3ToSwitch2, switch2ToSwitch1));
}
use of org.openkilda.model.PathSegment in project open-kilda by telstra.
the class TestFlowBuilder method buildFlowPath.
private FlowPath buildFlowPath(Flow flow, Switch srcSwitch, Switch destSwitch, List<Endpoint> transitEndpoints, FlowSegmentCookie cookie, MeterId meterId) {
PathId pathId = new PathId(UUID.randomUUID().toString());
List<PathSegment> pathSegments = new ArrayList<>();
if (!srcSwitch.getSwitchId().equals(destSwitch.getSwitchId())) {
for (int i = 0; i < transitEndpoints.size() - 1; i += 2) {
Endpoint first = transitEndpoints.get(i);
Endpoint second = transitEndpoints.get(i + 1);
pathSegments.add(PathSegment.builder().pathId(pathId).srcSwitch(first.sw).srcPort(first.port).destSwitch(second.sw).destPort(second.port).bandwidth(flow.getBandwidth()).ignoreBandwidth(flow.isIgnoreBandwidth()).build());
}
}
return FlowPath.builder().pathId(pathId).srcSwitch(srcSwitch).destSwitch(destSwitch).cookie(cookie).meterId(meterId).bandwidth(flow.getBandwidth()).ignoreBandwidth(flow.isIgnoreBandwidth()).segments(pathSegments).build();
}
use of org.openkilda.model.PathSegment in project open-kilda by telstra.
the class SpeakerFlowSegmentRequestBuilderTest method verifyCommonTransitRequest.
private TransitFlowSegmentRequest verifyCommonTransitRequest(Flow flow, FlowPath path, SwitchId datapath, FlowSegmentRequest rawRequest) {
assertThat("Should be egress segment request", rawRequest, instanceOf(TransitFlowSegmentRequest.class));
TransitFlowSegmentRequest request = (TransitFlowSegmentRequest) rawRequest;
assertEquals(flow.getFlowId(), request.getFlowId());
assertEquals(path.getCookie(), request.getCookie());
assertEquals(SWITCH_2, request.getSwitchId());
PathSegment ingress = null;
PathSegment egress = null;
for (PathSegment segment : path.getSegments()) {
if (datapath.equals(segment.getDestSwitchId())) {
ingress = segment;
} else if (datapath.equals(segment.getSrcSwitchId())) {
egress = segment;
}
}
assertNotNull(ingress);
assertNotNull(egress);
assertEquals(ingress.getDestPort(), (int) request.getIngressIslPort());
assertEquals(egress.getSrcPort(), (int) request.getEgressIslPort());
verifyVlanEncapsulation(flow, path, request.getEncapsulation());
return request;
}
Aggregations