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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations