Search in sources :

Example 21 with MessageContext

use of org.openkilda.messaging.MessageContext in project open-kilda by telstra.

the class SpeakerFlowSegmentRequestBuilder method makeTransitSegmentRequest.

private FlowSegmentRequestFactory makeTransitSegmentRequest(CommandContext context, FlowPath path, FlowTransitEncapsulation encapsulation, PathSegment ingress, PathSegment egress) {
    final PathSegmentSide inboundSide = makePathSegmentDestSide(ingress);
    final PathSegmentSide outboundSide = makePathSegmentSourceSide(egress);
    final IslEndpoint ingressEndpoint = inboundSide.getEndpoint();
    final IslEndpoint egressEndpoint = outboundSide.getEndpoint();
    assert ingressEndpoint.getSwitchId().equals(egressEndpoint.getSwitchId()) : "Only neighbor segments can be used for for transit segment request creation";
    UUID commandId = commandIdGenerator.generate();
    MessageContext messageContext = new MessageContext(commandId.toString(), context.getCorrelationId());
    return TransitFlowSegmentRequestFactory.builder().messageContext(messageContext).switchId(ingressEndpoint.getSwitchId()).metadata(makeMetadata(path, ensureEqualMultiTableFlag(inboundSide.isMultiTable(), outboundSide.isMultiTable(), String.format("Flow(id:%s, path:%s) have incompatible multi-table flags between segments %s " + "and %s", path.getFlow().getFlowId(), path.getPathId(), ingress, egress)))).ingressIslPort(ingressEndpoint.getPortNumber()).egressIslPort(egressEndpoint.getPortNumber()).encapsulation(encapsulation).build();
}
Also used : IslEndpoint(org.openkilda.model.IslEndpoint) MessageContext(org.openkilda.messaging.MessageContext) UUID(java.util.UUID)

Example 22 with MessageContext

use of org.openkilda.messaging.MessageContext 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 23 with MessageContext

use of org.openkilda.messaging.MessageContext 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 24 with MessageContext

use of org.openkilda.messaging.MessageContext in project open-kilda by telstra.

the class MeterVerifyCommandTest method shouldVerifyInaccurateMeterBandwidth.

@Test
public void shouldVerifyInaccurateMeterBandwidth() throws Exception {
    MeterConfig validConfig = new MeterConfig(new MeterId(1), 100);
    MeterVerifyCommand command1 = new MeterVerifyCommand(new MessageContext(), mapSwitchId(dpId), validConfig);
    switchFeaturesSetup(sw, SwitchFeature.METERS, SwitchFeature.INACCURATE_METER);
    SettableFuture<List<OFMeterConfigStatsReply>> statsReplyProxy = setupMeterConfigStatsReply();
    // for command2
    setupMeterConfigStatsReply();
    replayAll();
    CompletableFuture<MeterVerifyReport> result = command1.execute(commandProcessor);
    // make one more command with altered config, to produce meter config flags/bands
    MeterConfig invalidConfig = new MeterConfig(validConfig.getId(), validConfig.getBandwidth() + 1);
    MeterVerifyCommand command2 = new MeterVerifyCommand(command1.getMessageContext(), command1.getSwitchId(), invalidConfig);
    // must be executed, for let .setup() method to initialize all dependencies
    command2.execute(commandProcessor);
    OFMeterConfig reply = sw.getOFFactory().buildMeterConfig().setMeterId(validConfig.getId().getValue()).setFlags(command2.makeMeterFlags()).setEntries(command2.makeMeterBands()).build();
    statsReplyProxy.set(wrapMeterStatsReply(reply));
    verifySuccessCompletion(result);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) MessageContext(org.openkilda.messaging.MessageContext) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig) MeterConfig(org.openkilda.model.MeterConfig) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test) AbstractSpeakerCommandTest(org.openkilda.floodlight.command.AbstractSpeakerCommandTest)

Example 25 with MessageContext

use of org.openkilda.messaging.MessageContext in project open-kilda by telstra.

the class TransitFlowSegmentInstallCommandTest method makeCommand.

protected TransitFlowSegmentInstallCommand makeCommand(FlowTransitEncapsulation encapsulation, FlowSegmentMetadata metadata) {
    MessageContext messageContext = new MessageContext();
    UUID commandId = UUID.randomUUID();
    int ingressIslPort = 2;
    int egressIslPort = 4;
    return new TransitFlowSegmentInstallCommand(messageContext, mapSwitchId(dpIdNext), commandId, metadata, ingressIslPort, encapsulation, egressIslPort, null);
}
Also used : MessageContext(org.openkilda.messaging.MessageContext) UUID(java.util.UUID)

Aggregations

MessageContext (org.openkilda.messaging.MessageContext)28 UUID (java.util.UUID)13 FlowSegmentMetadata (org.openkilda.floodlight.model.FlowSegmentMetadata)9 SwitchId (org.openkilda.model.SwitchId)9 ArrayList (java.util.ArrayList)7 Cookie (org.openkilda.model.cookie.Cookie)6 EgressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory)5 InfoMessage (org.openkilda.messaging.info.InfoMessage)5 FlowEndpoint (org.openkilda.model.FlowEndpoint)5 MirrorConfig (org.openkilda.model.MirrorConfig)5 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)5 Session (org.openkilda.floodlight.service.session.Session)4 MeterConfig (org.openkilda.model.MeterConfig)4 MeterId (org.openkilda.model.MeterId)4 List (java.util.List)3 Optional (java.util.Optional)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 EgressMirrorFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.EgressMirrorFlowSegmentRequestFactory)3 FlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory)3 IngressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.IngressFlowSegmentRequestFactory)3