Search in sources :

Example 41 with FlowEndpoint

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

the class SimpleSwitchRuleConverter method buildEgressSimpleSwitchRules.

private List<SimpleSwitchRule> buildEgressSimpleSwitchRules(Flow flow, FlowPath flowPath, PathSegment egressSegment, EncapsulationId encapsulationId) {
    List<SimpleSwitchRule> rules = new ArrayList<>();
    FlowSideAdapter egressAdapter = FlowSideAdapter.makeEgressAdapter(flow, flowPath);
    FlowEndpoint endpoint = egressAdapter.getEndpoint();
    SimpleSwitchRule rule = SimpleSwitchRule.builder().switchId(flowPath.getDestSwitchId()).outPort(endpoint.getPortNumber()).inPort(egressSegment.getDestPort()).cookie(flowPath.getCookie().getValue()).egressRule(true).build();
    if (flow.getEncapsulationType().equals(FlowEncapsulationType.TRANSIT_VLAN)) {
        rule.setInVlan(encapsulationId.getEncapsulationId());
        rule.setOutVlan(calcVlanSetSequence(Collections.singletonList(encapsulationId.getEncapsulationId()), endpoint.getVlanStack()));
    } else if (flow.getEncapsulationType().equals(FlowEncapsulationType.VXLAN)) {
        rule.setTunnelId(encapsulationId.getEncapsulationId());
        rule.setOutVlan(calcVlanSetSequence(Collections.emptyList(), endpoint.getVlanStack()));
    }
    if (egressAdapter.isLooped() && !flowPath.isProtected()) {
        rules.add(buildTransitLoopRuleForEgressSwitch(rule, flowPath));
    }
    rules.add(rule);
    Optional<FlowMirrorPoints> foundFlowMirrorPoints = flowPath.getFlowMirrorPointsSet().stream().filter(mirrorPoints -> mirrorPoints.getMirrorSwitchId().equals(egressSegment.getDestSwitchId())).findFirst();
    if (foundFlowMirrorPoints.isPresent()) {
        FlowMirrorPoints flowMirrorPoints = foundFlowMirrorPoints.get();
        rules.add(rule.toBuilder().outPort(0).cookie(flowPath.getCookie().toBuilder().mirror(true).build().getValue()).groupId(flowMirrorPoints.getMirrorGroupId().intValue()).groupBuckets(mapGroupBuckets(flowMirrorPoints.getMirrorPaths(), endpoint.getPortNumber(), 0, 0)).build());
    }
    return rules;
}
Also used : PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) ArrayList(java.util.ArrayList) Lists(com.google.common.collect.Lists) Flow(org.openkilda.model.Flow) SwitchFlowEntries(org.openkilda.messaging.info.rule.SwitchFlowEntries) FlowSideAdapter(org.openkilda.adapter.FlowSideAdapter) SwitchGroupEntries(org.openkilda.messaging.info.rule.SwitchGroupEntries) FlowEncapsulationType(org.openkilda.model.FlowEncapsulationType) FlowEndpoint(org.openkilda.model.FlowEndpoint) SimpleGroupBucket(org.openkilda.wfm.share.utils.rule.validation.SimpleSwitchRule.SimpleGroupBucket) Iterator(java.util.Iterator) GroupBucket(org.openkilda.messaging.info.rule.GroupBucket) FlowEntry(org.openkilda.messaging.info.rule.FlowEntry) FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints) SimpleSwitchRuleBuilder(org.openkilda.wfm.share.utils.rule.validation.SimpleSwitchRule.SimpleSwitchRuleBuilder) Collection(java.util.Collection) GroupEntry(org.openkilda.messaging.info.rule.GroupEntry) Collectors(java.util.stream.Collectors) SwitchMeterEntries(org.openkilda.messaging.info.meter.SwitchMeterEntries) FlowApplyActions(org.openkilda.messaging.info.rule.FlowApplyActions) Objects(java.util.Objects) List(java.util.List) SwitchId(org.openkilda.model.SwitchId) FlowSetFieldAction(org.openkilda.messaging.info.rule.FlowSetFieldAction) NumberUtils(org.apache.commons.lang3.math.NumberUtils) FlowMirrorPath(org.openkilda.model.FlowMirrorPath) Optional(java.util.Optional) Meter(org.openkilda.model.Meter) Comparator(java.util.Comparator) Collections(java.util.Collections) EncapsulationId(org.openkilda.model.EncapsulationId) FlowEndpoint(org.openkilda.model.FlowEndpoint) ArrayList(java.util.ArrayList) FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints) FlowSideAdapter(org.openkilda.adapter.FlowSideAdapter)

Example 42 with FlowEndpoint

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

the class FlowCommandFactory method buildInstallEgressMirrorFlow.

/**
 * Generate install egress mirror flow command.
 *
 * @param flowPath flow path with segments to be used for building of install rules.
 * @param inputPortNo the number of input port.
 * @param encapsulationResources the encapsulation resources.
 * @param multiTable use multi table.
 * @return install egress flow command
 */
public InstallEgressMirrorFlow buildInstallEgressMirrorFlow(FlowPath flowPath, int inputPortNo, EncapsulationResources encapsulationResources, boolean multiTable, MirrorConfig mirrorConfig) {
    Flow flow = flowPath.getFlow();
    FlowEndpoint ingressEndpoint = FlowSideAdapter.makeIngressAdapter(flow, flowPath).getEndpoint();
    FlowEndpoint egressEndpoint = FlowSideAdapter.makeEgressAdapter(flow, flowPath).getEndpoint();
    return new InstallEgressMirrorFlow(transactionIdGenerator.generate(), flow.getFlowId(), flowPath.getCookie().toBuilder().mirror(true).build().getValue(), egressEndpoint.getSwitchId(), inputPortNo, egressEndpoint.getPortNumber(), encapsulationResources.getTransitEncapsulationId(), encapsulationResources.getEncapsulationType(), egressEndpoint.getOuterVlanId(), egressEndpoint.getInnerVlanId(), getOutputVlanType(flow, flowPath), multiTable, ingressEndpoint, mirrorConfig);
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) InstallEgressMirrorFlow(org.openkilda.messaging.command.flow.InstallEgressMirrorFlow) InstallTransitFlow(org.openkilda.messaging.command.flow.InstallTransitFlow) InstallServer42IngressFlow(org.openkilda.messaging.command.flow.InstallServer42IngressFlow) InstallOneSwitchMirrorFlow(org.openkilda.messaging.command.flow.InstallOneSwitchMirrorFlow) Flow(org.openkilda.model.Flow) InstallIngressLoopFlow(org.openkilda.messaging.command.flow.InstallIngressLoopFlow) InstallIngressMirrorFlow(org.openkilda.messaging.command.flow.InstallIngressMirrorFlow) InstallTransitLoopFlow(org.openkilda.messaging.command.flow.InstallTransitLoopFlow) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) InstallEgressFlow(org.openkilda.messaging.command.flow.InstallEgressFlow) InstallEgressMirrorFlow(org.openkilda.messaging.command.flow.InstallEgressMirrorFlow) InstallIngressFlow(org.openkilda.messaging.command.flow.InstallIngressFlow)

Example 43 with FlowEndpoint

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

the class FlowCommandFactory method buildInstallIngressMirrorFlow.

/**
 * Generate install ingress flow command.
 *
 * @param flow the flow.
 * @param flowPath flow path with segments to be used for building of install rules.
 * @param outputPortNo the number of output port.
 * @param encapsulationResources the encapsulation resources.
 * @param multiTable  \
 * @return install ingress flow command
 */
public InstallIngressMirrorFlow buildInstallIngressMirrorFlow(Flow flow, FlowPath flowPath, int outputPortNo, EncapsulationResources encapsulationResources, boolean multiTable, MirrorConfig mirrorConfig) {
    boolean enableLldp = needToInstallOrRemoveLldpFlow(flowPath);
    boolean enableArp = needToInstallOrRemoveArpFlow(flowPath);
    Long meterId = Optional.ofNullable(flowPath.getMeterId()).map(MeterId::getValue).orElse(null);
    FlowEndpoint ingressEndpoint = FlowSideAdapter.makeIngressAdapter(flow, flowPath).getEndpoint();
    FlowEndpoint egressEndpoint = FlowSideAdapter.makeEgressAdapter(flow, flowPath).getEndpoint();
    return new InstallIngressMirrorFlow(transactionIdGenerator.generate(), flow.getFlowId(), flowPath.getCookie().toBuilder().mirror(true).build().getValue(), ingressEndpoint.getSwitchId(), ingressEndpoint.getPortNumber(), outputPortNo, ingressEndpoint.getOuterVlanId(), ingressEndpoint.getInnerVlanId(), encapsulationResources.getTransitEncapsulationId(), encapsulationResources.getEncapsulationType(), getOutputVlanType(flow, flowPath), flow.getBandwidth(), meterId, egressEndpoint.getSwitchId(), multiTable, enableLldp, enableArp, mirrorConfig);
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) InstallIngressMirrorFlow(org.openkilda.messaging.command.flow.InstallIngressMirrorFlow)

Example 44 with FlowEndpoint

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

the class FlowCommandFactory method buildInstallIngressLoopFlow.

/**
 * Generate install ingress flow loop command.
 *
 * @param flow the flow.
 * @param flowPath flow path with segments to be used for building of install rules.
 * @param encapsulationResources the encapsulation resources.
 * @param multiTable  \
 * @return install ingress flow command
 */
public InstallIngressLoopFlow buildInstallIngressLoopFlow(Flow flow, FlowPath flowPath, EncapsulationResources encapsulationResources, boolean multiTable) {
    FlowEndpoint ingressEndpoint = FlowSideAdapter.makeIngressAdapter(flow, flowPath).getEndpoint();
    FlowEndpoint egressEndpoint = FlowSideAdapter.makeEgressAdapter(flow, flowPath).getEndpoint();
    return new InstallIngressLoopFlow(transactionIdGenerator.generate(), flow.getFlowId(), flowPath.getCookie().toBuilder().looped(true).build().getValue(), ingressEndpoint.getSwitchId(), ingressEndpoint.getPortNumber(), 0, encapsulationResources.getTransitEncapsulationId(), encapsulationResources.getEncapsulationType(), egressEndpoint.getOuterVlanId(), egressEndpoint.getInnerVlanId(), getOutputVlanType(flow, flowPath), multiTable, ingressEndpoint, null);
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) InstallIngressLoopFlow(org.openkilda.messaging.command.flow.InstallIngressLoopFlow)

Example 45 with FlowEndpoint

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

the class FlowCommandFactory method makeOneSwitchRule.

/**
 * Generate install one switch flow command.
 *
 * @param flow the flow.
 * @param flowPath flow path with segments to be used for building of install rules.
 * @return install one switch flow command
 */
public InstallOneSwitchFlow makeOneSwitchRule(Flow flow, FlowPath flowPath) {
    boolean enableLldp = needToInstallOrRemoveLldpFlow(flowPath);
    boolean enableArp = needToInstallOrRemoveArpFlow(flowPath);
    boolean multiTable = flowPath.isSrcWithMultiTable();
    FlowEndpoint ingressEndpoint = FlowSideAdapter.makeIngressAdapter(flow, flowPath).getEndpoint();
    FlowEndpoint egressEndpoint = FlowSideAdapter.makeEgressAdapter(flow, flowPath).getEndpoint();
    Long meterId = Optional.ofNullable(flowPath.getMeterId()).map(MeterId::getValue).orElse(null);
    return new InstallOneSwitchFlow(transactionIdGenerator.generate(), flow.getFlowId(), flowPath.getCookie().getValue(), ingressEndpoint.getSwitchId(), ingressEndpoint.getPortNumber(), egressEndpoint.getPortNumber(), ingressEndpoint.getOuterVlanId(), ingressEndpoint.getInnerVlanId(), egressEndpoint.getOuterVlanId(), egressEndpoint.getInnerVlanId(), getOutputVlanType(flow, flowPath), flow.getBandwidth(), meterId, multiTable, enableLldp, enableArp, null);
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow)

Aggregations

FlowEndpoint (org.openkilda.model.FlowEndpoint)105 Test (org.junit.Test)26 Flow (org.openkilda.model.Flow)22 ArrayList (java.util.ArrayList)15 RoutingMetadata (org.openkilda.floodlight.utils.metadata.RoutingMetadata)12 YFlow (org.openkilda.model.YFlow)11 FlowPath (org.openkilda.model.FlowPath)10 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)9 SpeakerData (org.openkilda.rulemanager.SpeakerData)9 SwitchId (org.openkilda.model.SwitchId)8 YSubFlow (org.openkilda.model.YSubFlow)8 HashSet (java.util.HashSet)7 FlowSideAdapter (org.openkilda.adapter.FlowSideAdapter)7 FlowSourceAdapter (org.openkilda.adapter.FlowSourceAdapter)7 IngressFlowSegmentInstallCommand (org.openkilda.floodlight.command.flow.ingress.IngressFlowSegmentInstallCommand)7 EffectiveIds (org.openkilda.floodlight.model.EffectiveIds)7 FlowSegmentWrapperCommand (org.openkilda.floodlight.command.flow.FlowSegmentWrapperCommand)6 FlowProcessingException (org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException)6 OFFlowAdd (org.projectfloodlight.openflow.protocol.OFFlowAdd)6 MessageContext (org.openkilda.messaging.MessageContext)5