use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class PersistenceDummyEntityFactory method makeFlowPathPair.
private void makeFlowPathPair(Flow flow, FlowEndpoint source, FlowEndpoint dest, List<IslDirectionalReference> forwardPathHint, List<String> tags) {
long flowEffectiveId = idProvider.provideFlowEffectiveId();
makeFlowCookie(flow.getFlowId(), flowEffectiveId);
List<IslDirectionalReference> reversePathHint = forwardPathHint.stream().map(IslDirectionalReference::makeOpposite).collect(Collectors.toList());
// inline
Collections.reverse(reversePathHint);
PathId forwardPathId = idProvider.providePathId(flow.getFlowId(), Stream.concat(tags.stream(), Stream.of("forward")));
List<PathSegment> forwardSegments = makePathSegments(forwardPathId, source.getSwitchId(), dest.getSwitchId(), forwardPathHint);
flow.setForwardPath(makePath(flow, source, dest, forwardPathId, forwardSegments, new FlowSegmentCookie(FlowPathDirection.FORWARD, flowEffectiveId)));
PathId reversePathId = idProvider.providePathId(flow.getFlowId(), Stream.concat(tags.stream(), Stream.of("reverse")));
List<PathSegment> reverseSegments = makePathSegments(reversePathId, dest.getSwitchId(), source.getSwitchId(), reversePathHint);
flow.setReversePath(makePath(flow, dest, source, reversePathId, reverseSegments, new FlowSegmentCookie(FlowPathDirection.REVERSE, flowEffectiveId)));
}
use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class SpeakerFlowSegmentRequestBuilder method makeEgressSegmentRequests.
private List<FlowSegmentRequestFactory> makeEgressSegmentRequests(CommandContext context, FlowPath path, FlowTransitEncapsulation encapsulation, PathSegment segment, FlowSideAdapter flowSide, FlowSideAdapter ingressFlowSide, MirrorContext mirrorContext) {
Flow flow = flowSide.getFlow();
PathSegmentSide segmentSide = makePathSegmentDestSide(segment);
UUID commandId = commandIdGenerator.generate();
MessageContext messageContext = new MessageContext(commandId.toString(), context.getCorrelationId());
FlowSegmentMetadata metadata = makeMetadata(path, ensureEqualMultiTableFlag(segmentSide.isMultiTable(), path.isDestWithMultiTable(), String.format("Last flow(id:%s, path:%s) segment and flow path level multi-table flags value " + "are incompatible to each other - segment(%s) != flow path(%s)", flow.getFlowId(), path.getPathId(), segmentSide.isMultiTable(), path.isDestWithMultiTable())));
List<FlowSegmentRequestFactory> egressFactories = new ArrayList<>();
if (!mirrorContext.isBuildMirrorFactoryOnly()) {
egressFactories.add(EgressFlowSegmentRequestFactory.builder().messageContext(messageContext).metadata(metadata).endpoint(flowSide.getEndpoint()).ingressEndpoint(ingressFlowSide.getEndpoint()).islPort(segmentSide.getEndpoint().getPortNumber()).encapsulation(encapsulation).build());
}
Optional<MirrorConfig> mirrorConfig = makeMirrorConfig(path, flowSide.getEndpoint(), mirrorContext);
if (mirrorConfig.isPresent() || mirrorContext.isRemoveFlowOperation()) {
FlowSegmentCookie mirrorCookie = path.getCookie().toBuilder().mirror(true).build();
egressFactories.add(EgressMirrorFlowSegmentRequestFactory.builder().messageContext(new MessageContext(commandIdGenerator.generate().toString(), context.getCorrelationId())).metadata(makeMetadata(metadata.getFlowId(), mirrorCookie, metadata.isMultiTable())).endpoint(flowSide.getEndpoint()).ingressEndpoint(ingressFlowSide.getEndpoint()).islPort(segmentSide.getEndpoint().getPortNumber()).encapsulation(encapsulation).mirrorConfig(mirrorConfig.orElse(null)).build());
}
return egressFactories;
}
use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class SpeakerFlowSegmentRequestBuilder method makeLoopRequests.
private List<FlowSegmentRequestFactory> makeLoopRequests(CommandContext context, FlowPath path, FlowTransitEncapsulation encapsulation, FlowSideAdapter ingressSide, FlowSideAdapter egressSide, PathSegment segment) {
List<FlowSegmentRequestFactory> result = new ArrayList<>(2);
PathSegmentSide segmentSide = makePathSegmentSourceSide(segment);
UUID commandId = commandIdGenerator.generate();
MessageContext messageContext = new MessageContext(commandId.toString(), context.getCorrelationId());
FlowSegmentCookie cookie = path.getCookie().toBuilder().looped(true).build();
result.add(IngressFlowLoopSegmentRequestFactory.builder().messageContext(messageContext).metadata(makeMetadata(path.getFlow().getFlowId(), cookie, segmentSide.isMultiTable())).endpoint(ingressSide.getEndpoint()).build());
FlowPathDirection reverse = cookie.getDirection() == FlowPathDirection.FORWARD ? FlowPathDirection.REVERSE : FlowPathDirection.FORWARD;
Cookie transitCookie = path.getCookie().toBuilder().looped(true).direction(reverse).build();
result.add(TransitFlowLoopSegmentRequestFactory.builder().messageContext(messageContext).switchId(segment.getSrcSwitch().getSwitchId()).egressSwitchId(egressSide.getEndpoint().getSwitchId()).metadata(makeMetadata(path.getFlow().getFlowId(), transitCookie, segmentSide.isMultiTable())).port(segment.getSrcPort()).encapsulation(encapsulation).build());
return result;
}
use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class SpeakerFlowSegmentRequestBuilder method makeIngressSegmentRequests.
private List<FlowSegmentRequestFactory> makeIngressSegmentRequests(CommandContext context, FlowPath path, FlowTransitEncapsulation encapsulation, FlowSideAdapter flowSide, PathSegment segment, FlowSideAdapter egressFlowSide, RulesContext rulesContext, MirrorContext mirrorContext) {
PathSegmentSide segmentSide = makePathSegmentSourceSide(segment);
UUID commandId = commandIdGenerator.generate();
MessageContext messageContext = new MessageContext(commandId.toString(), context.getCorrelationId());
FlowSegmentMetadata metadata = makeMetadata(path, ensureEqualMultiTableFlag(path.isSrcWithMultiTable(), segmentSide.isMultiTable(), String.format("First flow(id:%s, path:%s) segment and flow path level multi-table flag values " + "are incompatible to each other - flow path(%s) != segment(%s)", path.getFlow().getFlowId(), path.getPathId(), path.isSrcWithMultiTable(), segmentSide.isMultiTable())));
List<FlowSegmentRequestFactory> ingressFactories = new ArrayList<>();
if (!mirrorContext.isBuildMirrorFactoryOnly()) {
ingressFactories.add(IngressFlowSegmentRequestFactory.builder().messageContext(messageContext).metadata(metadata).endpoint(flowSide.getEndpoint()).meterConfig(getMeterConfig(path)).egressSwitchId(egressFlowSide.getEndpoint().getSwitchId()).islPort(segmentSide.getEndpoint().getPortNumber()).encapsulation(encapsulation).rulesContext(rulesContext).build());
}
Optional<MirrorConfig> mirrorConfig = makeMirrorConfig(path, segmentSide.getEndpoint(), mirrorContext);
if (mirrorConfig.isPresent() || mirrorContext.isRemoveFlowOperation()) {
FlowSegmentCookie mirrorCookie = path.getCookie().toBuilder().mirror(true).build();
ingressFactories.add(IngressMirrorFlowSegmentRequestFactory.builder().messageContext(new MessageContext(commandIdGenerator.generate().toString(), context.getCorrelationId())).metadata(makeMetadata(metadata.getFlowId(), mirrorCookie, metadata.isMultiTable())).endpoint(flowSide.getEndpoint()).meterConfig(getMeterConfig(path)).egressSwitchId(egressFlowSide.getEndpoint().getSwitchId()).islPort(segmentSide.getEndpoint().getPortNumber()).encapsulation(encapsulation).rulesContext(rulesContext.toBuilder().updateMeter(false).installServer42IngressRule(false).installServer42InputRule(false).installServer42OuterVlanMatchSharedRule(false).build()).mirrorConfig(mirrorConfig.orElse(null)).build());
}
return ingressFactories;
}
use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class FlowValidationTestBase method buildOneSwitchPortFlow.
protected void buildOneSwitchPortFlow() {
Switch switchD = Switch.builder().switchId(TEST_SWITCH_ID_D).description("").build();
switchRepository.add(switchD);
Flow flow = Flow.builder().flowId(TEST_FLOW_ID_B).srcSwitch(switchD).srcPort(FLOW_B_SRC_PORT).srcVlan(FLOW_B_SRC_VLAN).destSwitch(switchD).destPort(FLOW_B_SRC_PORT).destVlan(FLOW_B_DST_VLAN).bandwidth(FLOW_B_BANDWIDTH).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_B + "_forward_path")).cookie(new FlowSegmentCookie(FLOW_B_FORWARD_COOKIE)).meterId(new MeterId(FLOW_B_FORWARD_METER_ID)).srcSwitch(switchD).destSwitch(switchD).bandwidth(FLOW_B_BANDWIDTH).status(FlowPathStatus.ACTIVE).build();
flow.setForwardPath(forwardFlowPath);
FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_B + "_reverse_path")).cookie(new FlowSegmentCookie(FLOW_B_REVERSE_COOKIE)).meterId(new MeterId(FLOW_B_REVERSE_METER_ID)).srcSwitch(switchD).destSwitch(switchD).bandwidth(FLOW_B_BANDWIDTH).status(FlowPathStatus.ACTIVE).build();
flow.setReversePath(reverseFlowPath);
flowRepository.add(flow);
}
Aggregations