Search in sources :

Example 16 with FlowEndpoint

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

the class FlowValidator method validateQinQonWB.

@VisibleForTesting
void validateQinQonWB(RequestedFlow requestedFlow) throws UnavailableFlowEndpointException, InvalidFlowException {
    final FlowEndpoint source = RequestedFlowMapper.INSTANCE.mapSource(requestedFlow);
    final FlowEndpoint destination = RequestedFlowMapper.INSTANCE.mapDest(requestedFlow);
    if (source.getInnerVlanId() != 0) {
        Switch srcSwitch = switchRepository.findById(source.getSwitchId()).orElseThrow(() -> new UnavailableFlowEndpointException(format("Endpoint switch not found %s", source.getSwitchId())));
        if (Switch.isNoviflowESwitch(srcSwitch.getOfDescriptionManufacturer(), srcSwitch.getOfDescriptionHardware())) {
            String message = format("QinQ feature is temporary disabled for WB-series switch '%s'", srcSwitch.getSwitchId());
            throw new InvalidFlowException(message, ErrorType.PARAMETERS_INVALID);
        }
    }
    if (destination.getInnerVlanId() != 0) {
        Switch destSwitch = switchRepository.findById(destination.getSwitchId()).orElseThrow(() -> new UnavailableFlowEndpointException(format("Endpoint switch not found %s", destination.getSwitchId())));
        if (Switch.isNoviflowESwitch(destSwitch.getOfDescriptionManufacturer(), destSwitch.getOfDescriptionHardware())) {
            String message = format("QinQ feature is temporary disabled for WB-series switch '%s'", destSwitch.getSwitchId());
            throw new InvalidFlowException(message, ErrorType.PARAMETERS_INVALID);
        }
    }
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) Switch(org.openkilda.model.Switch) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 17 with FlowEndpoint

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

the class FlowCreateServiceTest method shouldCreateOneSwitchFlow.

@Test
public void shouldCreateOneSwitchFlow() throws Exception {
    FlowRequest request = makeRequest().flowId("one_switch_flow").destination(new FlowEndpoint(SWITCH_SOURCE, 2, 2)).build();
    preparePathComputation(request.getFlowId(), makeOneSwitchPathPair());
    testHappyPath(request, "successful_flow_create");
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) Test(org.junit.Test)

Example 18 with FlowEndpoint

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

the class MultiTableIngressYRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    if (flow.isOneSwitchFlow()) {
        throw new IllegalStateException("Y-Flow rules can't be created for one switch flow");
    }
    List<SpeakerData> result = new ArrayList<>();
    FlowEndpoint ingressEndpoint = checkAndBuildIngressEndpoint(flow, flowPath, sw.getSwitchId());
    FlowSpeakerData command = buildFlowIngressCommand(sw, ingressEndpoint);
    if (command == null) {
        return Collections.emptyList();
    }
    result.add(command);
    if (generateMeterCommand) {
        SpeakerData meterCommand = buildMeter(externalMeterCommandUuid, flowPath, config, sharedMeterId, sw);
        if (meterCommand != null) {
            result.add(meterCommand);
            command.getDependsOn().add(externalMeterCommandUuid);
        }
    } else if (sw.getFeatures().contains(METERS) && sharedMeterId != null) {
        command.getDependsOn().add(externalMeterCommandUuid);
    }
    return result;
}
Also used : FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FlowEndpoint(org.openkilda.model.FlowEndpoint) ArrayList(java.util.ArrayList) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData)

Example 19 with FlowEndpoint

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

the class SingleTableServer42IngressRuleGenerator method buildMatch.

private Set<FieldMatch> buildMatch(FlowEndpoint ingressEndpoint) {
    int udpSrcPort = ingressEndpoint.getPortNumber() + config.getServer42FlowRttUdpPortOffset();
    Set<FieldMatch> match = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(switchProperties.getServer42Port()).build(), FieldMatch.builder().field(Field.ETH_SRC).value(switchProperties.getServer42MacAddress().toLong()).build(), FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.IPv4).build(), FieldMatch.builder().field(Field.IP_PROTO).value(IpProto.UDP).build(), FieldMatch.builder().field(Field.UDP_SRC).value(udpSrcPort).build());
    if (isVlanIdSet(ingressEndpoint.getOuterVlanId())) {
        match.add(FieldMatch.builder().field(Field.VLAN_VID).value(ingressEndpoint.getOuterVlanId()).build());
    }
    return match;
}
Also used : FieldMatch(org.openkilda.rulemanager.match.FieldMatch) FlowEndpoint(org.openkilda.model.FlowEndpoint)

Example 20 with FlowEndpoint

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

the class MultiTableServer42IngressRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    List<SpeakerData> result = new ArrayList<>();
    if (switchProperties == null || !switchProperties.isMultiTable() || !switchProperties.isServer42FlowRtt() || flowPath.isOneSwitchFlow()) {
        return result;
    }
    FlowEndpoint ingressEndpoint = getIngressEndpoint(sw.getSwitchId());
    result.add(buildServer42IngressCommand(sw, ingressEndpoint));
    if (needToBuildServer42PreIngressRule(ingressEndpoint)) {
        result.add(buildServer42PreIngressCommand(sw, ingressEndpoint));
    }
    if (needToBuildServer42InputRule(ingressEndpoint)) {
        result.add(buildServer42InputCommand(sw, ingressEndpoint.getPortNumber()));
    }
    return result;
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) ArrayList(java.util.ArrayList) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData)

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