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