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();
}
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();
}
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();
}
Aggregations