Skip to content

Commit 402467a

Browse files
committed
Allowing listVirtualMachinesMetrics to respect hostid
1 parent ca9dceb commit 402467a

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,18 @@ public String getKeyPairName() {
200200
return keypair;
201201
}
202202

203+
public Long getHostId() {
204+
return hostId;
205+
}
206+
207+
public Long getPodId() {
208+
return podId;
209+
}
210+
211+
public Long getStorageId() {
212+
return storageId;
213+
}
214+
203215
public EnumSet<VMDetails> getDetails() throws InvalidParameterValueException {
204216
EnumSet<VMDetails> dv;
205217
if (viewDetails == null || viewDetails.size() <= 0) {

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
import org.apache.cloudstack.api.command.admin.storage.ListStorageTagsCmd;
5858
import org.apache.cloudstack.api.command.admin.template.ListTemplatesCmdByAdmin;
5959
import org.apache.cloudstack.api.command.admin.user.ListUsersCmd;
60-
import org.apache.cloudstack.api.command.admin.vm.ListVMsCmdByAdmin;
6160
import org.apache.cloudstack.api.command.admin.zone.ListZonesCmdByAdmin;
6261
import org.apache.cloudstack.api.command.user.account.ListAccountsCmd;
6362
import org.apache.cloudstack.api.command.user.account.ListProjectAccountsCmd;
@@ -910,11 +909,10 @@ private Pair<List<UserVmJoinVO>, Integer> searchForUserVMsInternal(ListVMsCmd cm
910909
Object pod = null;
911910
Object hostId = null;
912911
Object storageId = null;
913-
if (cmd instanceof ListVMsCmdByAdmin) {
914-
ListVMsCmdByAdmin adCmd = (ListVMsCmdByAdmin)cmd;
915-
pod = adCmd.getPodId();
916-
hostId = adCmd.getHostId();
917-
storageId = adCmd.getStorageId();
912+
if (_accountMgr.isRootAdmin(caller.getId())) {
913+
pod = cmd.getPodId();
914+
hostId = cmd.getHostId();
915+
storageId = cmd.getStorageId();
918916
}
919917

920918
sb.and("displayName", sb.entity().getDisplayName(), SearchCriteria.Op.LIKE);
@@ -1064,9 +1062,8 @@ private Pair<List<UserVmJoinVO>, Integer> searchForUserVMsInternal(ListVMsCmd cm
10641062
sc.setParameters("keyPairName", keyPairName);
10651063
}
10661064

1067-
if (cmd instanceof ListVMsCmdByAdmin) {
1068-
ListVMsCmdByAdmin aCmd = (ListVMsCmdByAdmin)cmd;
1069-
if (aCmd.getPodId() != null) {
1065+
if (_accountMgr.isRootAdmin(caller.getId())) {
1066+
if (cmd.getPodId() != null) {
10701067
sc.setParameters("podId", pod);
10711068

10721069
if (state == null) {

0 commit comments

Comments
 (0)