Search in sources :

Example 1 with Tunnel

use of org.onosproject.segmentrouting.Tunnel in project trellis-control by opennetworkinglab.

the class TunnelWebResource method getTunnel.

/**
 * Get all segment routing tunnels.
 * Returns an array of segment routing tunnels.
 *
 * @return status of OK
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getTunnel() {
    SegmentRoutingService srService = get(SegmentRoutingService.class);
    List<Tunnel> tunnels = srService.getTunnels();
    ObjectNode result = new ObjectMapper().createObjectNode();
    result.set("tunnel", new TunnelCodec().encode(tunnels, this));
    return ok(result.toString()).build();
}
Also used : SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService) Tunnel(org.onosproject.segmentrouting.Tunnel) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with Tunnel

use of org.onosproject.segmentrouting.Tunnel in project trellis-control by opennetworkinglab.

the class TunnelWebResource method createTunnel.

/**
 * Create a new segment routing tunnel.
 *
 * @param input JSON stream for tunnel to create
 * @return status of the request - OK if the tunnel is created,
 * @throws IOException if the JSON is invalid
 */
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response createTunnel(InputStream input) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    ObjectNode tunnelJson = readTreeFromStream(mapper, input);
    SegmentRoutingService srService = get(SegmentRoutingService.class);
    Tunnel tunnelInfo = TUNNEL_CODEC.decode(tunnelJson, this);
    srService.createTunnel(tunnelInfo);
    return Response.ok().build();
}
Also used : SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService) Tunnel(org.onosproject.segmentrouting.Tunnel) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Example 3 with Tunnel

use of org.onosproject.segmentrouting.Tunnel in project trellis-control by opennetworkinglab.

the class TunnelWebResource method removeTunnel.

/**
 * Delete a segment routing tunnel.
 *
 * @param input JSON stream for tunnel to delete
 * @return 204 NO CONTENT, if the tunnel is removed
 * @throws IOException if JSON is invalid
 */
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
public Response removeTunnel(InputStream input) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    ObjectNode tunnelJson = readTreeFromStream(mapper, input);
    SegmentRoutingService srService = get(SegmentRoutingService.class);
    Tunnel tunnelInfo = TUNNEL_CODEC.decode(tunnelJson, this);
    srService.removeTunnel(tunnelInfo);
    return Response.noContent().build();
}
Also used : SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService) Tunnel(org.onosproject.segmentrouting.Tunnel) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DELETE(javax.ws.rs.DELETE) Consumes(javax.ws.rs.Consumes)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 SegmentRoutingService (org.onosproject.segmentrouting.SegmentRoutingService)3 Tunnel (org.onosproject.segmentrouting.Tunnel)3 Consumes (javax.ws.rs.Consumes)2 DELETE (javax.ws.rs.DELETE)1 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1 Produces (javax.ws.rs.Produces)1