use of org.openkilda.model.PathSegment in project open-kilda by telstra.
the class FermaFlowPathRepositoryTest method buildTestProtectedFlow.
private Flow buildTestProtectedFlow(String flowId, Switch srcSwitch, int srcPort, int srcVlan, Switch destSwitch, int destPort, int destVlan) {
Flow flow = buildTestFlow(flowId, srcSwitch, srcPort, srcVlan, destSwitch, destPort, destVlan);
FlowPath forwardProtectedFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_forward_protected_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 2L)).srcSwitch(srcSwitch).destSwitch(destSwitch).status(FlowPathStatus.ACTIVE).build();
flow.setProtectedForwardPath(forwardProtectedFlowPath);
PathSegment forwardSegment = PathSegment.builder().pathId(forwardProtectedFlowPath.getPathId()).srcSwitch(srcSwitch).srcPort(srcPort).destSwitch(destSwitch).destPort(destPort).build();
forwardProtectedFlowPath.setSegments(Collections.singletonList(forwardSegment));
FlowPath reverseProtectedFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_reverse_protected_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 2L)).srcSwitch(destSwitch).destSwitch(srcSwitch).status(FlowPathStatus.ACTIVE).build();
flow.setProtectedReversePath(reverseProtectedFlowPath);
PathSegment reverseSegment = PathSegment.builder().pathId(reverseProtectedFlowPath.getPathId()).srcSwitch(destSwitch).srcPort(destPort).destSwitch(srcSwitch).destPort(srcPort).build();
reverseProtectedFlowPath.setSegments(Collections.singletonList(reverseSegment));
return flow;
}
use of org.openkilda.model.PathSegment in project open-kilda by telstra.
the class FermaFlowPathRepositoryTest method buildTestFlow.
private Flow buildTestFlow(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();
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();
flow.setForwardPath(forwardFlowPath);
PathSegment forwardSegment = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(srcSwitch).srcPort(srcPort).destSwitch(destSwitch).destPort(destPort).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();
flow.setReversePath(reverseFlowPath);
PathSegment reverseSegment = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(destSwitch).srcPort(destPort).destSwitch(srcSwitch).destPort(srcPort).build();
reverseFlowPath.setSegments(Collections.singletonList(reverseSegment));
return flow;
}
use of org.openkilda.model.PathSegment in project open-kilda by telstra.
the class FermaFlowPathRepositoryTest method shouldKeepSegmentsOrdered.
@Test
public void shouldKeepSegmentsOrdered() {
FlowPath flowPath = createTestFlowPath();
List<PathSegment> segments = asList(PathSegment.builder().pathId(flowPath.getPathId()).srcSwitch(switchA).destSwitch(switchC).build(), PathSegment.builder().pathId(flowPath.getPathId()).srcSwitch(switchC).destSwitch(switchB).build());
flowPath.setSegments(segments);
Optional<FlowPath> foundPath = flowPathRepository.findById(flowPath.getPathId());
assertEquals(foundPath.get().getSegments().get(0).getDestSwitchId(), switchC.getSwitchId());
}
use of org.openkilda.model.PathSegment in project open-kilda by telstra.
the class FermaIslRepositoryTest method createFlowWithPath.
private Flow createFlowWithPath(int forwardBandwidth, int reverseBandwidth) {
Flow flow = Flow.builder().flowId(TEST_FLOW_ID).srcSwitch(switchA).destSwitch(switchB).status(FlowStatus.UP).build();
FlowPath forwardPath = FlowPath.builder().srcSwitch(switchA).destSwitch(switchB).pathId(new PathId(TEST_FLOW_ID + "_forward_path")).cookie(new FlowSegmentCookie(1)).meterId(new MeterId(1)).status(FlowPathStatus.ACTIVE).bandwidth(forwardBandwidth).ignoreBandwidth(false).build();
flow.setForwardPath(forwardPath);
PathSegment forwardSegment = PathSegment.builder().pathId(forwardPath.getPathId()).srcSwitch(switchA).srcPort(1).destSwitch(switchB).destPort(2).build();
forwardPath.setSegments(Collections.singletonList(forwardSegment));
FlowPath reversePath = FlowPath.builder().srcSwitch(switchB).destSwitch(switchA).pathId(new PathId(TEST_FLOW_ID + "_reverse_path")).cookie(new FlowSegmentCookie(2)).meterId(new MeterId(2)).status(FlowPathStatus.ACTIVE).bandwidth(reverseBandwidth).ignoreBandwidth(false).build();
flow.setReversePath(reversePath);
PathSegment reverseSegment = PathSegment.builder().pathId(reversePath.getPathId()).srcSwitch(switchB).srcPort(2).destSwitch(switchA).destPort(1).build();
reversePath.setSegments(Collections.singletonList(reverseSegment));
flowRepository.add(flow);
return flow;
}
use of org.openkilda.model.PathSegment in project open-kilda by telstra.
the class FlowOperationsServiceTest method createPathSegment.
private PathSegment createPathSegment(PathId pathId, Switch srcSwitch, int srcPort, Switch dstSwitch, int dstPort) {
PathSegment pathSegment = PathSegment.builder().pathId(pathId).srcSwitch(srcSwitch).srcPort(srcPort).destSwitch(dstSwitch).destPort(dstPort).build();
pathSegmentRepository.add(pathSegment);
return pathSegment;
}
Aggregations