use of org.openkilda.model.PathSegment in project open-kilda by telstra.
the class FermaFlowPathRepositoryTest method createTestFlowPathWithIntermediate.
private FlowPath createTestFlowPathWithIntermediate(Switch intSwitch, int intPort) {
FlowPath flowPath = FlowPath.builder().pathId(new PathId(flow.getFlowId() + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(switchA).destSwitch(switchB).status(FlowPathStatus.ACTIVE).build();
PathSegment segment1 = PathSegment.builder().pathId(flowPath.getPathId()).srcSwitch(switchA).srcPort(1).destSwitch(intSwitch).destPort(intPort).build();
PathSegment segment2 = PathSegment.builder().pathId(flowPath.getPathId()).srcSwitch(intSwitch).srcPort(intPort + 100).destSwitch(switchB).destPort(2).build();
flowPath.setSegments(asList(segment1, segment2));
flowPathRepository.add(flowPath);
return flowPath;
}
use of org.openkilda.model.PathSegment in project open-kilda by telstra.
the class FermaIslRepositoryTest method shouldFindIslByPathId.
@Test
public void shouldFindIslByPathId() {
Isl isl = createIsl(switchA, 111, switchB, 112);
PathId pathId = new PathId("test_path_id");
PathSegment segment = PathSegment.builder().pathId(pathId).srcSwitch(isl.getSrcSwitch()).srcPort(isl.getSrcPort()).destSwitch(isl.getDestSwitch()).destPort(isl.getDestPort()).build();
FlowPath path = FlowPath.builder().pathId(pathId).srcSwitch(switchA).destSwitch(switchB).segments(Collections.singletonList(segment)).build();
flowPathRepository.add(path);
List<Isl> foundIsls = Lists.newArrayList(islRepository.findByPathIds(Collections.singletonList(pathId)));
assertThat(foundIsls, Matchers.hasSize(1));
assertThat(foundIsls, Matchers.contains(isl));
}
use of org.openkilda.model.PathSegment in project open-kilda by telstra.
the class FermaFlowRepositoryTest method createTestFlow.
private Flow createTestFlow(String flowId, Switch srcSwitch, int srcPort, int srcVlan, Switch destSwitch, int destPort, int destVlan, boolean multiTable) {
Flow flow = Flow.builder().flowId(flowId).srcSwitch(srcSwitch).srcPort(srcPort).srcVlan(srcVlan).destSwitch(destSwitch).destPort(destPort).destVlan(destVlan).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
flowRepository.add(flow);
FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(srcSwitch).destSwitch(destSwitch).status(FlowPathStatus.ACTIVE).srcWithMultiTable(multiTable).destWithMultiTable(multiTable).build();
PathSegment forwardSegment = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(srcSwitch).srcPort(srcPort).destSwitch(destSwitch).destPort(destPort).build();
forwardFlowPath.setSegments(Collections.singletonList(forwardSegment));
flowPathRepository.add(forwardFlowPath);
flow.setForwardPath(forwardFlowPath);
FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(2)).srcSwitch(destSwitch).destSwitch(srcSwitch).status(FlowPathStatus.ACTIVE).srcWithMultiTable(multiTable).destWithMultiTable(multiTable).build();
PathSegment reverseSegment = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(destSwitch).srcPort(destPort).destSwitch(srcSwitch).destPort(srcPort).build();
reverseFlowPath.setSegments(Collections.singletonList(reverseSegment));
flowPathRepository.add(reverseFlowPath);
flow.setReversePath(reverseFlowPath);
return flow;
}
use of org.openkilda.model.PathSegment in project open-kilda by telstra.
the class FermaFlowRepositoryTest method createTestFlowWithIntermediate.
private Flow createTestFlowWithIntermediate(String flowId, Switch srcSwitch, Switch intSwitch, int intPort, Switch destSwitch) {
Flow flow = Flow.builder().flowId(flowId).srcSwitch(srcSwitch).srcPort(PORT_1).destSwitch(destSwitch).destPort(PORT_2).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
flowRepository.add(flow);
FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(srcSwitch).destSwitch(destSwitch).status(FlowPathStatus.ACTIVE).build();
flowPathRepository.add(forwardFlowPath);
flow.setForwardPath(forwardFlowPath);
PathSegment forwardSegment = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(srcSwitch).srcPort(1).destSwitch(intSwitch).destPort(intPort).build();
forwardFlowPath.setSegments(Collections.singletonList(forwardSegment));
FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(2)).srcSwitch(destSwitch).destSwitch(srcSwitch).status(FlowPathStatus.ACTIVE).build();
flowPathRepository.add(reverseFlowPath);
flow.setReversePath(reverseFlowPath);
PathSegment reverseSegment = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(intSwitch).srcPort(100).destSwitch(srcSwitch).destPort(1).build();
reverseFlowPath.setSegments(Collections.singletonList(reverseSegment));
return flow;
}
use of org.openkilda.model.PathSegment in project open-kilda by telstra.
the class FermaYFlowRepositoryTest method createTestFlow.
private Flow createTestFlow(String flowId, Switch srcSwitch, int srcPort, int srcVlan, Switch destSwitch, int destPort, int destVlan) {
Flow flow = Flow.builder().flowId(flowId).srcSwitch(srcSwitch).srcPort(srcPort).srcVlan(srcVlan).destSwitch(destSwitch).destPort(destPort).destVlan(destVlan).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
flowRepository.add(flow);
FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(srcSwitch).destSwitch(destSwitch).status(FlowPathStatus.ACTIVE).build();
PathSegment forwardSegment = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(srcSwitch).srcPort(srcPort).destSwitch(destSwitch).destPort(destPort).build();
forwardFlowPath.setSegments(Collections.singletonList(forwardSegment));
flowPathRepository.add(forwardFlowPath);
flow.setForwardPath(forwardFlowPath);
FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(2)).srcSwitch(destSwitch).destSwitch(srcSwitch).status(FlowPathStatus.ACTIVE).build();
PathSegment reverseSegment = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(destSwitch).srcPort(destPort).destSwitch(srcSwitch).destPort(srcPort).build();
reverseFlowPath.setSegments(Collections.singletonList(reverseSegment));
flowPathRepository.add(reverseFlowPath);
flow.setReversePath(reverseFlowPath);
return flow;
}
Aggregations