Search in sources :

Example 1 with DetectConnectedDevicesDto

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

the class FlowMapper method toSwapOutput.

/**
 * Map {@link FlowDto} into {@link SwapFlowPayload}.
 */
public SwapFlowPayload toSwapOutput(FlowDto flowDto) {
    DetectConnectedDevicesDto connectedDevices = flowDto.getDetectConnectedDevices();
    FlowEndpointV2 source = generatedFlowSourceEndpointMap(flowDto);
    source.setDetectConnectedDevices(generatedFlowSourceEndpointConnectedDevicesMap(connectedDevices));
    FlowEndpointV2 destination = generatedFlowDestinationEndpointMap(flowDto);
    destination.setDetectConnectedDevices(generatedFlowDestinationEndpointConnectedDevicesMap(connectedDevices));
    SwapFlowPayload result = generatedSwapFlowPayloadMap(flowDto);
    result.setSource(source);
    result.setDestination(destination);
    return result;
}
Also used : DetectConnectedDevicesDto(org.openkilda.messaging.model.DetectConnectedDevicesDto) FlowEndpointV2(org.openkilda.northbound.dto.v2.flows.FlowEndpointV2) SwapFlowPayload(org.openkilda.northbound.dto.v2.flows.SwapFlowPayload)

Example 2 with DetectConnectedDevicesDto

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

the class FlowMapperTest method testFlowPairToDto.

@Test
public void testFlowPairToDto() {
    PathInfoData pathInfoData = new PathInfoData();
    pathInfoData.setLatency(1L);
    pathInfoData.setPath(asList(new PathNode(SRC_SWITCH_ID, 1, 1, 1L, 1L), new PathNode(DST_SWITCH_ID, 2, 2, 2L, 2L)));
    FlowDto forwardFlow = new FlowDto();
    forwardFlow.setSourceSwitch(SRC_SWITCH_ID);
    forwardFlow.setDestinationSwitch(DST_SWITCH_ID);
    forwardFlow.setFlowId("12");
    forwardFlow.setCookie(11);
    forwardFlow.setSourcePort(113);
    forwardFlow.setSourceVlan(1112);
    forwardFlow.setDestinationPort(113);
    forwardFlow.setDestinationVlan(1112);
    forwardFlow.setBandwidth(23);
    forwardFlow.setDescription("SOME FLOW");
    forwardFlow.setLastUpdated("2011-12-03T10:15:30Z");
    forwardFlow.setTransitEncapsulationId(87);
    forwardFlow.setMeterId(65);
    forwardFlow.setIgnoreBandwidth(true);
    forwardFlow.setPeriodicPings(true);
    forwardFlow.setEncapsulationType(FlowEncapsulationType.TRANSIT_VLAN);
    forwardFlow.setDetectConnectedDevices(new DetectConnectedDevicesDto(false, true, true, false, false, false, true, true));
    PathInfoData reversePathInfoData = new PathInfoData();
    reversePathInfoData.setLatency(1L);
    reversePathInfoData.setPath(asList(new PathNode(DST_SWITCH_ID, 2, 2, 2L, 2L), new PathNode(SRC_SWITCH_ID, 1, 1, 1L, 1L)));
    FlowDto reverseFlow = new FlowDto();
    reverseFlow.setSourceSwitch(forwardFlow.getDestinationSwitch());
    reverseFlow.setDestinationSwitch(SRC_SWITCH_ID);
    reverseFlow.setFlowId("12");
    reverseFlow.setCookie(12);
    reverseFlow.setSourcePort(113);
    reverseFlow.setSourceVlan(1112);
    reverseFlow.setDestinationPort(113);
    reverseFlow.setDestinationVlan(1112);
    reverseFlow.setBandwidth(23);
    reverseFlow.setDescription("SOME FLOW");
    reverseFlow.setLastUpdated("2011-12-03T10:15:30Z");
    reverseFlow.setTransitEncapsulationId(88);
    reverseFlow.setMeterId(66);
    reverseFlow.setIgnoreBandwidth(true);
    reverseFlow.setPeriodicPings(true);
    reverseFlow.setEncapsulationType(FlowEncapsulationType.TRANSIT_VLAN);
    reverseFlow.setDetectConnectedDevices(new DetectConnectedDevicesDto(true, false, false, true, false, false, true, true));
    FlowPairDto<FlowDto, FlowDto> pair = new FlowPairDto<>(forwardFlow, reverseFlow);
    Flow p = FlowMapper.INSTANCE.map(pair, () -> KildaConfiguration.DEFAULTS);
    assertEquals(p.getFlowId(), pair.getLeft().getFlowId());
    assertDetectConnectedDevices(forwardFlow.getDetectConnectedDevices(), p.getDetectConnectedDevices());
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) FlowDto(org.openkilda.messaging.model.FlowDto) DetectConnectedDevicesDto(org.openkilda.messaging.model.DetectConnectedDevicesDto) FlowPairDto(org.openkilda.messaging.model.FlowPairDto) PathNode(org.openkilda.messaging.info.event.PathNode) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 3 with DetectConnectedDevicesDto

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

the class RequestedFlowMapperTest method mapFlowToFlowRequestTest.

@Test
public void mapFlowToFlowRequestTest() {
    FlowRequest flowRequest = RequestedFlowMapper.INSTANCE.toFlowRequest(flow);
    assertEquals(FLOW_ID, flowRequest.getFlowId());
    assertEquals(SRC_SWITCH_ID, flowRequest.getSource().getSwitchId());
    assertEquals(SRC_PORT, (int) flowRequest.getSource().getPortNumber());
    assertEquals(SRC_VLAN, flowRequest.getSource().getOuterVlanId());
    assertEquals(DST_SWITCH_ID, flowRequest.getDestination().getSwitchId());
    assertEquals(DST_PORT, (int) flowRequest.getDestination().getPortNumber());
    assertEquals(DST_VLAN, flowRequest.getDestination().getOuterVlanId());
    assertEquals(PRIORITY, flowRequest.getPriority());
    assertEquals(DESCRIPTION, flowRequest.getDescription());
    assertEquals(BANDWIDTH, flowRequest.getBandwidth());
    assertEquals(MAX_LATENCY, flowRequest.getMaxLatency());
    assertEquals(org.openkilda.messaging.payload.flow.FlowEncapsulationType.TRANSIT_VLAN, flowRequest.getEncapsulationType());
    assertEquals(PATH_COMPUTATION_STRATEGY.toString().toLowerCase(), flowRequest.getPathComputationStrategy());
    assertTrue(flowRequest.isPinned());
    assertTrue(flowRequest.isAllocateProtectedPath());
    assertTrue(flowRequest.isIgnoreBandwidth());
    assertTrue(flowRequest.isPeriodicPings());
    assertEquals(new DetectConnectedDevicesDto(true, true, true, true, true, true, true, true), flowRequest.getDetectConnectedDevices());
}
Also used : FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) DetectConnectedDevicesDto(org.openkilda.messaging.model.DetectConnectedDevicesDto) Test(org.junit.Test)

Example 4 with DetectConnectedDevicesDto

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

the class FlowOperationsService method addChangedFields.

private FlowRequest addChangedFields(FlowRequest flowRequest, FlowPatch flowPatch) {
    boolean trackSrcLldp = flowRequest.getSource().isTrackLldpConnectedDevices();
    boolean trackSrcArp = flowRequest.getSource().isTrackArpConnectedDevices();
    PatchEndpoint source = flowPatch.getSource();
    if (source != null) {
        SwitchId switchId = Optional.ofNullable(source.getSwitchId()).orElse(flowRequest.getSource().getSwitchId());
        int port = Optional.ofNullable(source.getPortNumber()).orElse(flowRequest.getSource().getPortNumber());
        int vlan = Optional.ofNullable(source.getVlanId()).orElse(flowRequest.getSource().getOuterVlanId());
        int innerVlan = Optional.ofNullable(source.getInnerVlanId()).orElse(flowRequest.getSource().getInnerVlanId());
        trackSrcLldp = Optional.ofNullable(source.getTrackLldpConnectedDevices()).orElse(flowRequest.getSource().isTrackLldpConnectedDevices());
        trackSrcArp = Optional.ofNullable(source.getTrackArpConnectedDevices()).orElse(flowRequest.getSource().isTrackArpConnectedDevices());
        flowRequest.setSource(new FlowEndpoint(switchId, port, vlan, innerVlan));
    }
    boolean trackDstLldp = flowRequest.getDestination().isTrackLldpConnectedDevices();
    boolean trackDstArp = flowRequest.getDestination().isTrackArpConnectedDevices();
    PatchEndpoint destination = flowPatch.getDestination();
    if (destination != null) {
        SwitchId switchId = Optional.ofNullable(destination.getSwitchId()).orElse(flowRequest.getDestination().getSwitchId());
        int port = Optional.ofNullable(destination.getPortNumber()).orElse(flowRequest.getDestination().getPortNumber());
        int vlan = Optional.ofNullable(destination.getVlanId()).orElse(flowRequest.getDestination().getOuterVlanId());
        int innerVlan = Optional.ofNullable(destination.getInnerVlanId()).orElse(flowRequest.getDestination().getInnerVlanId());
        trackDstLldp = Optional.ofNullable(destination.getTrackLldpConnectedDevices()).orElse(flowRequest.getDestination().isTrackLldpConnectedDevices());
        trackDstArp = Optional.ofNullable(destination.getTrackArpConnectedDevices()).orElse(flowRequest.getDestination().isTrackArpConnectedDevices());
        flowRequest.setDestination(new FlowEndpoint(switchId, port, vlan, innerVlan));
    }
    flowRequest.setDetectConnectedDevices(new DetectConnectedDevicesDto(trackSrcLldp, trackSrcArp, trackDstLldp, trackDstArp));
    Optional.ofNullable(flowPatch.getBandwidth()).ifPresent(flowRequest::setBandwidth);
    Optional.ofNullable(flowPatch.getIgnoreBandwidth()).ifPresent(flowRequest::setIgnoreBandwidth);
    Optional.ofNullable(flowPatch.getAllocateProtectedPath()).ifPresent(flowRequest::setAllocateProtectedPath);
    Optional.ofNullable(flowPatch.getEncapsulationType()).map(FlowMapper.INSTANCE::map).ifPresent(flowRequest::setEncapsulationType);
    Optional.ofNullable(flowPatch.getPathComputationStrategy()).map(PathComputationStrategy::toString).ifPresent(flowRequest::setPathComputationStrategy);
    Optional.ofNullable(flowPatch.getDiverseFlowId()).ifPresent(flowRequest::setDiverseFlowId);
    return flowRequest;
}
Also used : RequestedFlowMapper(org.openkilda.wfm.share.mappers.RequestedFlowMapper) FlowMapper(org.openkilda.wfm.share.mappers.FlowMapper) FlowEndpoint(org.openkilda.model.FlowEndpoint) PatchEndpoint(org.openkilda.messaging.model.PatchEndpoint) DetectConnectedDevicesDto(org.openkilda.messaging.model.DetectConnectedDevicesDto) SwitchId(org.openkilda.model.SwitchId) FlowMirrorPoint(org.openkilda.messaging.nbtopology.response.FlowMirrorPointsDumpResponse.FlowMirrorPoint) IslEndpoint(org.openkilda.model.IslEndpoint) PatchEndpoint(org.openkilda.messaging.model.PatchEndpoint) FlowEndpoint(org.openkilda.model.FlowEndpoint)

Example 5 with DetectConnectedDevicesDto

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

the class RequestedFlowMapperTest method mapFlowToFlowRequestTest.

@Test
public void mapFlowToFlowRequestTest() {
    FlowRequest flowRequest = RequestedFlowMapper.INSTANCE.toFlowRequest(FLOW);
    assertEquals(FLOW_ID, flowRequest.getFlowId());
    assertEquals(SRC_SWITCH_ID, flowRequest.getSource().getSwitchId());
    assertEquals(SRC_PORT, flowRequest.getSource().getPortNumber());
    assertEquals(SRC_VLAN, flowRequest.getSource().getOuterVlanId());
    assertEquals(SRC_INNER_VLAN, flowRequest.getSource().getInnerVlanId());
    assertEquals(DST_SWITCH_ID, flowRequest.getDestination().getSwitchId());
    assertEquals(DST_PORT, flowRequest.getDestination().getPortNumber());
    assertEquals(DST_VLAN, flowRequest.getDestination().getOuterVlanId());
    assertEquals(DST_INNER_VLAN, flowRequest.getDestination().getInnerVlanId());
    assertEquals(PRIORITY, flowRequest.getPriority());
    assertEquals(DESCRIPTION, flowRequest.getDescription());
    assertEquals(BANDWIDTH, flowRequest.getBandwidth());
    assertEquals(MAX_LATENCY, flowRequest.getMaxLatency());
    assertEquals(MAX_LATENCY_TIER_2, flowRequest.getMaxLatencyTier2());
    assertEquals(org.openkilda.messaging.payload.flow.FlowEncapsulationType.TRANSIT_VLAN, flowRequest.getEncapsulationType());
    assertEquals(PATH_COMPUTATION_STRATEGY, flowRequest.getPathComputationStrategy());
    assertEquals(LOOP_SWITCH_ID, flowRequest.getLoopSwitchId());
    assertTrue(flowRequest.isPinned());
    assertTrue(flowRequest.isAllocateProtectedPath());
    assertTrue(flowRequest.isIgnoreBandwidth());
    assertTrue(flowRequest.isPeriodicPings());
    assertEquals(new DetectConnectedDevicesDto(true, true, true, true, true, true, true, true), flowRequest.getDetectConnectedDevices());
}
Also used : FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) DetectConnectedDevicesDto(org.openkilda.messaging.model.DetectConnectedDevicesDto) Test(org.junit.Test)

Aggregations

DetectConnectedDevicesDto (org.openkilda.messaging.model.DetectConnectedDevicesDto)6 Test (org.junit.Test)3 FlowRequest (org.openkilda.messaging.command.flow.FlowRequest)2 FlowEndpointV2 (org.openkilda.northbound.dto.v2.flows.FlowEndpointV2)2 PathInfoData (org.openkilda.messaging.info.event.PathInfoData)1 PathNode (org.openkilda.messaging.info.event.PathNode)1 FlowDto (org.openkilda.messaging.model.FlowDto)1 FlowPairDto (org.openkilda.messaging.model.FlowPairDto)1 PatchEndpoint (org.openkilda.messaging.model.PatchEndpoint)1 FlowMirrorPoint (org.openkilda.messaging.nbtopology.response.FlowMirrorPointsDumpResponse.FlowMirrorPoint)1 Flow (org.openkilda.model.Flow)1 FlowEndpoint (org.openkilda.model.FlowEndpoint)1 IslEndpoint (org.openkilda.model.IslEndpoint)1 SwitchId (org.openkilda.model.SwitchId)1 FlowResponseV2 (org.openkilda.northbound.dto.v2.flows.FlowResponseV2)1 SwapFlowPayload (org.openkilda.northbound.dto.v2.flows.SwapFlowPayload)1 FlowMapper (org.openkilda.wfm.share.mappers.FlowMapper)1 RequestedFlowMapper (org.openkilda.wfm.share.mappers.RequestedFlowMapper)1