Search in sources :

Example 1 with FlowEndpointV2

use of org.openkilda.northbound.dto.v2.flows.FlowEndpointV2 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 FlowEndpointV2

use of org.openkilda.northbound.dto.v2.flows.FlowEndpointV2 in project open-kilda by telstra.

the class FlowMapperTest method testFlowEndpointV2WithoutConnectedDevicesBuilder.

@Test
public void testFlowEndpointV2WithoutConnectedDevicesBuilder() {
    FlowEndpointV2 flowEndpointV2 = FlowEndpointV2.builder().switchId(SRC_SWITCH_ID).portNumber(SRC_PORT).vlanId(SRC_VLAN).build();
    assertNotNull(flowEndpointV2.getDetectConnectedDevices());
    assertFalse(flowEndpointV2.getDetectConnectedDevices().isArp());
    assertFalse(flowEndpointV2.getDetectConnectedDevices().isLldp());
}
Also used : FlowEndpointV2(org.openkilda.northbound.dto.v2.flows.FlowEndpointV2) Test(org.junit.Test)

Example 3 with FlowEndpointV2

use of org.openkilda.northbound.dto.v2.flows.FlowEndpointV2 in project open-kilda by telstra.

the class FlowMapperTest method testFlowRequestV2Mapping.

@Test
public void testFlowRequestV2Mapping() {
    FlowRequestV2 flowRequestV2 = FlowRequestV2.builder().flowId(FLOW_ID).encapsulationType(ENCAPSULATION_TYPE).source(new FlowEndpointV2(SRC_SWITCH_ID, SRC_PORT, SRC_VLAN, SRC_DETECT_CONNECTED_DEVICES)).destination(new FlowEndpointV2(DST_SWITCH_ID, DST_PORT, DST_VLAN, DST_DETECT_CONNECTED_DEVICES)).description(DESCRIPTION).maximumBandwidth(BANDWIDTH).maxLatency(LATENCY).maxLatencyTier2(LATENCY_TIER2).priority(PRIORITY).diverseFlowId(DIVERSE_FLOW_ID).build();
    FlowRequest flowRequest = flowMapper.toFlowRequest(flowRequestV2);
    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(FlowEncapsulationType.TRANSIT_VLAN, flowRequest.getEncapsulationType());
    assertEquals(DESCRIPTION, flowRequest.getDescription());
    assertEquals(BANDWIDTH, flowRequest.getBandwidth());
    // ms to ns
    assertEquals(LATENCY * MS_TO_NS_MULTIPLIER, (long) flowRequest.getMaxLatency());
    assertEquals(LATENCY_TIER2 * MS_TO_NS_MULTIPLIER, (long) flowRequest.getMaxLatencyTier2());
    assertEquals(PRIORITY, flowRequest.getPriority());
    assertEquals(DIVERSE_FLOW_ID, flowRequest.getDiverseFlowId());
    assertEquals(SRC_DETECT_CONNECTED_DEVICES.isLldp(), flowRequest.getDetectConnectedDevices().isSrcLldp());
    assertEquals(SRC_DETECT_CONNECTED_DEVICES.isArp(), flowRequest.getDetectConnectedDevices().isSrcArp());
    assertEquals(DST_DETECT_CONNECTED_DEVICES.isLldp(), flowRequest.getDetectConnectedDevices().isDstLldp());
    assertEquals(DST_DETECT_CONNECTED_DEVICES.isArp(), flowRequest.getDetectConnectedDevices().isDstArp());
}
Also used : FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) FlowEndpointV2(org.openkilda.northbound.dto.v2.flows.FlowEndpointV2) FlowRequestV2(org.openkilda.northbound.dto.v2.flows.FlowRequestV2) Test(org.junit.Test)

Example 4 with FlowEndpointV2

use of org.openkilda.northbound.dto.v2.flows.FlowEndpointV2 in project open-kilda by telstra.

the class FlowMapperTest method testFlowRequestV2InvalidEncapsulation.

@Test(expected = IllegalArgumentException.class)
public void testFlowRequestV2InvalidEncapsulation() {
    FlowRequestV2 flowRequestV2 = FlowRequestV2.builder().flowId(FLOW_ID).encapsulationType("abc").source(new FlowEndpointV2(SRC_SWITCH_ID, SRC_PORT, SRC_VLAN, SRC_DETECT_CONNECTED_DEVICES)).destination(new FlowEndpointV2(DST_SWITCH_ID, DST_PORT, DST_VLAN, DST_DETECT_CONNECTED_DEVICES)).build();
    flowMapper.toFlowRequest(flowRequestV2);
}
Also used : FlowEndpointV2(org.openkilda.northbound.dto.v2.flows.FlowEndpointV2) FlowRequestV2(org.openkilda.northbound.dto.v2.flows.FlowRequestV2) Test(org.junit.Test)

Example 5 with FlowEndpointV2

use of org.openkilda.northbound.dto.v2.flows.FlowEndpointV2 in project open-kilda by telstra.

the class FlowServiceTest method swapFlowEndpoint.

@Test
public void swapFlowEndpoint() throws Exception {
    String correlationId = "bulk-flow-update";
    RequestCorrelationId.create(correlationId);
    String firstFlowId = "bulk-flow-1";
    String secondFlowId = "bulk-flow-2";
    FlowEndpointV2 firstEndpoint = new FlowEndpointV2(new SwitchId("ff:00"), 1, 1, new DetectConnectedDevicesV2(false, false));
    FlowEndpointV2 secondEndpoint = new FlowEndpointV2(new SwitchId("ff:01"), 2, 2, new DetectConnectedDevicesV2(false, false));
    SwapFlowPayload firstFlowPayload = SwapFlowPayload.builder().flowId(firstFlowId).source(firstEndpoint).destination(firstEndpoint).build();
    SwapFlowPayload secondFlowPayload = SwapFlowPayload.builder().flowId(secondFlowId).source(secondEndpoint).destination(secondEndpoint).build();
    SwapFlowEndpointPayload input = new SwapFlowEndpointPayload(firstFlowPayload, secondFlowPayload);
    FlowDto firstResponse = FlowDto.builder().flowId(firstFlowId).bandwidth(10000).description(firstFlowId).state(FlowState.UP).sourceSwitch(new SwitchId("ff:00")).sourcePort(1).sourceVlan(1).destinationSwitch(new SwitchId("ff:01")).destinationPort(2).destinationVlan(2).build();
    FlowDto secondResponse = FlowDto.builder().flowId(secondFlowId).bandwidth(20000).description(secondFlowId).state(FlowState.UP).sourceSwitch(new SwitchId("ff:01")).sourcePort(2).sourceVlan(2).destinationSwitch(new SwitchId("ff:00")).destinationPort(1).destinationVlan(1).build();
    SwapFlowResponse response = new SwapFlowResponse(new FlowResponse(firstResponse), new FlowResponse(secondResponse));
    messageExchanger.mockResponse(correlationId, response);
    SwapFlowEndpointPayload result = flowService.swapFlowEndpoint(input).get();
    assertEquals(secondEndpoint, result.getFirstFlow().getDestination());
    assertEquals(firstEndpoint, result.getSecondFlow().getDestination());
}
Also used : FlowDto(org.openkilda.messaging.model.FlowDto) SwapFlowEndpointPayload(org.openkilda.northbound.dto.v2.flows.SwapFlowEndpointPayload) FlowEndpointV2(org.openkilda.northbound.dto.v2.flows.FlowEndpointV2) SwapFlowPayload(org.openkilda.northbound.dto.v2.flows.SwapFlowPayload) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) SwapFlowResponse(org.openkilda.messaging.info.flow.SwapFlowResponse) DetectConnectedDevicesV2(org.openkilda.northbound.dto.v2.flows.DetectConnectedDevicesV2) SwitchId(org.openkilda.model.SwitchId) SwapFlowResponse(org.openkilda.messaging.info.flow.SwapFlowResponse) Test(org.junit.Test)

Aggregations

FlowEndpointV2 (org.openkilda.northbound.dto.v2.flows.FlowEndpointV2)8 Test (org.junit.Test)6 DetectConnectedDevicesDto (org.openkilda.messaging.model.DetectConnectedDevicesDto)2 FlowRequestV2 (org.openkilda.northbound.dto.v2.flows.FlowRequestV2)2 SwapFlowPayload (org.openkilda.northbound.dto.v2.flows.SwapFlowPayload)2 FlowMirrorPointCreateRequest (org.openkilda.messaging.command.flow.FlowMirrorPointCreateRequest)1 FlowRequest (org.openkilda.messaging.command.flow.FlowRequest)1 FlowResponse (org.openkilda.messaging.info.flow.FlowResponse)1 SwapFlowResponse (org.openkilda.messaging.info.flow.SwapFlowResponse)1 FlowDto (org.openkilda.messaging.model.FlowDto)1 SwitchId (org.openkilda.model.SwitchId)1 DetectConnectedDevicesV2 (org.openkilda.northbound.dto.v2.flows.DetectConnectedDevicesV2)1 FlowMirrorPointPayload (org.openkilda.northbound.dto.v2.flows.FlowMirrorPointPayload)1 FlowResponseV2 (org.openkilda.northbound.dto.v2.flows.FlowResponseV2)1 SwapFlowEndpointPayload (org.openkilda.northbound.dto.v2.flows.SwapFlowEndpointPayload)1