Skip to content

Commit 085038e

Browse files
committed
address review comments
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent fc29c19 commit 085038e

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ public class ListVMsCmd extends BaseListRetrieveOnlyResourceCountCmd implements
9898
collectionType = CommandType.STRING,
9999
description = "comma separated list of host details requested, "
100100
+ "value can be a list of [all, group, nics, stats, secgrp, tmpl, servoff, diskoff, iso, volume, min, affgrp]."
101-
+ " If no parameter is passed in, the details will be defaulted to, all details excluding stats "
102-
+ " for the listVirtualMachines API, and all details including stats for the listVirtualMachinesMetrics API")
101+
+ " If no parameter is passed in, the details will be defaulted to all details excluding/including stats "
102+
+ " for the listVirtualMachines API as determined by list.vm.default.details.stats setting (default: false)."
103+
+ " However, all details including stats are returned for the listVirtualMachinesMetrics API")
103104
protected List<String> viewDetails;
104105

105106
@Parameter(name = ApiConstants.TEMPLATE_ID, type = CommandType.UUID, entityType = TemplateResponse.class, description = "list vms by template")

api/src/main/java/org/apache/cloudstack/query/QueryService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ public interface QueryService {
125125
static final ConfigKey<Boolean> SharePublicTemplatesWithOtherDomains = new ConfigKey<>("Advanced", Boolean.class, "share.public.templates.with.other.domains", "true",
126126
"If false, templates of this domain will not show up in the list templates of other domains.", true, ConfigKey.Scope.Domain);
127127

128+
ConfigKey<Boolean> AllowStatsInDefaultDetailsForListVMs = new ConfigKey<>("Advanced", Boolean.class, "list.vm.default.details.stats", "false",
129+
"Determines whether VM stats should be returned when details are not specified in listVirtualMachines API request", true, ConfigKey.Scope.Global);
130+
128131
ListResponse<UserResponse> searchForUsers(ListUsersCmd cmd) throws PermissionDeniedException;
129132

130133
ListResponse<UserResponse> searchForUsers(Long domainId, boolean recursive) throws PermissionDeniedException;

engine/schema/src/main/resources/META-INF/db/schema-41900to41910-cleanup.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@
1818
--;
1919
-- Schema upgrade cleanup from 4.19.0.0 to 4.19.1.0
2020
--;
21+
22+
DELETE from cloud.configuration where name='vm.stats.increment.metrics.in.memory';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5686,6 +5686,6 @@ public String getConfigComponentName() {
56865686
@Override
56875687
public ConfigKey<?>[] getConfigKeys() {
56885688
return new ConfigKey<?>[] {AllowUserViewDestroyedVM, UserVMDeniedDetails, UserVMReadOnlyDetails, SortKeyAscending,
5689-
AllowUserViewAllDomainAccounts, SharePublicTemplatesWithOtherDomains};
5689+
AllowUserViewAllDomainAccounts, SharePublicTemplatesWithOtherDomains, AllowStatsInDefaultDetailsForListVMs};
56905690
}
56915691
}

server/src/main/java/com/cloud/api/query/dao/UserVmJoinDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public UserVmResponse newUserVmResponse(ResponseView view, String objectName, Us
251251
userVmResponse.setOsDisplayName(guestOS.getDisplayName());
252252
}
253253

254-
if (details.contains(VMDetails.stats)) {
254+
if (details.contains(VMDetails.stats) || (QueryService.AllowStatsInDefaultDetailsForListVMs.value() && details.contains(VMDetails.all))) {
255255
// stats calculation
256256
VmStats vmStats = ApiDBUtils.getVmStatistics(userVm.getId(), accumulateStats);
257257
if (vmStats != null) {

0 commit comments

Comments
 (0)