Skip to content

Commit 2229e3e

Browse files
committed
CLOUDSTACK-4803:
fix listVirtualMachines to not display vms to the normal users with forDisplay=false. But displayvms to ROOT Admin irrespective of the flag. Signed off by : nitin mehta<nitin.mehta@citrix.com>
1 parent 59ad4a9 commit 2229e3e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎server/src/com/cloud/api/query/QueryManagerImpl.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,7 @@ private Pair<List<UserVmJoinVO>, Integer> searchForUserVMsByCriteria(Criteria c,
768768
ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String> tags) {
769769
Filter searchFilter = new Filter(UserVmJoinVO.class, c.getOrderBy(), c.getAscending(), c.getOffset(),
770770
c.getLimit());
771+
boolean isRootAdmin = _accountMgr.isRootAdmin(caller.getType());
771772

772773
// first search distinct vm id by using query criteria and pagination
773774
SearchBuilder<UserVmJoinVO> sb = _userVmJoinDao.createSearchBuilder();
@@ -831,6 +832,10 @@ private Pair<List<UserVmJoinVO>, Integer> searchForUserVMsByCriteria(Criteria c,
831832
sb.and("affinityGroupId", sb.entity().getAffinityGroupId(), SearchCriteria.Op.EQ);
832833
}
833834

835+
if(!isRootAdmin){
836+
sb.and("displayVm", sb.entity().isDisplayVm(), SearchCriteria.Op.EQ);
837+
}
838+
834839
// populate the search criteria with the values passed in
835840
SearchCriteria<UserVmJoinVO> sc = sb.create();
836841

@@ -936,6 +941,9 @@ private Pair<List<UserVmJoinVO>, Integer> searchForUserVMsByCriteria(Criteria c,
936941
sc.setParameters("affinityGroupId", affinityGroupId);
937942
}
938943

944+
if(!isRootAdmin){
945+
sc.setParameters("displayVm", 1);
946+
}
939947
// search vm details by ids
940948
Pair<List<UserVmJoinVO>, Integer> uniqueVmPair = _userVmJoinDao.searchAndCount(sc, searchFilter);
941949
Integer count = uniqueVmPair.second();

0 commit comments

Comments
 (0)