Search in sources :

Example 1 with LagLogicalPort

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

the class FermaLagLogicalPortTest method createLogicalPortAndSetPhysicalPortsTest.

@Test
public void createLogicalPortAndSetPhysicalPortsTest() {
    LagLogicalPort logicalPort = createLogicalPort(SWITCH_ID_1, LOGICAL_PORT_NUMBER_1);
    assertEquals(0, lagLogicalPortRepository.findAll().iterator().next().getPhysicalPorts().size());
    PhysicalPort physicalPort1 = createPhysicalPort(SWITCH_ID_1, PHYSICAL_PORT_NUMBER_1, logicalPort);
    PhysicalPort physicalPort2 = createPhysicalPort(SWITCH_ID_1, PHYSICAL_PORT_NUMBER_2, logicalPort);
    logicalPort.setPhysicalPorts(Lists.newArrayList(physicalPort1, physicalPort2));
    List<LagLogicalPort> ports = new ArrayList<>(lagLogicalPortRepository.findAll());
    assertEquals(1, ports.size());
    assertEquals(2, ports.get(0).getPhysicalPorts().size());
    assertEquals(PHYSICAL_PORT_NUMBER_1, ports.get(0).getPhysicalPorts().get(0).getPortNumber());
    assertEquals(PHYSICAL_PORT_NUMBER_2, ports.get(0).getPhysicalPorts().get(1).getPortNumber());
    assertEquals(SWITCH_ID_1, ports.get(0).getPhysicalPorts().get(0).getSwitchId());
    assertEquals(SWITCH_ID_1, ports.get(0).getPhysicalPorts().get(1).getSwitchId());
    assertEquals(logicalPort, ports.get(0).getPhysicalPorts().get(0).getLagLogicalPort());
    assertEquals(logicalPort, ports.get(0).getPhysicalPorts().get(1).getLagLogicalPort());
}
Also used : LagLogicalPort(org.openkilda.model.LagLogicalPort) ArrayList(java.util.ArrayList) PhysicalPort(org.openkilda.model.PhysicalPort) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 2 with LagLogicalPort

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

the class FermaLagLogicalPortTest method createLogicalPort.

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

Example 3 with LagLogicalPort

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

the class LagPortMapperTest method mapLagPortToDtoTest.

@Test
public void mapLagPortToDtoTest() {
    LagLogicalPort lagLogicalPort = new LagLogicalPort(SWITCH_ID, LAG_PORT, Lists.newArrayList(PHYSICAL_PORT_1, PHYSICAL_PORT_2));
    LagPortDto dto = LagPortMapper.INSTANCE.map(lagLogicalPort);
    assertEquals(LAG_PORT, dto.getLogicalPortNumber());
    assertEquals(PHYSICAL_PORT_1, dto.getPortNumbers().get(0).intValue());
    assertEquals(PHYSICAL_PORT_2, dto.getPortNumbers().get(1).intValue());
}
Also used : LagPortDto(org.openkilda.messaging.nbtopology.response.LagPortDto) LagLogicalPort(org.openkilda.model.LagLogicalPort) Test(org.junit.Test)

Example 4 with LagLogicalPort

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

the class SwitchOperationsServiceTest method shouldReturnLagPorts.

@Test
public void shouldReturnLagPorts() throws SwitchNotFoundException {
    Switch sw = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build();
    switchRepository.add(sw);
    LagLogicalPort lagLogicalPort = new LagLogicalPort(TEST_SWITCH_ID, LAG_LOGICAL_PORT, Lists.newArrayList(PHYSICAL_PORT_1, PHYSICAL_PORT_2));
    lagLogicalPortRepository.add(lagLogicalPort);
    Collection<LagLogicalPort> ports = switchOperationsService.getSwitchLagPorts(TEST_SWITCH_ID);
    assertEquals(1, ports.size());
    assertEquals(LAG_LOGICAL_PORT, ports.iterator().next().getLogicalPortNumber());
    assertEquals(PHYSICAL_PORT_1, ports.iterator().next().getPhysicalPorts().get(0).getPortNumber());
    assertEquals(PHYSICAL_PORT_2, ports.iterator().next().getPhysicalPorts().get(1).getPortNumber());
}
Also used : Switch(org.openkilda.model.Switch) LagLogicalPort(org.openkilda.model.LagLogicalPort) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 5 with LagLogicalPort

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

the class LagPortOperationService method createTransaction.

private LagLogicalPort createTransaction(SwitchId switchId, Set<Integer> targetPorts) {
    // locate switch first to produce correct error if switch is missing
    Switch sw = querySwitch(switchId);
    if (!isSwitchLagCapable(sw)) {
        throw new InvalidDataException(format("Switch %s doesn't support LAG.", sw.getSwitchId()));
    }
    Set<SwitchFeature> features = sw.getFeatures();
    for (Integer portNumber : targetPorts) {
        validatePhysicalPort(switchId, features, portNumber);
    }
    ensureNoLagCollisions(switchId, targetPorts);
    LagLogicalPort port = queryPoolManager(switchId).allocate();
    port.setPhysicalPorts(targetPorts.stream().map(portNumber -> new PhysicalPort(switchId, portNumber, port)).collect(Collectors.toList()));
    log.info("Adding new LAG logical port entry into DB: {}", port);
    lagLogicalPortRepository.add(port);
    return port;
}
Also used : Switch(org.openkilda.model.Switch) LagLogicalPort(org.openkilda.model.LagLogicalPort) InvalidDataException(org.openkilda.wfm.topology.switchmanager.error.InvalidDataException) PhysicalPort(org.openkilda.model.PhysicalPort) SwitchFeature(org.openkilda.model.SwitchFeature)

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