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));
}
use of org.onosproject.routeservice.Route in project onos by opennetworkinglab.
the class RoutesListCommand method doExecute.
@Override
protected void doExecute() {
RouteService service = AbstractShellCommand.get(RouteService.class);
if (outputJson()) {
ObjectMapper mapper = new ObjectMapper();
ObjectNode result = mapper.createObjectNode();
result.set("routes4", json(service.getRoutes(new RouteTableId("ipv4"))));
result.set("routes6", json(service.getRoutes(new RouteTableId("ipv6"))));
print("%s", result);
} else {
print("B: Best route, R: Resolved route\n");
service.getRouteTables().forEach(id -> {
Collection<RouteInfo> tableRoutes = service.getRoutes(id);
String format = tableRoutes.stream().anyMatch(route -> route.prefix().isIp6()) ? FORMAT_ROUTE6 : FORMAT_ROUTE;
// Print header
print(FORMAT_TABLE, id);
print(format, "B", "R", NETWORK, NEXTHOP, SOURCE, NODE);
// Print routing entries
tableRoutes.stream().sorted(Comparator.comparing(r -> r.prefix().address())).forEach(route -> this.print(format, route));
print(FORMAT_TOTAL, tableRoutes.size());
print("");
});
}
}
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 RouteManager method activate.
@Activate
protected void activate() {
routeMonitor = new RouteMonitor(this, clusterService, storageService);
routeResolver = new RouteResolver(this, hostService);
threadFactory = groupedThreads("onos/route", "listener-%d", log);
hostEventExecutors = new PredictableExecutor(DEFAULT_BUCKETS, groupedThreads("onos/route-manager", "event-host-%d", log));
resolvedRouteStore = new DefaultResolvedRouteStore();
routeStore.setDelegate(delegate);
hostService.addListener(hostListener);
routeStore.getRouteTables().stream().flatMap(id -> routeStore.getRoutes(id).stream()).forEach(routeSet -> routeResolver.resolve(routeSet));
}
use of org.onosproject.routeservice.Route in project onos by opennetworkinglab.
the class RouteCodec method decode.
@Override
public Route decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
IpPrefix prefix = IpPrefix.valueOf(json.path(PREFIX).asText());
IpAddress nextHop = IpAddress.valueOf(json.path(NEXT_HOP).asText());
String source = json.path(SOURCE).asText();
// Routes through the REST API without mentioning source in the json are created as STATIC,
// otherwise routes are created with corresponding source.
Route route = source.isEmpty() ? new Route(Route.Source.STATIC, prefix, nextHop) : new Route(Route.Source.valueOf(source), prefix, nextHop);
return route;
}
Aggregations