Search in sources :

Example 6 with LagLogicalPort

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

the class LagPortOperationService method deleteTransaction.

private LagLogicalPort deleteTransaction(SwitchId switchId, int logicalPortNumber) {
    LagLogicalPort port = ensureDeleteIsPossible(switchId, logicalPortNumber);
    log.info("Removing LAG logical port entry into DB: {}", port);
    lagLogicalPortRepository.remove(port);
    return port;
}
Also used : LagLogicalPort(org.openkilda.model.LagLogicalPort)

Example 7 with LagLogicalPort

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

the class LagPortOperationService method ensureDeleteIsPossible.

/**
 * Verify that LAG logical port can be removed (it exists and do not in use by any flow).
 */
public LagLogicalPort ensureDeleteIsPossible(SwitchId switchId, int logicalPortNumber) {
    // locate switch first to produce correct error if switch is missing
    Switch sw = querySwitch(switchId);
    Optional<LagLogicalPort> port = lagLogicalPortRepository.findBySwitchIdAndPortNumber(switchId, logicalPortNumber);
    if (!port.isPresent()) {
        throw new LagPortNotFoundException(switchId, logicalPortNumber);
    }
    List<String> occupiedBy = flowRepository.findByEndpoint(switchId, logicalPortNumber).stream().map(Flow::getFlowId).collect(Collectors.toList());
    if (!occupiedBy.isEmpty()) {
        throw new InvalidDataException(format("Couldn't delete LAG port '%d' from switch %s because flows '%s' " + "use it as endpoint", logicalPortNumber, switchId, occupiedBy));
    }
    if (!isSwitchLagCapable(sw)) {
        log.error("Processing request for remove existing LAG logical port #{} on switch {} without LAG support", logicalPortNumber, switchId);
    }
    return port.get();
}
Also used : Switch(org.openkilda.model.Switch) LagLogicalPort(org.openkilda.model.LagLogicalPort) LagPortNotFoundException(org.openkilda.wfm.topology.switchmanager.error.LagPortNotFoundException) InvalidDataException(org.openkilda.wfm.topology.switchmanager.error.InvalidDataException)

Example 8 with LagLogicalPort

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

the class LogicalPortMapperTest method mapLagLogicalPortTest.

@Test
public void mapLagLogicalPortTest() {
    LagLogicalPort lagLogicalPort = new LagLogicalPort(SWITCH_ID, LAG_PORT, Lists.newArrayList(PHYSICAL_PORT_1, PHYSICAL_PORT_2));
    LogicalPortInfoEntry port = INSTANCE.map(lagLogicalPort);
    assertEquals(LAG_PORT, port.getLogicalPortNumber().intValue());
    assertEquals(2, port.getPhysicalPorts().size());
    assertEquals(PHYSICAL_PORT_1, port.getPhysicalPorts().get(0).intValue());
    assertEquals(PHYSICAL_PORT_2, port.getPhysicalPorts().get(1).intValue());
    assertNull(port.getExpected());
    assertNull(port.getActual());
}
Also used : LogicalPortInfoEntry(org.openkilda.messaging.info.switches.LogicalPortInfoEntry) LagLogicalPort(org.openkilda.model.LagLogicalPort) Test(org.junit.Test)

Example 9 with LagLogicalPort

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

the class FermaPhysicalPortTest method createLogicalPort.

private LagLogicalPort createLogicalPort(SwitchId switchId, int logicalPortNumber) {
    LagLogicalPort port = new LagLogicalPort(switchId, logicalPortNumber, new ArrayList<Integer>());
    lagLogicalPortRepository.add(port);
    return port;
}
Also used : LagLogicalPort(org.openkilda.model.LagLogicalPort)

Example 10 with LagLogicalPort

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

the class FermaLagLogicalPortTest method removeLogicalPortTest.

@Test
public void removeLogicalPortTest() {
    LagLogicalPort logicalPort1 = createLogicalPort(SWITCH_ID_1, LOGICAL_PORT_NUMBER_1, PHYSICAL_PORT_NUMBER_1, PHYSICAL_PORT_NUMBER_2);
    LagLogicalPort logicalPort2 = createLogicalPort(SWITCH_ID_1, LOGICAL_PORT_NUMBER_1);
    transactionManager.doInTransaction(() -> lagLogicalPortRepository.remove(logicalPort2));
    List<LagLogicalPort> ports = new ArrayList<>(lagLogicalPortRepository.findAll());
    assertEquals(1, ports.size());
    assertEquals(2, ports.get(0).getPhysicalPorts().size());
    assertEquals(2, physicalPortRepository.findAll().size());
    transactionManager.doInTransaction(() -> lagLogicalPortRepository.remove(logicalPort1));
    assertEquals(0, lagLogicalPortRepository.findAll().size());
    assertEquals(0, physicalPortRepository.findAll().size());
}
Also used : LagLogicalPort(org.openkilda.model.LagLogicalPort) ArrayList(java.util.ArrayList) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Aggregations

LagLogicalPort (org.openkilda.model.LagLogicalPort)11 Test (org.junit.Test)6 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)4 ArrayList (java.util.ArrayList)3 Switch (org.openkilda.model.Switch)3 PhysicalPort (org.openkilda.model.PhysicalPort)2 InvalidDataException (org.openkilda.wfm.topology.switchmanager.error.InvalidDataException)2 LogicalPortInfoEntry (org.openkilda.messaging.info.switches.LogicalPortInfoEntry)1 LagPortDto (org.openkilda.messaging.nbtopology.response.LagPortDto)1 SwitchFeature (org.openkilda.model.SwitchFeature)1 LagPortNotFoundException (org.openkilda.wfm.topology.switchmanager.error.LagPortNotFoundException)1