Display resolved status in routes command
Change-Id: Ib02f5fa6863bfdc9cd8bbd8c1237914ff48e3c7c
(cherry picked from commit 8d2650043bdc401d48612e0ee1433d67e6b97809)
diff --git a/apps/route-service/app/src/main/java/org/onosproject/routeservice/cli/RoutesListCommand.java b/apps/route-service/app/src/main/java/org/onosproject/routeservice/cli/RoutesListCommand.java
index 9c7eae0..665b432 100644
--- a/apps/route-service/app/src/main/java/org/onosproject/routeservice/cli/RoutesListCommand.java
+++ b/apps/route-service/app/src/main/java/org/onosproject/routeservice/cli/RoutesListCommand.java
@@ -43,8 +43,8 @@
private static final String SOURCE = "Source";
private static final String NODE = "Node";
- private static final String FORMAT_ROUTE = "%-1s %-18s %-15s %s (%s)";
- private static final String FORMAT_ROUTE6 = "%-1s %-43s %-39s %s (%s)";
+ private static final String FORMAT_ROUTE = "%-1s %-1s %-18s %-15s %s (%s)";
+ private static final String FORMAT_ROUTE6 = "%-1s %-1s %-43s %-39s %s (%s)";
private static final String FORMAT_TABLE = "Table: %s";
private static final String FORMAT_TOTAL = " Total: %d";
@@ -60,6 +60,7 @@
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);
@@ -68,7 +69,7 @@
// Print header
print(FORMAT_TABLE, id);
- print(format, "", NETWORK, NEXTHOP, SOURCE, NODE);
+ print(format, "B", "R", NETWORK, NEXTHOP, SOURCE, NODE);
// Print routing entries
tableRoutes.stream()
@@ -83,8 +84,10 @@
private void print(String format, RouteInfo routeInfo) {
routeInfo.allRoutes().stream()
- .sorted(Comparator.comparing(r -> r.nextHop()))
- .forEach(r -> print(format, isBestRoute(routeInfo.bestRoute(), r) ? ">" : "",
+ .sorted(Comparator.comparing(ResolvedRoute::nextHop))
+ .forEach(r -> print(format,
+ isBestRoute(routeInfo.bestRoute(), r) ? ">" : "",
+ isResolvedRoute(r) ? "*" : "",
r.prefix(), r.nextHop(), r.route().source(), r.route().sourceNode()));
}
@@ -92,6 +95,10 @@
return Objects.equals(bestRoute.orElse(null), route);
}
+ private boolean isResolvedRoute(ResolvedRoute route) {
+ return route.nextHopMac() != null && route.nextHopVlan() != null;
+ }
+
/**
* Produces a JSON array of routes.
*