rohityadavcloud commented on code in PR #8782:
URL: https://github.com/apache/cloudstack/pull/8782#discussion_r1594253988


##########
api/src/main/java/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java:
##########
@@ -239,22 +240,32 @@ public Long getAutoScaleVmGroupId() {
         return autoScaleVmGroupId;
     }
 
+    protected boolean isViewDetailsEmpty() {
+        return CollectionUtils.isEmpty(viewDetails);
+    }
+
     public EnumSet<VMDetails> getDetails() throws 
InvalidParameterValueException {
-        EnumSet<VMDetails> dv;
-        if (viewDetails == null || viewDetails.size() <= 0) {
-            dv = EnumSet.of(VMDetails.all);
-        } else {
-            try {
-                ArrayList<VMDetails> dc = new ArrayList<VMDetails>();
-                for (String detail : viewDetails) {
-                    dc.add(VMDetails.valueOf(detail));
-                }
-                dv = EnumSet.copyOf(dc);
-            } catch (IllegalArgumentException e) {
-                throw new InvalidParameterValueException("The details 
parameter contains a non permitted value. The allowed values are " + 
EnumSet.allOf(VMDetails.class));
+        if (isViewDetailsEmpty()) {
+            if (_queryService.returnVmStatsOnVmList.value()) {
+                return EnumSet.of(VMDetails.all);
+            }
+
+            Set<VMDetails> allDetails = new 
HashSet<>(Set.of(VMDetails.values()));

Review Comment:
   I think it could be simpler, if the decision whether to list stats or not 
can be done via 
`server/src/main/java/com/cloud/api/query/dao/UserVmJoinDaoImpl.java` 
   ```
   -        if (details.contains(VMDetails.all) || 
details.contains(VMDetails.stats)) {
   +        if (details.contains(VMDetails.stats)) {
   ```
   
   See - 
https://github.com/apache/cloudstack/pull/8985/files#diff-b180fb2c499ee386bb5b8eae08c2a004e2c33a9430d94b4253bdbd3871d36f8a



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to