Search in sources :

Example 1 with SwitchFeature

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

the class LagPortOperationService method validatePhysicalPort.

private void validatePhysicalPort(SwitchId switchId, Set<SwitchFeature> features, Integer portNumber) throws InvalidDataException {
    if (portNumber == null || portNumber <= 0) {
        throw new InvalidDataException(format("Invalid physical port number %s. It can't be null or negative.", portNumber));
    }
    int bfdPortOffset = config.getBfdPortOffset();
    int bfdPortMaxNumber = config.getBfdPortMaxNumber();
    if (features.contains(BFD) && portNumber >= bfdPortOffset && portNumber <= bfdPortMaxNumber) {
        throw new InvalidDataException(format("Physical port number %d intersects with BFD port range [%d, %d]", portNumber, bfdPortOffset, bfdPortMaxNumber));
    }
    long lagPortOffset = config.getPoolConfig().getIdMinimum();
    if (portNumber >= lagPortOffset) {
        throw new InvalidDataException(format("Physical port number %d can't be greater than LAG port offset %d.", portNumber, lagPortOffset));
    }
    Collection<Isl> isls = islRepository.findByEndpoint(switchId, portNumber);
    if (!isls.isEmpty()) {
        throw new InvalidDataException(format("Physical port number %d intersects with existing ISLs %s.", portNumber, isls));
    }
    Optional<SwitchProperties> properties = switchPropertiesRepository.findBySwitchId(switchId);
    if (properties.isPresent() && Objects.equals(properties.get().getServer42Port(), portNumber)) {
        throw new InvalidDataException(format("Physical port number %d on switch %s is server42 port.", portNumber, switchId));
    }
    Set<String> flowIds = flowRepository.findByEndpoint(switchId, portNumber).stream().map(Flow::getFlowId).collect(Collectors.toSet());
    if (!flowIds.isEmpty()) {
        throw new InvalidDataException(format("Physical port %d already used by following flows: %s. You must " + "remove these flows to be able to use the port in LAG.", portNumber, flowIds));
    }
    Collection<FlowMirrorPath> mirrorPaths = flowMirrorPathRepository.findByEgressSwitchIdAndPort(switchId, portNumber);
    if (!mirrorPaths.isEmpty()) {
        Map<String, List<PathId>> mirrorPathByFLowIdMap = new HashMap<>();
        for (FlowMirrorPath path : mirrorPaths) {
            String flowId = path.getFlowMirrorPoints().getFlowPath().getFlowId();
            mirrorPathByFLowIdMap.computeIfAbsent(flowId, ignore -> new ArrayList<>());
            mirrorPathByFLowIdMap.get(flowId).add(path.getPathId());
        }
        String message = mirrorPathByFLowIdMap.entrySet().stream().map(entry -> format("flow '%s': %s", entry.getKey(), entry.getValue())).collect(Collectors.joining(", "));
        throw new InvalidDataException(format("Physical port %d already used as sink by following mirror points %s", portNumber, message));
    }
}
Also used : TransactionManager(org.openkilda.persistence.tx.TransactionManager) SwitchFeature(org.openkilda.model.SwitchFeature) LRUMap(org.apache.commons.collections4.map.LRUMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) SwitchNotFoundException(org.openkilda.wfm.topology.switchmanager.error.SwitchNotFoundException) Flow(org.openkilda.model.Flow) PoolManager(org.openkilda.wfm.share.utils.PoolManager) IslRepository(org.openkilda.persistence.repositories.IslRepository) Map(java.util.Map) FlowRepository(org.openkilda.persistence.repositories.FlowRepository) LagLogicalPort(org.openkilda.model.LagLogicalPort) LagPortNotFoundException(org.openkilda.wfm.topology.switchmanager.error.LagPortNotFoundException) PathId(org.openkilda.model.PathId) SwitchProperties(org.openkilda.model.SwitchProperties) IpSocketAddress(org.openkilda.model.IpSocketAddress) Switch(org.openkilda.model.Switch) PhysicalPortRepository(org.openkilda.persistence.repositories.PhysicalPortRepository) InconsistentDataException(org.openkilda.wfm.topology.switchmanager.error.InconsistentDataException) NonNull(lombok.NonNull) Collection(java.util.Collection) SetView(com.google.common.collect.Sets.SetView) Set(java.util.Set) RetryPolicy(net.jodah.failsafe.RetryPolicy) BFD(org.openkilda.model.SwitchFeature.BFD) FlowMirrorPathRepository(org.openkilda.persistence.repositories.FlowMirrorPathRepository) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Sets(com.google.common.collect.Sets) Objects(java.util.Objects) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) SwitchPropertiesRepository(org.openkilda.persistence.repositories.SwitchPropertiesRepository) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) SwitchId(org.openkilda.model.SwitchId) LagLogicalPortRepository(org.openkilda.persistence.repositories.LagLogicalPortRepository) FlowMirrorPath(org.openkilda.model.FlowMirrorPath) InvalidDataException(org.openkilda.wfm.topology.switchmanager.error.InvalidDataException) Optional(java.util.Optional) ConstraintViolationException(org.openkilda.persistence.exceptions.ConstraintViolationException) Isl(org.openkilda.model.Isl) PhysicalPort(org.openkilda.model.PhysicalPort) SwitchRepository(org.openkilda.persistence.repositories.SwitchRepository) Isl(org.openkilda.model.Isl) HashMap(java.util.HashMap) InvalidDataException(org.openkilda.wfm.topology.switchmanager.error.InvalidDataException) ArrayList(java.util.ArrayList) List(java.util.List) SwitchProperties(org.openkilda.model.SwitchProperties) FlowMirrorPath(org.openkilda.model.FlowMirrorPath)

Example 2 with SwitchFeature

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

the class MaxBurstCoefficientLimitationFeature method discover.

@Override
public Optional<SwitchFeature> discover(IOFSwitch sw) {
    Optional<SwitchFeature> empty = Optional.empty();
    SwitchDescription description = sw.getSwitchDescription();
    if (description == null || description.getSoftwareDescription() == null || description.getHardwareDescription() == null) {
        return empty;
    }
    if (NOVIFLOW_SOFTWARE_DESCRIPTION_REGEX.matcher(description.getSoftwareDescription()).matches() && !E_SWITCH_HARDWARE_DESCRIPTION_REGEX.matcher(description.getHardwareDescription()).matches()) {
        return Optional.of(SwitchFeature.MAX_BURST_COEFFICIENT_LIMITATION);
    }
    return Optional.empty();
}
Also used : SwitchDescription(net.floodlightcontroller.core.SwitchDescription) SwitchFeature(org.openkilda.model.SwitchFeature)

Example 3 with SwitchFeature

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

the class FeatureDetectorServiceTest method discoveryContain.

private void discoveryContain(IOFSwitch sw, SwitchFeature... expectedFeatules) {
    replayAll();
    Set<SwitchFeature> actualFeatures = featuresDetector.detectSwitch(sw);
    for (SwitchFeature expected : expectedFeatules) {
        Assert.assertTrue(actualFeatures.contains(expected));
    }
}
Also used : SwitchFeature(org.openkilda.model.SwitchFeature)

Example 4 with SwitchFeature

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

the class BfdCommand method checkSwitchCapabilities.

protected void checkSwitchCapabilities(IOFSwitch sw) throws NoFeatureException {
    Set<SwitchFeature> features = featureDetector.detectSwitch(sw);
    final SwitchFeature requiredFeature = SwitchFeature.BFD;
    if (!features.contains(requiredFeature)) {
        throw new NoFeatureException(sw.getId(), requiredFeature, features);
    }
}
Also used : NoFeatureException(org.openkilda.floodlight.error.NoFeatureException) SwitchFeature(org.openkilda.model.SwitchFeature)

Example 5 with SwitchFeature

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

the class SwitchManager method removeMultitableEndpointIslRules.

@Override
public List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port) throws SwitchOperationException {
    IOFSwitch sw = lookupSwitch(dpid);
    List<Long> removedFlows = new ArrayList<>();
    Set<SwitchFeature> features = featureDetectorService.detectSwitch(sw);
    if (features.contains(NOVIFLOW_PUSH_POP_VXLAN) || features.contains(KILDA_OVS_PUSH_POP_MATCH_VXLAN)) {
        removedFlows.add(removeEgressIslVxlanRule(dpid, port));
        removedFlows.add(removeTransitIslVxlanRule(dpid, port));
    } else {
        logger.info("Skip removing of isl multitable vxlan rule for switch {} {}", dpid, port);
    }
    removedFlows.add(removeEgressIslVlanRule(dpid, port));
    return removedFlows;
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) ArrayList(java.util.ArrayList) SwitchFeature(org.openkilda.model.SwitchFeature)

Aggregations

SwitchFeature (org.openkilda.model.SwitchFeature)23 ArrayList (java.util.ArrayList)7 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)7 OFFlowMod (org.projectfloodlight.openflow.protocol.OFFlowMod)6 Match (org.projectfloodlight.openflow.protocol.match.Match)5 Instructions (org.openkilda.rulemanager.Instructions)4 OFAction (org.projectfloodlight.openflow.protocol.action.OFAction)4 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)3 SwitchDescription (net.floodlightcontroller.core.SwitchDescription)3 Cookie (org.openkilda.model.cookie.Cookie)3 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)3 HashSet (java.util.HashSet)2 RoutingMetadata (org.openkilda.floodlight.utils.metadata.RoutingMetadata)2 IpSocketAddress (org.openkilda.model.IpSocketAddress)2 LagLogicalPort (org.openkilda.model.LagLogicalPort)2 PhysicalPort (org.openkilda.model.PhysicalPort)2 Switch (org.openkilda.model.Switch)2 PortColourCookie (org.openkilda.model.cookie.PortColourCookie)2 Sets (com.google.common.collect.Sets)1 SetView (com.google.common.collect.Sets.SetView)1