Search in sources :

Example 1 with XconnectDesc

use of org.onosproject.segmentrouting.xconnect.api.XconnectDesc in project trellis-control by opennetworkinglab.

the class XconnectWebResource method removeXconnect.

/**
 * Delete an existing Xconnect.
 *
 * @param input JSON stream for xconnect to remove
 * @return 204 NO CONTENT
 * @throws IOException Throws IO exception
 * @onos.rsModel XconnectDelete
 */
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
public Response removeXconnect(InputStream input) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    ObjectNode json = readTreeFromStream(mapper, input);
    XconnectDesc desc = codec(XconnectDesc.class).decode(json, this);
    XconnectService xconnectService = get(XconnectService.class);
    xconnectService.removeXonnect(desc.key().deviceId(), desc.key().vlanId());
    return Response.noContent().build();
}
Also used : XconnectService(org.onosproject.segmentrouting.xconnect.api.XconnectService) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) XconnectDesc(org.onosproject.segmentrouting.xconnect.api.XconnectDesc) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DELETE(javax.ws.rs.DELETE) Consumes(javax.ws.rs.Consumes)

Example 2 with XconnectDesc

use of org.onosproject.segmentrouting.xconnect.api.XconnectDesc in project trellis-control by opennetworkinglab.

the class XconnectWebResource method getXconnects.

/**
 * Gets all Xconnects.
 *
 * @return an array of xconnects
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getXconnects() {
    XconnectService xconnectService = get(XconnectService.class);
    Set<XconnectDesc> xconnects = xconnectService.getXconnects();
    ObjectNode result = encodeArray(XconnectDesc.class, XCONNECTS, xconnects);
    return ok(result).build();
}
Also used : XconnectService(org.onosproject.segmentrouting.xconnect.api.XconnectService) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) XconnectDesc(org.onosproject.segmentrouting.xconnect.api.XconnectDesc) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with XconnectDesc

use of org.onosproject.segmentrouting.xconnect.api.XconnectDesc in project trellis-control by opennetworkinglab.

the class XconnectWebResource method addOrUpdateXconnect.

/**
 * Create a new Xconnect.
 *
 * @param input JSON stream for xconnect to create
 * @return 200 OK
 * @throws IOException Throws IO exception
 * @onos.rsModel XconnectCreate
 */
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response addOrUpdateXconnect(InputStream input) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    ObjectNode json = readTreeFromStream(mapper, input);
    XconnectDesc desc = codec(XconnectDesc.class).decode(json, this);
    if (desc.endpoints().size() != 2) {
        throw new IllegalArgumentException("Ports should have only two items.");
    }
    XconnectService xconnectService = get(XconnectService.class);
    xconnectService.addOrUpdateXconnect(desc.key().deviceId(), desc.key().vlanId(), desc.endpoints());
    return Response.ok().build();
}
Also used : XconnectService(org.onosproject.segmentrouting.xconnect.api.XconnectService) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) XconnectDesc(org.onosproject.segmentrouting.xconnect.api.XconnectDesc) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Aggregations

ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 XconnectDesc (org.onosproject.segmentrouting.xconnect.api.XconnectDesc)3 XconnectService (org.onosproject.segmentrouting.xconnect.api.XconnectService)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 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