use of org.onosproject.routeservice.Route 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.Route in project onos by opennetworkinglab.
the class RouteServiceWebResource method getRoutesCountByType.
/**
* Get count of all types routes .
* Returns count of all known route types.
*
* @return 200 OK with count of all route types
* @onos.rsModel RoutesGetTypeCount
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/routes/types/count")
public Response getRoutesCountByType() {
RouteService service = get(RouteService.class);
ObjectNode root = mapper().createObjectNode();
service.getRouteTables().forEach(table -> {
List<Route> staticRoutes = new ArrayList<>();
List<Route> fpmRoutes = new ArrayList<>();
List<Route> ripRoutes = new ArrayList<>();
List<Route> dhcpRoutes = new ArrayList<>();
List<Route> dhcpLQRoutes = new ArrayList<>();
List<Route> bgpRoutes = new ArrayList<>();
List<Route> routes = service.getRoutes(table).stream().flatMap(ri -> ri.allRoutes().stream()).map(ResolvedRoute::route).collect(Collectors.toList());
routes.forEach(route -> {
if (route.source() == Route.Source.STATIC) {
staticRoutes.add(route);
}
if (route.source() == Route.Source.FPM) {
fpmRoutes.add(route);
}
if (route.source() == Route.Source.RIP) {
ripRoutes.add(route);
}
if (route.source() == Route.Source.DHCP) {
dhcpRoutes.add(route);
}
if (route.source() == Route.Source.DHCPLQ) {
dhcpLQRoutes.add(route);
}
if (route.source() == Route.Source.BGP) {
bgpRoutes.add(route);
}
});
root.put(table.name() + "StaticRouteCount", staticRoutes.size());
root.put(table.name() + "FpmRouteCount", fpmRoutes.size());
root.put(table.name() + "RipRouteCount", ripRoutes.size());
root.put(table.name() + "DhcpRouteCount", dhcpRoutes.size());
root.put(table.name() + "DhcpLQRouteCount", dhcpLQRoutes.size());
root.put(table.name() + "BgpRouteCount", bgpRoutes.size());
root.put(table.name() + "TotalRouteCount", routes.stream().count());
});
return ok(root).build();
}
use of org.onosproject.routeservice.Route in project onos by opennetworkinglab.
the class LocalRouteStore method computeRouteTablesFromRoutes.
private Map<RouteTableId, Set<Route>> computeRouteTablesFromRoutes(Collection<Route> routes) {
Map<RouteTableId, Set<Route>> computedTables = new HashMap<>();
routes.forEach(route -> {
RouteTableId routeTableId = (route.prefix().address().isIp4()) ? IPV4 : IPV6;
Set<Route> tempRoutes = computedTables.computeIfAbsent(routeTableId, k -> Sets.newHashSet());
tempRoutes.add(route);
});
return computedTables;
}
use of org.onosproject.routeservice.Route 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.Route 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));
}
Aggregations