use of org.onosproject.segmentrouting.SegmentRoutingService in project trellis-control by opennetworkinglab.
the class PseudowireNextListCommand method doExecute.
@Override
protected void doExecute() {
SegmentRoutingService srService = AbstractShellCommand.get(SegmentRoutingService.class);
print(srService.getPwInitNext());
print(srService.getPwTermNext());
}
use of org.onosproject.segmentrouting.SegmentRoutingService in project trellis-control by opennetworkinglab.
the class RerouteNetworkCommand method doExecute.
@Override
protected void doExecute() {
SegmentRoutingService srService = AbstractShellCommand.get(SegmentRoutingService.class);
srService.rerouteNetwork();
}
use of org.onosproject.segmentrouting.SegmentRoutingService in project trellis-control by opennetworkinglab.
the class McastWebResource method encodeMcastTrees.
private ObjectNode encodeMcastTrees(String gAddr, String source) {
SegmentRoutingService srService = get(SegmentRoutingService.class);
Set<IpAddress> mcastGroups = ImmutableSet.copyOf(srService.getMcastLeaders(null).keySet());
if (!isNullOrEmpty(gAddr)) {
mcastGroups = mcastGroups.stream().filter(mcastIp -> mcastIp.equals(IpAddress.valueOf(gAddr))).collect(Collectors.toSet());
}
ObjectMapper mapper = new ObjectMapper();
ObjectNode root = mapper.createObjectNode();
// Print the trees for each group or build json objects
mcastGroups.forEach(group -> {
// We want to use source cp only for a specific group
ConnectPoint sourcecp = null;
if (!isNullOrEmpty(source) && !isNullOrEmpty(gAddr)) {
sourcecp = ConnectPoint.deviceConnectPoint(source);
}
Multimap<ConnectPoint, List<ConnectPoint>> mcastTree = srService.getMcastTrees(group, sourcecp);
// Build a json object for each group
root.putPOJO(group.toString(), json(mcastTree));
});
return root;
}
use of org.onosproject.segmentrouting.SegmentRoutingService in project trellis-control by opennetworkinglab.
the class PseudowireWebResource method removePseudowiresBulk.
/**
* Delete a bulk of pseudowires.
*
* @param input JSON stream for pseudowires to delete
* @return Response with appropriate status
* @throws IOException Throws IO exception.
* @onos.rsModel PseudowireDeleteBulk
*/
@DELETE
@Path("/bulk")
@Consumes(MediaType.APPLICATION_JSON)
public Response removePseudowiresBulk(InputStream input) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectNode pseudowireJson = readTreeFromStream(mapper, input);
SegmentRoutingService srService = get(SegmentRoutingService.class);
List<Integer> ids = new ArrayList<>();
// throw an exception and stop process
try {
for (JsonNode node : pseudowireJson.withArray(PWS)) {
Integer idToDelete = PseudowireCodec.decodeId((ObjectNode) node);
if (idToDelete == null) {
log.error("Error when parsing pseudowire for deletion in REST API.");
throw new IllegalArgumentException("Id of pseudowire should be an integer!");
}
ids.add(idToDelete);
}
} catch (IllegalArgumentException e) {
log.error("Pseudowire ID should be an integer.");
return Response.serverError().status(Response.Status.BAD_REQUEST).build();
} catch (UnsupportedOperationException e) {
log.error("Pseudowires for deletion should be an array of pseudowire ids.");
return Response.serverError().status(Response.Status.BAD_REQUEST).build();
}
for (Integer pseudowireId : ids) {
L2TunnelHandler.Result res = srService.removePseudowire(pseudowireId);
switch(res) {
case WRONG_PARAMETERS:
case INTERNAL_ERROR:
log.error("Pseudowire {} could not be removed, internal error : {}", pseudowireId, res.getSpecificError());
break;
case SUCCESS:
log.debug("Pseudowire {} was removed succesfully!", pseudowireId);
break;
default:
}
}
return Response.noContent().build();
}
use of org.onosproject.segmentrouting.SegmentRoutingService 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