use of org.onosproject.routeservice.RouteAdminService in project onos by opennetworkinglab.
the class RouteRemoveCommand method doExecute.
@Override
protected void doExecute() {
RouteAdminService service = AbstractShellCommand.get(RouteAdminService.class);
IpPrefix prefix = IpPrefix.valueOf(prefixString);
IpAddress nextHop = IpAddress.valueOf(nextHopString);
// Routes through cli without mentioning source then it is created as STATIC,
// otherwise routes are created with corresponding source.
Route route = source == null ? new Route(Route.Source.STATIC, prefix, nextHop) : new Route(Route.Source.valueOf(source), prefix, nextHop);
service.withdraw(Collections.singleton(route));
}
use of org.onosproject.routeservice.RouteAdminService in project onos by opennetworkinglab.
the class RouteAddCommand method doExecute.
@Override
protected void doExecute() {
RouteAdminService service = AbstractShellCommand.get(RouteAdminService.class);
IpPrefix prefix = IpPrefix.valueOf(prefixString);
IpAddress nextHop = IpAddress.valueOf(nextHopString);
service.update(Collections.singleton(new Route(Route.Source.STATIC, prefix, nextHop)));
}
use of org.onosproject.routeservice.RouteAdminService in project onos by opennetworkinglab.
the class RouteServiceWebResource method createRoute.
/**
* Create new unicast route.
* Creates a new route in the unicast RIB. Source field is kept optional.
* Without Source field routes are created as STATIC routes. Otherwise as per the mentioned Source
*
* @param route unicast route JSON
* @return status of the request - CREATED if the JSON is correct,
* BAD_REQUEST if the JSON is invalid, NO_CONTENT otherwise
* @onos.rsModel RouteTypePost
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createRoute(InputStream route) {
RouteAdminService service = get(RouteAdminService.class);
try {
ObjectNode jsonTree = readTreeFromStream(mapper(), route);
Route r = codec(Route.class).decode(jsonTree, this);
service.update(Collections.singletonList(r));
} catch (IOException ex) {
throw new IllegalArgumentException(ex);
}
return Response.noContent().build();
}
use of org.onosproject.routeservice.RouteAdminService in project onos by opennetworkinglab.
the class RouteServiceWebResource method deleteRoutes.
/**
* Removes unicast routes.
* Removes multiple routes from the unicast RIB.
*
* @param routesStream unicast routes array JSON
* @return 204 NO CONTENT
*/
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Path("/bulk")
public Response deleteRoutes(InputStream routesStream) {
RouteAdminService service = get(RouteAdminService.class);
try {
ObjectNode jsonTree = readTreeFromStream(mapper(), routesStream);
ArrayNode routesArray = nullIsIllegal((ArrayNode) jsonTree.get(ROUTES), ROUTES_KEY_ERROR);
List<Route> routes = codec(Route.class).decode(routesArray, this);
service.withdraw(routes);
} catch (IOException ex) {
throw new IllegalArgumentException(ex);
}
return Response.noContent().build();
}
use of org.onosproject.routeservice.RouteAdminService in project onos by opennetworkinglab.
the class RouteServiceWebResource method deleteRoute.
/**
* Remove a unicast route.
* Removes a route from the unicast RIB.
*
* @param route unicast route JSON
* @return 204 NO CONTENT
* @onos.rsModel RoutePost
*/
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
public Response deleteRoute(InputStream route) {
RouteAdminService service = get(RouteAdminService.class);
try {
ObjectNode jsonTree = readTreeFromStream(mapper(), route);
Route r = codec(Route.class).decode(jsonTree, this);
service.withdraw(Collections.singletonList(r));
} catch (IOException ex) {
throw new IllegalArgumentException(ex);
}
return Response.noContent().build();
}
Aggregations