Search in sources :

Example 26 with FlowSegmentCookie

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)));
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathSegment(org.openkilda.model.PathSegment)

Example 27 with FlowSegmentCookie

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;
}
Also used : IngressMirrorFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.IngressMirrorFlowSegmentRequestFactory) IngressFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.IngressFlowSegmentRequestFactory) EgressMirrorFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.EgressMirrorFlowSegmentRequestFactory) EgressFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory) TransitFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.TransitFlowSegmentRequestFactory) FlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) MirrorConfig(org.openkilda.model.MirrorConfig) ArrayList(java.util.ArrayList) MessageContext(org.openkilda.messaging.MessageContext) UUID(java.util.UUID) FlowSegmentMetadata(org.openkilda.floodlight.model.FlowSegmentMetadata) Flow(org.openkilda.model.Flow)

Example 28 with FlowSegmentCookie

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;
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) IngressMirrorFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.IngressMirrorFlowSegmentRequestFactory) IngressFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.IngressFlowSegmentRequestFactory) EgressMirrorFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.EgressMirrorFlowSegmentRequestFactory) EgressFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory) TransitFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.TransitFlowSegmentRequestFactory) FlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) ArrayList(java.util.ArrayList) MessageContext(org.openkilda.messaging.MessageContext) UUID(java.util.UUID) FlowPathDirection(org.openkilda.model.FlowPathDirection)

Example 29 with FlowSegmentCookie

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;
}
Also used : IngressMirrorFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.IngressMirrorFlowSegmentRequestFactory) IngressFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.IngressFlowSegmentRequestFactory) EgressMirrorFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.EgressMirrorFlowSegmentRequestFactory) EgressFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory) TransitFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.TransitFlowSegmentRequestFactory) FlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) MirrorConfig(org.openkilda.model.MirrorConfig) ArrayList(java.util.ArrayList) MessageContext(org.openkilda.messaging.MessageContext) UUID(java.util.UUID) FlowSegmentMetadata(org.openkilda.floodlight.model.FlowSegmentMetadata)

Example 30 with FlowSegmentCookie

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);
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) Switch(org.openkilda.model.Switch) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId)

Aggregations

FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)59 Flow (org.openkilda.model.Flow)33 FlowPath (org.openkilda.model.FlowPath)31 PathId (org.openkilda.model.PathId)23 MeterId (org.openkilda.model.MeterId)19 Test (org.junit.Test)15 PathSegment (org.openkilda.model.PathSegment)15 Switch (org.openkilda.model.Switch)15 ArrayList (java.util.ArrayList)8 SwitchId (org.openkilda.model.SwitchId)8 FlowEntry (org.openkilda.messaging.info.rule.FlowEntry)6 UUID (java.util.UUID)5 FlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory)5 IngressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.IngressFlowSegmentRequestFactory)5 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)5 DeleteRulesCriteria (org.openkilda.messaging.command.switches.DeleteRulesCriteria)4 MirrorConfig (org.openkilda.model.MirrorConfig)4 YFlow (org.openkilda.model.YFlow)4 Before (org.junit.Before)3 EgressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory)3