use of org.openkilda.model.FlowMirrorPoints in project open-kilda by telstra.
the class FlowPathFrame method addFlowMirrorPoints.
@Override
public void addFlowMirrorPoints(FlowMirrorPoints flowMirrorPoints) {
FlowMirrorPoints.FlowMirrorPointsData data = flowMirrorPoints.getData();
FlowMirrorPointsFrame frame;
if (data instanceof FlowMirrorPointsFrame) {
frame = (FlowMirrorPointsFrame) data;
// Unlink the mirror points from the previous owner.
frame.getElement().edges(Direction.IN, FlowPathFrame.HAS_SEGMENTS_EDGE).forEachRemaining(Edge::remove);
} else {
// A path must be added via corresponding repository first.
throw new IllegalArgumentException("Unable to link to transient flow mirror points " + flowMirrorPoints);
}
PathId flowPathId = getPathId();
frame.setProperty(FlowMirrorPointsFrame.FLOW_PATH_ID_PROPERTY, PathIdConverter.INSTANCE.toGraphProperty(flowPathId));
linkOut(frame, HAS_SEGMENTS_EDGE);
flowMirrorPoints.getMirrorGroup().setPathId(flowPathId);
if (this.flowMirrorPointsSet != null) {
this.flowMirrorPointsSet.add(flowMirrorPoints);
}
}
use of org.openkilda.model.FlowMirrorPoints in project open-kilda by telstra.
the class FlowValidator method checkFlowForMirrorEndpointConflicts.
private void checkFlowForMirrorEndpointConflicts(String flowId, EndpointDescriptor descriptor) throws InvalidFlowException {
FlowEndpoint endpoint = descriptor.getEndpoint();
Optional<Flow> foundFlow = flowRepository.findById(flowId);
if (foundFlow.isPresent()) {
Flow flow = foundFlow.get();
Optional<FlowMirrorPoints> flowMirrorPointsForward = flowMirrorPointsRepository.findByPathIdAndSwitchId(flow.getForwardPathId(), endpoint.getSwitchId());
Optional<FlowMirrorPoints> flowMirrorPointsReverse = flowMirrorPointsRepository.findByPathIdAndSwitchId(flow.getReversePathId(), endpoint.getSwitchId());
if ((flowMirrorPointsForward.isPresent() || flowMirrorPointsReverse.isPresent()) && (endpoint.isTrackLldpConnectedDevices() || endpoint.isTrackArpConnectedDevices())) {
String errorMessage = format("Flow mirror point is created for the flow %s, " + "lldp or arp can not be set to true.", flowId);
throw new InvalidFlowException(errorMessage, ErrorType.PARAMETERS_INVALID);
}
}
}
use of org.openkilda.model.FlowMirrorPoints in project open-kilda by telstra.
the class SimpleSwitchRuleConverterTest method buildFlow.
private Flow buildFlow(FlowEncapsulationType flowEncapsulationType, boolean checkWithGroup) {
Switch switchA = Switch.builder().switchId(TEST_SWITCH_ID_A).description("").build();
Switch switchB = Switch.builder().switchId(TEST_SWITCH_ID_B).description("").build();
Switch switchC = Switch.builder().switchId(TEST_SWITCH_ID_C).description("").build();
Flow flow = Flow.builder().flowId(TEST_FLOW_ID_A).srcSwitch(switchA).srcPort(FLOW_A_SRC_PORT).srcVlan(FLOW_A_SRC_VLAN).destSwitch(switchC).destPort(FLOW_A_DST_PORT).destVlan(FLOW_A_DST_VLAN).allocateProtectedPath(true).encapsulationType(flowEncapsulationType).bandwidth(FLOW_A_BANDWIDTH).status(FlowStatus.UP).build();
FlowPath forwardFlowPath = FlowPath.builder().pathId(FLOW_A_FORWARD_PATH_ID).cookie(new FlowSegmentCookie(FLOW_A_FORWARD_COOKIE_VALUE)).meterId(new MeterId(FLOW_A_FORWARD_METER_ID)).srcSwitch(switchA).destSwitch(switchC).status(FlowPathStatus.ACTIVE).bandwidth(FLOW_A_BANDWIDTH).build();
flow.setForwardPath(forwardFlowPath);
PathSegment forwardSegmentA = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(switchA).srcPort(FLOW_A_SEGMENT_A_SRC_PORT).destSwitch(switchB).destPort(FLOW_A_SEGMENT_A_DST_PORT).build();
PathSegment forwardSegmentB = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(switchB).srcPort(FLOW_A_SEGMENT_B_SRC_PORT).destSwitch(switchC).destPort(FLOW_A_SEGMENT_B_DST_PORT).build();
forwardFlowPath.setSegments(Lists.newArrayList(forwardSegmentA, forwardSegmentB));
if (checkWithGroup) {
FlowMirrorPoints flowMirrorPoints = FlowMirrorPoints.builder().mirrorSwitch(switchA).mirrorGroup(MirrorGroup.builder().switchId(TEST_SWITCH_ID_A).groupId(new GroupId(FLOW_GROUP_ID_A)).pathId(FLOW_A_FORWARD_PATH_ID).flowId(TEST_FLOW_ID_A).mirrorGroupType(MirrorGroupType.TRAFFIC_INTEGRITY).mirrorDirection(MirrorDirection.INGRESS).build()).build();
FlowMirrorPath flowMirrorPath = FlowMirrorPath.builder().pathId(new PathId("mirror_path")).mirrorSwitch(switchA).egressSwitch(switchA).egressPort(FLOW_GROUP_ID_A_OUT_PORT).egressOuterVlan(FLOW_GROUP_ID_A_OUT_VLAN).build();
flowMirrorPoints.addPaths(flowMirrorPath);
forwardFlowPath.addFlowMirrorPoints(flowMirrorPoints);
}
return flow;
}
use of org.openkilda.model.FlowMirrorPoints in project open-kilda by telstra.
the class SwitchOperationsServiceTest method shouldValidateFlowMirrorPointsWhenUpdatingSwitchArpProperties.
@Test(expected = IllegalSwitchPropertiesException.class)
public void shouldValidateFlowMirrorPointsWhenUpdatingSwitchArpProperties() {
Switch mirrorSwitch = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build();
switchRepository.add(mirrorSwitch);
MirrorGroup mirrorGroup = MirrorGroup.builder().switchId(TEST_SWITCH_ID).groupId(new GroupId(12L)).pathId(new PathId("test_path_id")).flowId(TEST_FLOW_ID_1).mirrorGroupType(MirrorGroupType.TRAFFIC_INTEGRITY).mirrorDirection(MirrorDirection.INGRESS).build();
mirrorGroupRepository.add(mirrorGroup);
FlowMirrorPoints flowMirrorPoints = FlowMirrorPoints.builder().mirrorGroup(mirrorGroup).mirrorSwitch(mirrorSwitch).build();
flowMirrorPointsRepository.add(flowMirrorPoints);
createSwitchProperties(mirrorSwitch, Collections.singleton(FlowEncapsulationType.TRANSIT_VLAN), true, false, false);
SwitchPropertiesDto update = new SwitchPropertiesDto();
update.setSupportedTransitEncapsulation(Collections.singleton(org.openkilda.messaging.payload.flow.FlowEncapsulationType.TRANSIT_VLAN));
update.setMultiTable(true);
update.setSwitchArp(true);
switchOperationsService.updateSwitchProperties(TEST_SWITCH_ID, update);
}
use of org.openkilda.model.FlowMirrorPoints in project open-kilda by telstra.
the class CommandBuilderImpl method makeMirrorConfig.
private MirrorConfig makeMirrorConfig(@NonNull FlowPath flowPath, @NonNull SwitchId mirrorSwitchId, int mirrorPort) {
MirrorConfig mirrorConfig = null;
FlowMirrorPoints flowMirrorPoints = flowPath.getFlowMirrorPointsSet().stream().filter(mirrorPoints -> mirrorSwitchId.equals(mirrorPoints.getMirrorSwitchId())).findFirst().orElse(null);
if (flowMirrorPoints != null) {
Set<MirrorConfigData> mirrorConfigDataSet = flowMirrorPoints.getMirrorPaths().stream().map(mirrorPath -> new MirrorConfigData(mirrorPath.getEgressPort(), mirrorPath.getEgressOuterVlan())).collect(Collectors.toSet());
if (!mirrorConfigDataSet.isEmpty()) {
mirrorConfig = MirrorConfig.builder().groupId(flowMirrorPoints.getMirrorGroupId()).flowPort(mirrorPort).mirrorConfigDataSet(mirrorConfigDataSet).build();
}
}
return mirrorConfig;
}
Aggregations