use of org.openkilda.northbound.dto.v2.flows.SwapFlowPayload 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;
}
use of org.openkilda.northbound.dto.v2.flows.SwapFlowPayload 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());
}
use of org.openkilda.northbound.dto.v2.flows.SwapFlowPayload in project open-kilda by telstra.
the class NorthboundServiceImpl method swapFlowEndpoint.
@Override
public SwapFlowEndpointPayload swapFlowEndpoint(SwapFlowPayload firstFlow, SwapFlowPayload secondFlow) {
log.debug("Swap flow endpoints. First flow: {}. Second flow: {}", firstFlow, secondFlow);
HttpEntity<SwapFlowEndpointPayload> httpEntity = new HttpEntity<>(new SwapFlowEndpointPayload(firstFlow, secondFlow), buildHeadersWithCorrelationId());
return restTemplate.exchange("/api/v2/flows/swap-endpoint", HttpMethod.POST, httpEntity, SwapFlowEndpointPayload.class).getBody();
}
Aggregations