resources CLI
Change-Id: Idac7ae69c8264da80cb1b55628990690803eaf89
diff --git a/cli/src/main/java/org/onosproject/cli/net/ResourcesCommand.java b/cli/src/main/java/org/onosproject/cli/net/ResourcesCommand.java
index 1e24cb9..b17f944 100644
--- a/cli/src/main/java/org/onosproject/cli/net/ResourcesCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/ResourcesCommand.java
@@ -172,10 +172,18 @@
List<Resource> nonAggregatable = new ArrayList<>();
for (Resource r : children) {
- if (!isPrintTarget(r)) {
+ if (!isPrintTarget(r)) { // A
continue;
}
+ if (r instanceof DiscreteResource) {
+
+ if (resourceService.getRegisteredResources(((DiscreteResource) r).id()).isEmpty()) {
+ // resource which has children should be printed
+ continue;
+ }
+ }
+
if (r instanceof ContinuousResource) {
// non-aggregatable terminal node
nonAggregatable.add(r);
@@ -188,6 +196,7 @@
}
}
+
// print aggregated (terminal)
aggregatables.asMap().entrySet()
.forEach(e -> {
@@ -236,12 +245,7 @@
String resourceName = resource.simpleTypeName();
if (resource instanceof DiscreteResource) {
- // TODO This distributed store access incurs overhead.
- // This should be merged with the one in printResource()
- if (!resourceService.getRegisteredResources(((DiscreteResource) resource).id()).isEmpty()) {
- // resource which has children should be printed
- return true;
- }
+
if (availablesOnly && !resourceService.isAvailable(resource)) {
// don't print unavailable discrete resource
return false;
@@ -250,7 +254,6 @@
log.warn("Unexpected resource class: {}", resource.getClass().getSimpleName());
return false;
}
-
return typesToPrint.contains(resourceName);
}
}