use of org.onosproject.segmentrouting.xconnect.api.XconnectService 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();
}
use of org.onosproject.segmentrouting.xconnect.api.XconnectService 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();
}
Aggregations