Search in sources :

Example 6 with FlowMirrorPoints

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

the class FermaFlowMirrorPointsRepositoryTest method createTestFlowMirrorPoints.

private FlowMirrorPoints createTestFlowMirrorPoints() {
    FlowMirrorPoints flowMirrorPoints = FlowMirrorPoints.builder().mirrorGroup(mirrorGroup).mirrorSwitch(switchA).build();
    flowMirrorPointsRepository.add(flowMirrorPoints);
    return flowMirrorPoints;
}
Also used : FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints)

Example 7 with FlowMirrorPoints

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

the class SwitchOperationsService method validateSwitchProperties.

private void validateSwitchProperties(SwitchId switchId, SwitchProperties updatedSwitchProperties) {
    if (!updatedSwitchProperties.isMultiTable()) {
        String propertyErrorMessage = "Illegal switch properties combination for switch %s. '%s' property " + "can be set to 'true' only if 'multiTable' property is 'true'.";
        if (updatedSwitchProperties.isSwitchLldp()) {
            throw new IllegalSwitchPropertiesException(format(propertyErrorMessage, switchId, "switchLldp"));
        }
        if (updatedSwitchProperties.isSwitchArp()) {
            throw new IllegalSwitchPropertiesException(format(propertyErrorMessage, switchId, "switchArp"));
        }
        List<String> flowsWitchEnabledLldp = flowRepository.findByEndpointSwitchWithEnabledLldp(switchId).stream().map(Flow::getFlowId).collect(Collectors.toList());
        if (!flowsWitchEnabledLldp.isEmpty()) {
            throw new IllegalSwitchPropertiesException(format("Illegal switch properties combination for switch %s. " + "Detect Connected Devices feature is turn on for following flows [%s]. " + "For correct work of this feature switch property 'multiTable' must be set to 'true' " + "Please disable detecting of connected devices via LLDP for each flow before set " + "'multiTable' property to 'false'", switchId, String.join(", ", flowsWitchEnabledLldp)));
        }
        List<String> flowsWithEnabledArp = flowRepository.findByEndpointSwitchWithEnabledArp(switchId).stream().map(Flow::getFlowId).collect(Collectors.toList());
        if (!flowsWithEnabledArp.isEmpty()) {
            throw new IllegalSwitchPropertiesException(format("Illegal switch properties combination for switch %s. " + "Detect Connected Devices feature via ARP is turn on for following flows [%s]. " + "For correct work of this feature switch property 'multiTable' must be set to 'true' " + "Please disable detecting of connected devices via ARP for each flow before set " + "'multiTable' property to 'false'", switchId, String.join(", ", flowsWithEnabledArp)));
        }
    }
    if (updatedSwitchProperties.getServer42Port() != null) {
        Optional<PhysicalPort> physicalPort = physicalPortRepository.findBySwitchIdAndPortNumber(switchId, updatedSwitchProperties.getServer42Port());
        if (physicalPort.isPresent()) {
            throw new IllegalSwitchPropertiesException(format("Illegal server42 port '%d' on switch %s. This port is part of LAG '%d'. Please " + "delete LAG port or choose another server42 port.", updatedSwitchProperties.getServer42Port(), switchId, physicalPort.get().getLagLogicalPort().getLogicalPortNumber()));
        }
    }
    if (updatedSwitchProperties.isServer42FlowRtt()) {
        String errorMessage = "Illegal switch properties combination for switch %s. To enable property " + "'server42_flow_rtt' you need to specify valid property '%s'";
        if (updatedSwitchProperties.getServer42Port() == null) {
            throw new IllegalSwitchPropertiesException(format(errorMessage, switchId, "server42_port"));
        }
        if (updatedSwitchProperties.getServer42MacAddress() == null) {
            throw new IllegalSwitchPropertiesException(format(errorMessage, switchId, "server42_mac_address"));
        }
        if (updatedSwitchProperties.getServer42Vlan() == null) {
            throw new IllegalSwitchPropertiesException(format(errorMessage, switchId, "server42_vlan"));
        }
    }
    if (updatedSwitchProperties.getServer42IslRtt() == RttState.ENABLED) {
        String errorMessage = "Illegal switch properties combination for switch %s. To enable property " + "'server42_isl_rtt' you need to specify valid property '%s'";
        if (updatedSwitchProperties.getServer42Port() == null) {
            throw new IllegalSwitchPropertiesException(format(errorMessage, switchId, "server42_port"));
        }
        if (updatedSwitchProperties.getServer42MacAddress() == null) {
            throw new IllegalSwitchPropertiesException(format(errorMessage, switchId, "server42_mac_address"));
        }
        if (updatedSwitchProperties.getServer42Vlan() == null) {
            throw new IllegalSwitchPropertiesException(format(errorMessage, switchId, "server42_vlan"));
        }
    }
    Collection<FlowMirrorPoints> flowMirrorPoints = flowMirrorPointsRepository.findBySwitchId(switchId);
    if (!flowMirrorPoints.isEmpty() && (updatedSwitchProperties.isSwitchLldp() || updatedSwitchProperties.isSwitchArp())) {
        throw new IllegalSwitchPropertiesException(format("Flow mirror point is created on the switch %s, " + "switchLldp or switchArp can not be set to true.", switchId));
    }
    if (updatedSwitchProperties.getServer42Port() != null) {
        String errorMessage = "SwitchId '%s' and port '%d' belong to the %s endpoint. " + "Cannot specify port '%d' as port for server 42.";
        int server42port = updatedSwitchProperties.getServer42Port();
        Collection<Flow> flows = flowRepository.findByEndpoint(switchId, server42port);
        if (!flows.isEmpty()) {
            throw new IllegalSwitchPropertiesException(format(errorMessage, switchId, server42port, "flow", server42port));
        }
        Collection<FlowMirrorPath> flowMirrorPaths = flowMirrorPathRepository.findByEgressSwitchIdAndPort(switchId, server42port);
        if (!flowMirrorPaths.isEmpty()) {
            throw new IllegalSwitchPropertiesException(format(errorMessage, switchId, server42port, "flow mirror path", server42port));
        }
    }
}
Also used : IllegalSwitchPropertiesException(org.openkilda.wfm.error.IllegalSwitchPropertiesException) FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints) PhysicalPort(org.openkilda.model.PhysicalPort) IslEndpoint(org.openkilda.model.IslEndpoint) FlowMirrorPath(org.openkilda.model.FlowMirrorPath) Flow(org.openkilda.model.Flow)

Example 8 with FlowMirrorPoints

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

the class SwitchOperationsServiceTest method shouldValidateFlowMirrorPointsWhenUpdatingSwitchLldpProperties.

@Test(expected = IllegalSwitchPropertiesException.class)
public void shouldValidateFlowMirrorPointsWhenUpdatingSwitchLldpProperties() {
    Switch mirrorSwitch = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build();
    switchRepository.add(mirrorSwitch);
    MirrorGroup mirrorGroup = MirrorGroup.builder().switchId(TEST_SWITCH_ID).groupId(new GroupId(12L)).pathId(new PathId("test_path_id")).flowId(TEST_FLOW_ID_1).mirrorGroupType(MirrorGroupType.TRAFFIC_INTEGRITY).mirrorDirection(MirrorDirection.INGRESS).build();
    mirrorGroupRepository.add(mirrorGroup);
    FlowMirrorPoints flowMirrorPoints = FlowMirrorPoints.builder().mirrorGroup(mirrorGroup).mirrorSwitch(mirrorSwitch).build();
    flowMirrorPointsRepository.add(flowMirrorPoints);
    createSwitchProperties(mirrorSwitch, Collections.singleton(FlowEncapsulationType.TRANSIT_VLAN), true, false, false);
    SwitchPropertiesDto update = new SwitchPropertiesDto();
    update.setSupportedTransitEncapsulation(Collections.singleton(org.openkilda.messaging.payload.flow.FlowEncapsulationType.TRANSIT_VLAN));
    update.setMultiTable(true);
    update.setSwitchLldp(true);
    switchOperationsService.updateSwitchProperties(TEST_SWITCH_ID, update);
}
Also used : PathId(org.openkilda.model.PathId) SwitchPropertiesDto(org.openkilda.messaging.model.SwitchPropertiesDto) MirrorGroup(org.openkilda.model.MirrorGroup) Switch(org.openkilda.model.Switch) FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints) GroupId(org.openkilda.model.GroupId) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 9 with FlowMirrorPoints

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

the class EgressMirrorRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    List<SpeakerData> result = new ArrayList<>();
    if (flowPath.isOneSwitchFlow() || flowPath.getSegments().isEmpty()) {
        return result;
    }
    FlowMirrorPoints mirrorPoints = flowPath.getFlowMirrorPointsSet().stream().filter(points -> sw.getSwitchId().equals(points.getMirrorSwitchId())).findFirst().orElse(null);
    if (mirrorPoints == null) {
        return result;
    }
    PathSegment lastSegment = flowPath.getSegments().get(flowPath.getSegments().size() - 1);
    FlowEndpoint egressEndpoint = checkAndBuildEgressEndpoint(flow, flowPath, sw.getSwitchId());
    SpeakerData egressCommand = buildEgressCommand(sw, lastSegment.getDestPort(), egressEndpoint, mirrorPoints.getMirrorGroupId());
    result.add(egressCommand);
    SpeakerData groupCommand = buildGroup(sw, mirrorPoints, egressEndpoint.getPortNumber());
    result.add(groupCommand);
    egressCommand.getDependsOn().add(groupCommand.getUuid());
    return result;
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) ArrayList(java.util.ArrayList) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints) PathSegment(org.openkilda.model.PathSegment) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData)

Example 10 with FlowMirrorPoints

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

the class Utils method buildMirrorBuckets.

/**
 * Builds group buckets for flow mirror points (only for sink endpoints. Flow bucket must be build separately).
 */
public static List<Bucket> buildMirrorBuckets(FlowMirrorPoints flowMirrorPoints) {
    List<Bucket> buckets = new ArrayList<>();
    Set<MirrorConfigData> mirrorConfigDataSet = flowMirrorPoints.getMirrorPaths().stream().map(mirrorPath -> new MirrorConfigData(mirrorPath.getEgressPort(), mirrorPath.getEgressOuterVlan())).collect(Collectors.toSet());
    for (MirrorConfigData mirrorConfig : mirrorConfigDataSet) {
        Set<Action> actions = new HashSet<>(makeVlanReplaceActions(new ArrayList<>(), makeVlanStack(mirrorConfig.getMirrorVlan())));
        actions.add(new PortOutAction(new PortNumber(mirrorConfig.getMirrorPort())));
        buckets.add(Bucket.builder().writeActions(actions).watchGroup(WatchGroup.ANY).watchPort(WatchPort.ANY).build());
    }
    return buckets;
}
Also used : VXLAN_SRC_IPV4_ADDRESS(org.openkilda.rulemanager.Constants.VXLAN_SRC_IPV4_ADDRESS) FlowPath(org.openkilda.model.FlowPath) SwitchFeature(org.openkilda.model.SwitchFeature) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Action(org.openkilda.rulemanager.action.Action) SpecialPortType(org.openkilda.rulemanager.ProtoConstants.PortNumber.SpecialPortType) KILDA_OVS_PUSH_POP_MATCH_VXLAN(org.openkilda.model.SwitchFeature.KILDA_OVS_PUSH_POP_MATCH_VXLAN) OfMetadata(org.openkilda.rulemanager.OfMetadata) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) VXLAN_DST_IPV4_ADDRESS(org.openkilda.rulemanager.Constants.VXLAN_DST_IPV4_ADDRESS) Flow(org.openkilda.model.Flow) FlowEndpoint.makeVlanStack(org.openkilda.model.FlowEndpoint.makeVlanStack) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) ActionType(org.openkilda.rulemanager.action.ActionType) FlowSideAdapter(org.openkilda.adapter.FlowSideAdapter) WatchGroup(org.openkilda.rulemanager.group.WatchGroup) FlowEndpoint(org.openkilda.model.FlowEndpoint) Iterator(java.util.Iterator) FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints) WatchPort(org.openkilda.rulemanager.group.WatchPort) Set(java.util.Set) SpeakerData(org.openkilda.rulemanager.SpeakerData) NOVIFLOW_PUSH_POP_VXLAN(org.openkilda.model.SwitchFeature.NOVIFLOW_PUSH_POP_VXLAN) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Bucket(org.openkilda.rulemanager.group.Bucket) MacAddress(org.openkilda.model.MacAddress) List(java.util.List) FlowEndpoint.isVlanIdSet(org.openkilda.model.FlowEndpoint.isVlanIdSet) SwitchId(org.openkilda.model.SwitchId) MirrorConfigData(org.openkilda.model.MirrorConfig.MirrorConfigData) Optional(java.util.Optional) Field(org.openkilda.rulemanager.Field) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Bucket(org.openkilda.rulemanager.group.Bucket) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) ArrayList(java.util.ArrayList) MirrorConfigData(org.openkilda.model.MirrorConfig.MirrorConfigData) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) HashSet(java.util.HashSet) Sets.newHashSet(com.google.common.collect.Sets.newHashSet)

Aggregations

FlowMirrorPoints (org.openkilda.model.FlowMirrorPoints)26 Flow (org.openkilda.model.Flow)11 PathId (org.openkilda.model.PathId)10 FlowMirrorPath (org.openkilda.model.FlowMirrorPath)7 FlowPath (org.openkilda.model.FlowPath)7 SwitchId (org.openkilda.model.SwitchId)7 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 Switch (org.openkilda.model.Switch)6 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)6 FlowEndpoint (org.openkilda.model.FlowEndpoint)5 PathSegment (org.openkilda.model.PathSegment)5 List (java.util.List)4 Optional (java.util.Optional)4 Collectors (java.util.stream.Collectors)4 MirrorGroup (org.openkilda.model.MirrorGroup)4 Collections (java.util.Collections)3 Iterator (java.util.Iterator)3 FlowSideAdapter (org.openkilda.adapter.FlowSideAdapter)3 GroupId (org.openkilda.model.GroupId)3