@@ -254,9 +254,15 @@ protected Pair<List<UserVmVO>, Integer> searchForUserVmsInternal(ListVMsUsageHis
254254 final Long id = cmd .getId ();
255255 Account caller = CallContext .current ().getCallingAccount ();
256256 List <Long > permittedAccounts = new ArrayList <>();
257- boolean recursive = AccountTypesWithRecursiveUsageAccess .contains (caller .getType ());
257+ Account .Type callerType = caller .getType ();
258+ boolean recursive = AccountTypesWithRecursiveUsageAccess .contains (callerType );
258259 Ternary <Long , Boolean , Project .ListProjectResourcesCriteria > domainIdRecursiveListProject = new Ternary <>(null , recursive , null );
259- accountMgr .buildACLSearchParameters (caller , id , null , null , permittedAccounts , domainIdRecursiveListProject , true , false );
260+
261+ // Allow users to also list metrics of resources owned by projects they belong to (-1L), and admins to list all
262+ // metrics belonging to their domains recursively (null)
263+ Long projectId = callerType == Account .Type .NORMAL ? -1L : null ;
264+
265+ accountMgr .buildACLSearchParameters (caller , id , null , projectId , permittedAccounts , domainIdRecursiveListProject , true , false );
260266 Long domainId = domainIdRecursiveListProject .first ();
261267 Boolean isRecursive = domainIdRecursiveListProject .second ();
262268 Project .ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject .third ();
@@ -360,9 +366,15 @@ protected Pair<List<VolumeVO>, Integer> searchForVolumesInternal(ListVolumesUsag
360366 final Long id = cmd .getId ();
361367 Account caller = CallContext .current ().getCallingAccount ();
362368 List <Long > permittedAccounts = new ArrayList <>();
363- boolean recursive = AccountTypesWithRecursiveUsageAccess .contains (caller .getType ());
369+ Account .Type callerType = caller .getType ();
370+ boolean recursive = AccountTypesWithRecursiveUsageAccess .contains (callerType );
364371 Ternary <Long , Boolean , Project .ListProjectResourcesCriteria > domainIdRecursiveListProject = new Ternary <>(null , recursive , null );
365- accountMgr .buildACLSearchParameters (caller , id , null , null , permittedAccounts , domainIdRecursiveListProject , true , false );
372+
373+ // Allow users to also list metrics of resources owned by projects they belong to (-1L), and admins to list all
374+ // metrics belonging to their domains recursively (null)
375+ Long projectId = callerType == Account .Type .NORMAL ? -1L : null ;
376+
377+ accountMgr .buildACLSearchParameters (caller , id , null , projectId , permittedAccounts , domainIdRecursiveListProject , true , false );
366378 Long domainId = domainIdRecursiveListProject .first ();
367379 Boolean isRecursive = domainIdRecursiveListProject .second ();
368380 Project .ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject .third ();
0 commit comments