Search in sources :

Example 6 with FlowSegmentMetadata

use of org.openkilda.floodlight.model.FlowSegmentMetadata in project open-kilda by telstra.

the class OneSwitchFlowCommandJsonTest method makeRequest.

@Override
protected OneSwitchFlowRequest makeRequest() {
    SwitchId swId = new SwitchId(1);
    OneSwitchFlowRequestFactory factory = new OneSwitchFlowRequestFactory(new MessageContext(), new FlowSegmentMetadata("single-switch-flow-install-request", new Cookie(2), false), new FlowEndpoint(swId, 3, 4), new MeterConfig(new MeterId(6), 7000), new FlowEndpoint(swId, 8, 9), RulesContext.builder().build(), MirrorConfig.builder().build());
    return makeRequest(factory);
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) FlowEndpoint(org.openkilda.model.FlowEndpoint) OneSwitchFlowRequestFactory(org.openkilda.floodlight.api.request.factory.OneSwitchFlowRequestFactory) SwitchId(org.openkilda.model.SwitchId) MessageContext(org.openkilda.messaging.MessageContext) MeterConfig(org.openkilda.model.MeterConfig) FlowSegmentMetadata(org.openkilda.floodlight.model.FlowSegmentMetadata) MeterId(org.openkilda.model.MeterId)

Example 7 with FlowSegmentMetadata

use of org.openkilda.floodlight.model.FlowSegmentMetadata in project open-kilda by telstra.

the class SpeakerFlowSegmentRequestBuilder method makeOneSwitchRequest.

private List<FlowSegmentRequestFactory> makeOneSwitchRequest(CommandContext context, FlowPath path, FlowSideAdapter ingressSide, FlowSideAdapter egressSide, RulesContext rulesContext, MirrorContext mirrorContext) {
    Flow flow = ingressSide.getFlow();
    UUID commandId = commandIdGenerator.generate();
    MessageContext messageContext = new MessageContext(commandId.toString(), context.getCorrelationId());
    FlowSegmentMetadata metadata = makeMetadata(path, ensureEqualMultiTableFlag(path.isSrcWithMultiTable(), path.isDestWithMultiTable(), String.format("Flow(id:%s) have incompatible for one-switch flow per-side multi-table flags - " + "src(%s) != dst(%s)", flow.getFlowId(), path.isSrcWithMultiTable(), path.isDestWithMultiTable())));
    List<FlowSegmentRequestFactory> oneSwitchFactories = new ArrayList<>();
    if (!mirrorContext.isBuildMirrorFactoryOnly()) {
        oneSwitchFactories.add(OneSwitchFlowRequestFactory.builder().messageContext(messageContext).metadata(metadata).endpoint(ingressSide.getEndpoint()).meterConfig(getMeterConfig(path)).egressEndpoint(egressSide.getEndpoint()).rulesContext(rulesContext).build());
    }
    Optional<MirrorConfig> mirrorConfig = makeMirrorConfig(path, egressSide.getEndpoint(), mirrorContext);
    if (mirrorConfig.isPresent() || mirrorContext.isRemoveFlowOperation()) {
        FlowSegmentCookie mirrorCookie = path.getCookie().toBuilder().mirror(true).build();
        oneSwitchFactories.add(OneSwitchMirrorFlowRequestFactory.builder().messageContext(new MessageContext(commandIdGenerator.generate().toString(), context.getCorrelationId())).metadata(makeMetadata(metadata.getFlowId(), mirrorCookie, metadata.isMultiTable())).endpoint(ingressSide.getEndpoint()).meterConfig(getMeterConfig(path)).egressEndpoint(egressSide.getEndpoint()).rulesContext(rulesContext).mirrorConfig(mirrorConfig.orElse(null)).build());
    }
    return oneSwitchFactories;
}
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 8 with FlowSegmentMetadata

use of org.openkilda.floodlight.model.FlowSegmentMetadata 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 9 with FlowSegmentMetadata

use of org.openkilda.floodlight.model.FlowSegmentMetadata 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 10 with FlowSegmentMetadata

use of org.openkilda.floodlight.model.FlowSegmentMetadata in project open-kilda by telstra.

the class EgressFlowSegmentInstallCommandTest method happyPathTransitVlanMultiTable.

@Test
public void happyPathTransitVlanMultiTable() throws Exception {
    EgressFlowSegmentInstallCommand command = makeCommand(endpointEgressSingleVlan, endpointIngressSingleVlan, encapsulationVlan, new FlowSegmentMetadata("egress-flow-segment-multitable", new Cookie(3), true));
    executeCommand(command, 1);
    OFFlowAdd expected = of.buildFlowAdd().setTableId(TableId.of(SwitchManager.EGRESS_TABLE_ID)).setPriority(EgressFlowSegmentInstallCommand.FLOW_PRIORITY).setCookie(U64.of(command.getCookie().getValue())).setMatch(OfAdapter.INSTANCE.matchVlanId(of, of.buildMatch(), command.getEncapsulation().getId()).setExact(MatchField.IN_PORT, OFPort.of(command.getIngressIslPort())).build()).setInstructions(ImmutableList.of(of.instructions().applyActions(ImmutableList.of(OfAdapter.INSTANCE.setVlanIdAction(of, command.getEndpoint().getOuterVlanId()), of.actions().buildOutput().setPort(OFPort.of(command.getEndpoint().getPortNumber())).build())))).build();
    verifyOfMessageEquals(expected, getWriteRecord(0).getRequest());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) FlowSegmentMetadata(org.openkilda.floodlight.model.FlowSegmentMetadata) OFFlowAdd(org.projectfloodlight.openflow.protocol.OFFlowAdd) Test(org.junit.Test)

Aggregations

FlowSegmentMetadata (org.openkilda.floodlight.model.FlowSegmentMetadata)11 MessageContext (org.openkilda.messaging.MessageContext)9 Cookie (org.openkilda.model.cookie.Cookie)6 UUID (java.util.UUID)5 EgressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory)4 FlowEndpoint (org.openkilda.model.FlowEndpoint)4 ArrayList (java.util.ArrayList)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 IngressMirrorFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.IngressMirrorFlowSegmentRequestFactory)3 TransitFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.TransitFlowSegmentRequestFactory)3 MirrorConfig (org.openkilda.model.MirrorConfig)3 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)3 Properties (java.util.Properties)2 IOFSwitchService (net.floodlightcontroller.core.internal.IOFSwitchService)2 FloodlightModuleContext (net.floodlightcontroller.core.module.FloodlightModuleContext)2 Test (org.junit.Test)2 PropertiesBasedConfigurationProvider (org.openkilda.config.provider.PropertiesBasedConfigurationProvider)2 KildaCore (org.openkilda.floodlight.KildaCore)2