Search in sources :

Example 26 with FlowPayload

use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.

the class FlowServiceImplTest method createFlow.

@Test
public void createFlow() throws Exception {
    FlowEndpointPayload firstEndpoint = new FlowEndpointPayload(srcSwitchId, DIRECT_INCOMING_PORT, INPUT_VLAN_ID);
    FlowEndpointPayload secondEndpoint = new FlowEndpointPayload(dstSwitchId, DIRECT_OUTGOING_PORT, OUTPUT_VLAN_ID);
    FlowPayload flowPayload = new FlowPayload(flowId, 0L, firstEndpoint, secondEndpoint, 10000L, "", "", OutputVlanType.NONE);
    flowService.createFlow(flowPayload, DEFAULT_CORRELATION_ID);
    Set<Flow> flows = flowRepository.findByFlowId(flowId);
    assertNotNull(flows);
    assertFalse(flows.isEmpty());
    assertEquals(2, flows.size());
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) FlowEndpointPayload(org.openkilda.messaging.payload.flow.FlowEndpointPayload) Flow(org.openkilda.topology.domain.Flow) Test(org.junit.Test)

Example 27 with FlowPayload

use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.

the class FlowServiceImpl method getFlows.

/**
 * {@inheritDoc}
 */
@Override
public InfoMessage getFlows(final FlowIdStatusPayload payload, final String correlationId) {
    Set<Flow> flows = flowRepository.findAll();
    List<FlowPayload> flowsPayload = new ArrayList<>(flows.size() / 2);
    for (Flow flow : flows) {
        if ((flow.getCookie() & DIRECT_FLOW_COOKIE) == DIRECT_FLOW_COOKIE) {
            flowsPayload.add(getFlowPayloadByFlow(flow));
        }
    }
    logger.debug("Flows get: {}", flowsPayload);
    return new InfoMessage(new FlowsResponse(new FlowsPayload(flowsPayload)), System.currentTimeMillis(), correlationId, Destination.WFM);
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowsResponse(org.openkilda.messaging.info.flow.FlowsResponse) ArrayList(java.util.ArrayList) FlowsPayload(org.openkilda.messaging.payload.flow.FlowsPayload) Flow(org.openkilda.topology.domain.Flow)

Example 28 with FlowPayload

use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.

the class FlowController method createFlow.

/**
 * Creates new flow.
 *
 * @param flow          flow
 * @param correlationId correlation ID header value
 * @return flow
 */
@ApiOperation(value = "Creates new flow", response = FlowPayload.class)
@ApiResponses(value = { @ApiResponse(code = 200, response = FlowPayload.class, message = "Operation is successful"), @ApiResponse(code = 400, response = MessageError.class, message = "Invalid input data"), @ApiResponse(code = 401, response = MessageError.class, message = "Unauthorized"), @ApiResponse(code = 403, response = MessageError.class, message = "Forbidden"), @ApiResponse(code = 404, response = MessageError.class, message = "Not found"), @ApiResponse(code = 500, response = MessageError.class, message = "General error"), @ApiResponse(code = 503, response = MessageError.class, message = "Service unavailable") })
@RequestMapping(value = "/flows", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<FlowPayload> createFlow(@RequestBody FlowPayload flow, @RequestHeader(value = CORRELATION_ID, defaultValue = DEFAULT_CORRELATION_ID) String correlationId) {
    logger.debug("Create flow: {}={}, flow={}", CORRELATION_ID, correlationId, flow);
    FlowPayload response = flowService.createFlow(flow, correlationId);
    return new ResponseEntity<>(response, new HttpHeaders(), HttpStatus.OK);
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 29 with FlowPayload

use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.

the class FlowController method deleteFlow.

/**
 * Deletes flow.
 *
 * @param flowId        flow id
 * @param correlationId correlation ID header value
 * @return flow
 */
@ApiOperation(value = "Deletes flow", response = FlowPayload.class)
@ApiResponses(value = { @ApiResponse(code = 200, response = FlowPayload.class, message = "Operation is successful"), @ApiResponse(code = 400, response = MessageError.class, message = "Invalid input data"), @ApiResponse(code = 401, response = MessageError.class, message = "Unauthorized"), @ApiResponse(code = 403, response = MessageError.class, message = "Forbidden"), @ApiResponse(code = 404, response = MessageError.class, message = "Not found"), @ApiResponse(code = 500, response = MessageError.class, message = "General error"), @ApiResponse(code = 503, response = MessageError.class, message = "Service unavailable") })
@RequestMapping(value = "/flows/{flow-id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<FlowPayload> deleteFlow(@PathVariable(name = "flow-id") String flowId, @RequestHeader(value = CORRELATION_ID, defaultValue = DEFAULT_CORRELATION_ID) String correlationId) {
    logger.debug("Delete flow: {}={}, {}={}", CORRELATION_ID, correlationId, FLOW_ID, flowId);
    FlowPayload response = flowService.deleteFlow(flowId, correlationId);
    return new ResponseEntity<>(response, new HttpHeaders(), HttpStatus.OK);
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 30 with FlowPayload

use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.

the class FlowController method getFlow.

/**
 * Gets flow.
 *
 * @param flowId        flow id
 * @param correlationId correlation ID header value
 * @return flow
 */
@ApiOperation(value = "Gets flow", response = FlowPayload.class)
@ApiResponses(value = { @ApiResponse(code = 200, response = FlowPayload.class, message = "Operation is successful"), @ApiResponse(code = 400, response = MessageError.class, message = "Invalid input data"), @ApiResponse(code = 401, response = MessageError.class, message = "Unauthorized"), @ApiResponse(code = 403, response = MessageError.class, message = "Forbidden"), @ApiResponse(code = 404, response = MessageError.class, message = "Not found"), @ApiResponse(code = 500, response = MessageError.class, message = "General error"), @ApiResponse(code = 503, response = MessageError.class, message = "Service unavailable") })
@RequestMapping(value = "/flows/{flow-id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<FlowPayload> getFlow(@PathVariable(name = "flow-id") String flowId, @RequestHeader(value = CORRELATION_ID, defaultValue = DEFAULT_CORRELATION_ID) String correlationId) {
    logger.debug("Get flow: {}={}, {}={}", CORRELATION_ID, correlationId, FLOW_ID, flowId);
    FlowPayload response = flowService.getFlow(flowId, correlationId);
    return new ResponseEntity<>(response, new HttpHeaders(), HttpStatus.OK);
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

FlowPayload (org.openkilda.messaging.payload.flow.FlowPayload)48 Test (org.junit.Test)14 FlowEndpointPayload (org.openkilda.messaging.payload.flow.FlowEndpointPayload)9 Then (cucumber.api.java.en.Then)7 When (cucumber.api.java.en.When)7 ApiOperation (io.swagger.annotations.ApiOperation)6 ApiResponses (io.swagger.annotations.ApiResponses)6 DefaultParameters.northboundEndpoint (org.openkilda.DefaultParameters.northboundEndpoint)6 DefaultParameters.topologyEndpoint (org.openkilda.DefaultParameters.topologyEndpoint)6 PathInfoData (org.openkilda.messaging.info.event.PathInfoData)6 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)6 HttpHeaders (org.springframework.http.HttpHeaders)6 ResponseEntity (org.springframework.http.ResponseEntity)6 WithMockUser (org.springframework.security.test.context.support.WithMockUser)6 MvcResult (org.springframework.test.web.servlet.MvcResult)6 And (cucumber.api.java.en.And)5 Client (javax.ws.rs.client.Client)5 Response (javax.ws.rs.core.Response)5 ArrayList (java.util.ArrayList)4 List (java.util.List)3