nvazquez commented on a change in pull request #5114:
URL: https://github.com/apache/cloudstack/pull/5114#discussion_r691751398



##########
File path: server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
##########
@@ -2083,8 +2084,15 @@
         if (clusterId != null) {
             sc.setParameters("clusterId", clusterId);
         }
-        // Don't return DomR and ConsoleProxy volumes
-        sc.setParameters("type", VirtualMachine.Type.ConsoleProxy, 
VirtualMachine.Type.SecondaryStorageVm, VirtualMachine.Type.DomainRouter);
+
+        sc.setParameters("type", VirtualMachine.Type.User);
+
+        // Display all volumes for ROOT admin
+        if (forSystemVms != null && forSystemVms && caller.getType() == 
Account.ACCOUNT_TYPE_ADMIN) {

Review comment:
       What about extracting this condition into a new method, such as:
   ````
   boolean isAdminRequestingAllVolumes(Boolean forSystemVms, Account caller) {
      return forSystemVms != null && forSystemVms && caller.getType() == 
Account.ACCOUNT_TYPE_ADMIN;
   }
   ````

##########
File path: server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
##########
@@ -2006,9 +2007,9 @@
         sb.and("display", sb.entity().isDisplayVolume(), SearchCriteria.Op.EQ);
         sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
         sb.and("stateNEQ", sb.entity().getState(), SearchCriteria.Op.NEQ);
-        sb.and("systemUse", sb.entity().isSystemUse(), SearchCriteria.Op.NEQ);
+        sb.and("systemUse", sb.entity().isSystemUse(), SearchCriteria.Op.IN);

Review comment:
       Then we won't need this change

##########
File path: server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
##########
@@ -2083,8 +2084,15 @@
         if (clusterId != null) {
             sc.setParameters("clusterId", clusterId);
         }
-        // Don't return DomR and ConsoleProxy volumes
-        sc.setParameters("type", VirtualMachine.Type.ConsoleProxy, 
VirtualMachine.Type.SecondaryStorageVm, VirtualMachine.Type.DomainRouter);

Review comment:
       Same here:
   
   ````
   if (!isAdminRequestingAllVolumes(forSystemVms, caller) {
      // Don't return DomR and ConsoleProxy volumes
      sc.setParameters("type", VirtualMachine.Type.ConsoleProxy, 
VirtualMachine.Type.SecondaryStorageVm, VirtualMachine.Type.DomainRouter);
   }
   ````
   
   And we won't need all the lines added below

##########
File path: server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
##########
@@ -2006,9 +2007,9 @@
         sb.and("display", sb.entity().isDisplayVolume(), SearchCriteria.Op.EQ);
         sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
         sb.and("stateNEQ", sb.entity().getState(), SearchCriteria.Op.NEQ);
-        sb.and("systemUse", sb.entity().isSystemUse(), SearchCriteria.Op.NEQ);
+        sb.and("systemUse", sb.entity().isSystemUse(), SearchCriteria.Op.IN);
         // display UserVM volumes only
-        sb.and().op("type", sb.entity().getVmType(), SearchCriteria.Op.NIN);
+        sb.and().op("type", sb.entity().getVmType(), SearchCriteria.Op.IN);

Review comment:
       Or this

##########
File path: server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
##########
@@ -2035,7 +2036,7 @@
 
         setIdsListToSearchCriteria(sc, ids);
 
-        sc.setParameters("systemUse", 1);
+        sc.setParameters("systemUse", 0);

Review comment:
       This could be reverted as well, to:
   ````
   if (!isAdminRequestingAllVolumes(forSystemVms, caller) {
      sc.setParameters("systemUse", 1);
   }
   ````




-- 
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