Search in sources :

Example 6 with FlowMirrorPath

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

the class FermaFlowMirrorPathRepositoryTest method createTestFlowPaths.

private void createTestFlowPaths() {
    FlowMirrorPath pathA = createFlowPath(TEST_MIRROR_PATH_ID_1, 1, switchA, switchB, 2, 3, 4);
    FlowMirrorPath pathB = createFlowPath(TEST_MIRROR_PATH_ID_2, 2, switchA, switchC, 3, 4, 5);
    flowMirrorPoints.addPaths(pathA, pathB);
}
Also used : FlowMirrorPath(org.openkilda.model.FlowMirrorPath)

Example 7 with FlowMirrorPath

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

the class FermaFlowMirrorPathRepositoryTest method shouldFindByDestEndpoint.

@Test
public void shouldFindByDestEndpoint() {
    createTestFlowPaths();
    FlowMirrorPath foundPath = flowMirrorPathRepository.findByEgressEndpoint(switchC.getSwitchId(), 3, 4, 5).get();
    assertEquals(switchA.getSwitchId(), foundPath.getMirrorSwitchId());
    assertEquals(switchC.getSwitchId(), foundPath.getEgressSwitchId());
}
Also used : FlowMirrorPath(org.openkilda.model.FlowMirrorPath) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 8 with FlowMirrorPath

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

the class FermaFlowMirrorPathRepositoryTest method shouldFindByEgressSwitchIdAndPort.

@Test
public void shouldFindByEgressSwitchIdAndPort() {
    FlowMirrorPath pathA = createFlowPath(TEST_MIRROR_PATH_ID_1, 1, switchA, switchB, 2, 3, 4);
    FlowMirrorPath pathB = createFlowPath(TEST_MIRROR_PATH_ID_2, 2, switchA, switchC, 3, 4, 5);
    FlowMirrorPath pathC = createFlowPath(TEST_MIRROR_PATH_ID_3, 3, switchB, switchC, 3, 5, 6);
    flowMirrorPoints.addPaths(pathA, pathB, pathC);
    List<FlowMirrorPath> foundPaths = new ArrayList<>(flowMirrorPathRepository.findByEgressSwitchIdAndPort(switchC.getSwitchId(), 3));
    assertEquals(2, foundPaths.size());
    assertEquals(switchA.getSwitchId(), foundPaths.get(1).getMirrorSwitchId());
    assertEquals(switchC.getSwitchId(), foundPaths.get(1).getEgressSwitchId());
    assertEquals(switchB.getSwitchId(), foundPaths.get(0).getMirrorSwitchId());
    assertEquals(switchC.getSwitchId(), foundPaths.get(0).getEgressSwitchId());
}
Also used : ArrayList(java.util.ArrayList) FlowMirrorPath(org.openkilda.model.FlowMirrorPath) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 9 with FlowMirrorPath

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

the class FermaFlowMirrorPathRepositoryTest method shouldCreateFlowMirrorPaths.

@Test
public void shouldCreateFlowMirrorPaths() {
    createTestFlowPaths();
    Collection<FlowMirrorPath> allPaths = flowMirrorPathRepository.findAll();
    assertThat(allPaths, hasSize(2));
    FlowMirrorPath foundPath = flowMirrorPathRepository.findById(TEST_MIRROR_PATH_ID_1).get();
    assertEquals(switchA.getSwitchId(), foundPath.getMirrorSwitchId());
    assertEquals(switchB.getSwitchId(), foundPath.getEgressSwitchId());
    FlowMirrorPoints flowMirrorPoints = flowMirrorPointsRepository.findByGroupId(TEST_GROUP_ID).get();
    assertThat(flowMirrorPoints.getMirrorPaths(), hasSize(2));
}
Also used : FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints) FlowMirrorPath(org.openkilda.model.FlowMirrorPath) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 10 with FlowMirrorPath

use of org.openkilda.model.FlowMirrorPath 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)

Aggregations

FlowMirrorPath (org.openkilda.model.FlowMirrorPath)18 Flow (org.openkilda.model.Flow)6 PathId (org.openkilda.model.PathId)6 Test (org.junit.Test)5 FlowMirrorPoints (org.openkilda.model.FlowMirrorPoints)5 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)5 Switch (org.openkilda.model.Switch)4 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)3 FlowProcessingException (org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException)3 ArrayList (java.util.ArrayList)2 InfoMessage (org.openkilda.messaging.info.InfoMessage)2 FlowMirrorPointResponse (org.openkilda.messaging.info.flow.FlowMirrorPointResponse)2 FlowPath (org.openkilda.model.FlowPath)2 PhysicalPort (org.openkilda.model.PhysicalPort)2 SwitchProperties (org.openkilda.model.SwitchProperties)2 Sets (com.google.common.collect.Sets)1 SetView (com.google.common.collect.Sets.SetView)1 String.format (java.lang.String.format)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1