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