Search in sources :

Example 1 with FlowMirrorPoint

use of org.openkilda.messaging.nbtopology.response.FlowMirrorPointsDumpResponse.FlowMirrorPoint in project open-kilda by telstra.

the class FlowOperationsBolt method processFlowMirrorPointsDumpRequest.

private List<FlowMirrorPointsDumpResponse> processFlowMirrorPointsDumpRequest(FlowMirrorPointsDumpRequest readRequest) {
    try {
        String flowId = readRequest.getFlowId();
        List<FlowMirrorPoint> points = flowOperationsService.getFlowMirrorPoints(flowId);
        FlowMirrorPointsDumpResponse response = FlowMirrorPointsDumpResponse.builder().flowId(flowId).points(points).build();
        return Collections.singletonList(response);
    } catch (FlowNotFoundException e) {
        throw new MessageException(ErrorType.NOT_FOUND, "Can not get flow mirror points: " + e.getMessage(), "Flow not found");
    } catch (Exception e) {
        throw new MessageException(ErrorType.INTERNAL_ERROR, "Can not get flow mirror points: " + e.getMessage(), "Internal Error");
    }
}
Also used : FlowMirrorPoint(org.openkilda.messaging.nbtopology.response.FlowMirrorPointsDumpResponse.FlowMirrorPoint) FlowNotFoundException(org.openkilda.wfm.error.FlowNotFoundException) FlowMirrorPointsDumpResponse(org.openkilda.messaging.nbtopology.response.FlowMirrorPointsDumpResponse) MessageException(org.openkilda.messaging.error.MessageException) IslNotFoundException(org.openkilda.wfm.error.IslNotFoundException) SwitchNotFoundException(org.openkilda.wfm.error.SwitchNotFoundException) MessageException(org.openkilda.messaging.error.MessageException) FlowNotFoundException(org.openkilda.wfm.error.FlowNotFoundException)

Example 2 with FlowMirrorPoint

use of org.openkilda.messaging.nbtopology.response.FlowMirrorPointsDumpResponse.FlowMirrorPoint in project open-kilda by telstra.

the class FlowMapperTest method testFlowMirrorPointsDumpResponseToFlowMirrorPointsResponseV2.

@Test
public void testFlowMirrorPointsDumpResponseToFlowMirrorPointsResponseV2() {
    FlowMirrorPoint firstPoint = FlowMirrorPoint.builder().mirrorPointId(MIRROR_POINT_ID_A).mirrorPointDirection(MIRROR_POINT_DIRECTION_A).mirrorPointSwitchId(SRC_SWITCH_ID).sinkEndpoint(FlowEndpoint.builder().switchId(SRC_SWITCH_ID).portNumber(SRC_PORT).outerVlanId(SRC_VLAN).innerVlanId(SRC_INNER_VLAN).build()).build();
    FlowMirrorPoint secondPoint = FlowMirrorPoint.builder().mirrorPointId(MIRROR_POINT_ID_B).mirrorPointDirection(MIRROR_POINT_DIRECTION_B).mirrorPointSwitchId(SRC_SWITCH_ID).sinkEndpoint(FlowEndpoint.builder().switchId(DST_SWITCH_ID).portNumber(DST_PORT).outerVlanId(DST_VLAN).innerVlanId(DST_INNER_VLAN).build()).build();
    List<FlowMirrorPoint> points = Lists.newArrayList(firstPoint, secondPoint);
    FlowMirrorPointsDumpResponse response = FlowMirrorPointsDumpResponse.builder().flowId(FLOW_ID).points(points).build();
    FlowMirrorPointsResponseV2 apiResponse = flowMapper.toFlowMirrorPointsResponseV2(response);
    assertEquals(response.getFlowId(), apiResponse.getFlowId());
    assertEquals(2, apiResponse.getPoints().size());
    FlowMirrorPointPayload firstPayload = apiResponse.getPoints().get(0);
    assertEquals(firstPoint.getMirrorPointId(), firstPayload.getMirrorPointId());
    assertEquals(firstPoint.getMirrorPointDirection(), firstPayload.getMirrorPointDirection());
    assertEquals(firstPoint.getMirrorPointSwitchId(), firstPayload.getMirrorPointSwitchId());
    assertEquals(firstPoint.getSinkEndpoint().getSwitchId(), firstPayload.getSinkEndpoint().getSwitchId());
    assertEquals(firstPoint.getSinkEndpoint().getPortNumber(), firstPayload.getSinkEndpoint().getPortNumber());
    assertEquals(firstPoint.getSinkEndpoint().getOuterVlanId(), firstPayload.getSinkEndpoint().getVlanId());
    assertEquals(firstPoint.getSinkEndpoint().getInnerVlanId(), firstPayload.getSinkEndpoint().getInnerVlanId());
    FlowMirrorPointPayload secondPayload = apiResponse.getPoints().get(1);
    assertEquals(secondPoint.getMirrorPointId(), secondPayload.getMirrorPointId());
    assertEquals(secondPoint.getMirrorPointDirection(), secondPayload.getMirrorPointDirection());
    assertEquals(secondPoint.getMirrorPointSwitchId(), secondPayload.getMirrorPointSwitchId());
    assertEquals(secondPoint.getSinkEndpoint().getSwitchId(), secondPayload.getSinkEndpoint().getSwitchId());
    assertEquals(secondPoint.getSinkEndpoint().getPortNumber(), secondPayload.getSinkEndpoint().getPortNumber());
    assertEquals(secondPoint.getSinkEndpoint().getOuterVlanId(), secondPayload.getSinkEndpoint().getVlanId());
    assertEquals(secondPoint.getSinkEndpoint().getInnerVlanId(), secondPayload.getSinkEndpoint().getInnerVlanId());
}
Also used : FlowMirrorPoint(org.openkilda.messaging.nbtopology.response.FlowMirrorPointsDumpResponse.FlowMirrorPoint) FlowMirrorPointsDumpResponse(org.openkilda.messaging.nbtopology.response.FlowMirrorPointsDumpResponse) FlowMirrorPointPayload(org.openkilda.northbound.dto.v2.flows.FlowMirrorPointPayload) FlowMirrorPointsResponseV2(org.openkilda.northbound.dto.v2.flows.FlowMirrorPointsResponseV2) Test(org.junit.Test)

Aggregations

FlowMirrorPointsDumpResponse (org.openkilda.messaging.nbtopology.response.FlowMirrorPointsDumpResponse)2 FlowMirrorPoint (org.openkilda.messaging.nbtopology.response.FlowMirrorPointsDumpResponse.FlowMirrorPoint)2 Test (org.junit.Test)1 MessageException (org.openkilda.messaging.error.MessageException)1 FlowMirrorPointPayload (org.openkilda.northbound.dto.v2.flows.FlowMirrorPointPayload)1 FlowMirrorPointsResponseV2 (org.openkilda.northbound.dto.v2.flows.FlowMirrorPointsResponseV2)1 FlowNotFoundException (org.openkilda.wfm.error.FlowNotFoundException)1 IslNotFoundException (org.openkilda.wfm.error.IslNotFoundException)1 SwitchNotFoundException (org.openkilda.wfm.error.SwitchNotFoundException)1