use of org.openkilda.model.Switch in project open-kilda by telstra.
the class SwitchConnectedDeviceFrame method getSwitchObj.
@Override
public Switch getSwitchObj() {
if (switchObj == null) {
List<? extends SwitchFrame> switchFrames = traverse(v -> v.in(HAS_BY_EDGE).hasLabel(SwitchFrame.FRAME_LABEL)).toListExplicit(SwitchFrame.class);
switchObj = !switchFrames.isEmpty() ? new Switch(switchFrames.get(0)) : null;
SwitchId switchId = switchObj != null ? switchObj.getSwitchId() : null;
if (!Objects.equals(getSwitchId(), switchId)) {
throw new IllegalStateException(format("The connected device %s has inconsistent switch %s / %s", getId(), getSwitchId(), switchId));
}
}
return switchObj;
}
use of org.openkilda.model.Switch in project open-kilda by telstra.
the class SwitchPropertiesFrame method getSwitchObj.
@Override
public Switch getSwitchObj() {
if (switchObj == null) {
List<? extends SwitchFrame> switchFrames = traverse(v -> v.in(HAS_BY_EDGE).hasLabel(SwitchFrame.FRAME_LABEL)).toListExplicit(SwitchFrame.class);
switchObj = !switchFrames.isEmpty() ? new Switch(switchFrames.get(0)) : null;
SwitchId switchId = switchObj != null ? switchObj.getSwitchId() : null;
if (!Objects.equals(getSwitchId(), switchId)) {
throw new IllegalStateException(format("The switch properties %s has inconsistent switch %s / %s", getId(), getSwitchId(), switchId));
}
}
return switchObj;
}
use of org.openkilda.model.Switch in project open-kilda by telstra.
the class PortPropertiesFrame method getSwitchObj.
@Override
public Switch getSwitchObj() {
if (switchObj == null) {
List<? extends SwitchFrame> switchFrames = traverse(v -> v.in(OWNS_SWITCH_EDGE).hasLabel(SwitchFrame.FRAME_LABEL)).toListExplicit(SwitchFrame.class);
switchObj = !switchFrames.isEmpty() ? new Switch(switchFrames.get(0)) : null;
SwitchId switchId = switchObj != null ? switchObj.getSwitchId() : null;
if (!Objects.equals(getSwitchId(), switchId)) {
throw new IllegalStateException(format("The port properties %s has inconsistent switch %s / %s", getId(), getSwitchId(), switchId));
}
}
return switchObj;
}
use of org.openkilda.model.Switch in project open-kilda by telstra.
the class FermaFlowRepositoryTest method shouldFind2SegmentFlowById.
@Test
public void shouldFind2SegmentFlowById() {
Switch switchC = createTestSwitch(TEST_SWITCH_C_ID.getId());
createTestFlowWithIntermediate(TEST_FLOW_ID, switchA, switchC, 100, switchB);
Optional<Flow> foundFlow = flowRepository.findById(TEST_FLOW_ID);
assertTrue(foundFlow.isPresent());
}
use of org.openkilda.model.Switch in project open-kilda by telstra.
the class FermaPortPropertiesRepositoryTest method shouldCreatePortPropertiesWithRelation.
@Test
public void shouldCreatePortPropertiesWithRelation() {
Switch origSwitch = createTestSwitch(TEST_SWITCH_ID.getId());
PortProperties portProperties = PortProperties.builder().switchObj(origSwitch).discoveryEnabled(false).build();
portPropertiesRepository.add(portProperties);
Collection<PortProperties> portPropertiesResult = portPropertiesRepository.findAll();
assertEquals(1, portPropertiesResult.size());
assertNotNull(portPropertiesResult.iterator().next().getSwitchObj());
}
Aggregations