mirror of https://github.com/apache/cloudstack.git
bug 8944: default page size for list* API commands is taken from global config params now. The name of the parameter is "default.page.size", default value is 50
status 8944: resolved fixed
This commit is contained in:
parent
107103a6e1
commit
ff5cef64d0
|
|
@ -2187,5 +2187,7 @@ public interface ManagementServer {
|
|||
|
||||
|
||||
Long getDomainIdForVlan(long vlanDbId);
|
||||
|
||||
Integer getDefaultPageSize();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public class ListAccountsCmd extends BaseCmd{
|
|||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class ListAlertsCmd extends BaseCmd{
|
|||
Integer pageSize = (Integer)params.get(BaseCmd.Properties.PAGESIZE.getName());
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class ListAsyncJobsCmd extends BaseCmd {
|
|||
Date startDate = (Date)params.get(BaseCmd.Properties.START_TZDATE.getName());
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,23 +18,23 @@
|
|||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.capacity.CapacityVO;
|
||||
import com.cloud.server.Criteria;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
public class ListCapacityCmd extends BaseCmd{
|
||||
|
|
@ -67,12 +67,12 @@ public class ListCapacityCmd extends BaseCmd{
|
|||
Long hostId = (Long)params.get(BaseCmd.Properties.HOST_ID.getName());
|
||||
String type = (String)params.get(BaseCmd.Properties.TYPE.getName());
|
||||
Integer page = (Integer)params.get(BaseCmd.Properties.PAGE.getName());
|
||||
Integer pageSize = (Integer)params.get(BaseCmd.Properties.PAGESIZE.getName());
|
||||
Long pageSize = (Long)params.get(BaseCmd.Properties.PAGESIZE.getName());
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 1000000;
|
||||
Long pageSizeNum = null;
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
pageSizeNum = pageSize;
|
||||
}
|
||||
if (page != null) {
|
||||
int pageNum = page.intValue();
|
||||
|
|
@ -81,7 +81,7 @@ public class ListCapacityCmd extends BaseCmd{
|
|||
}
|
||||
}
|
||||
|
||||
Criteria c = new Criteria ("capacityType", Boolean.TRUE, startIndex, Long.valueOf(pageSizeNum));
|
||||
Criteria c = new Criteria ("capacityType", Boolean.TRUE, startIndex, pageSizeNum);
|
||||
c.addCriteria(Criteria.DATACENTERID, zoneId);
|
||||
c.addCriteria(Criteria.PODID, podId);
|
||||
c.addCriteria(Criteria.HOSTID, hostId);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class ListCfgsByCmd extends BaseCmd {
|
|||
Integer pageSize = (Integer)params.get(BaseCmd.Properties.PAGESIZE.getName());
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 100;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public class ListClustersCmd extends BaseCmd {
|
|||
Integer pageSize = (Integer) params.get(BaseCmd.Properties.PAGESIZE.getName());
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public class ListDiskOfferingsCmd extends BaseCmd {
|
|||
Integer pageSize = (Integer)params.get(BaseCmd.Properties.PAGESIZE.getName());
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class ListDomainChildrenCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class ListDomainsCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public class ListEventsCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public class ListHostsCmd extends BaseCmd {
|
|||
Integer pageSize = (Integer) params.get(BaseCmd.Properties.PAGESIZE.getName());
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ public class ListIsosCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public class ListLoadBalancerRulesCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public class ListNetworkGroupsCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ public class ListPortForwardingServicesCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class ListPreallocatedLunsCmd extends BaseCmd {
|
|||
Integer pageSize = (Integer)params.get(BaseCmd.Properties.PAGESIZE.getName());
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ public class ListPublicIpAddressesCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ public class ListResourceLimitsCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public class ListRoutersCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class ListServiceOfferingsCmd extends BaseCmd {
|
|||
Long domainId = (Long)params.get(BaseCmd.Properties.DOMAIN_ID.getName());
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public class ListSnapshotsCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class ListStoragePoolsCmd extends BaseCmd{
|
|||
Integer pageSize = (Integer)params.get(BaseCmd.Properties.PAGESIZE.getName());
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public class ListSystemVMsCmd extends BaseCmd {
|
|||
Integer pageSize = (Integer)params.get(BaseCmd.Properties.PAGESIZE.getName());
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public class ListTemplatesCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public class ListUsersCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ public class ListVMsCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 500;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class ListVlanIpRangesCmd extends BaseCmd {
|
|||
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ public class ListVolumesCmd extends BaseCmd{
|
|||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
int pageSizeNum = getManagementServer().getDefaultPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,7 +177,9 @@ public enum Config {
|
|||
CloudIdentifier("Hidden", ManagementServer.class, String.class, "cloud.identifier", null, "A unique identifier for the cloud.", null),
|
||||
SSOKey("Hidden", ManagementServer.class, String.class, "security.singlesignon.key", null, "A Single Sign-On key used for logging into the cloud", null),
|
||||
SSOAuthTolerance("Advanced", ManagementServer.class, Long.class, "security.singlesignon.tolerance.millis", "300000", "The allowable clock difference in milliseconds between when an SSO login request is made and when it is received.", null),
|
||||
HashKey("Hidden", ManagementServer.class, String.class, "security.hash.key", null, "for generic key-ed hash", null);
|
||||
HashKey("Hidden", ManagementServer.class, String.class, "security.hash.key", null, "for generic key-ed hash", null),
|
||||
|
||||
DefaultPageSize("Advanced", ManagementServer.class, Integer.class, "default.page.size", "50", "Default page size for API list* commands", null);
|
||||
|
||||
private final String _category;
|
||||
private final Class<?> _componentClass;
|
||||
|
|
|
|||
|
|
@ -355,6 +355,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
private final Map<String, String> _configs;
|
||||
|
||||
private String _domain;
|
||||
private Integer _defaultPageSize;
|
||||
private int _consoleProxyPort = ConsoleProxyManager.DEFAULT_PROXY_VNC_PORT;
|
||||
// private int _consoleProxyUrlPort =
|
||||
// ConsoleProxyManager.DEFAULT_PROXY_URL_PORT;
|
||||
|
|
@ -505,6 +506,13 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
if (_instance == null) {
|
||||
_instance = "DEFAULT";
|
||||
}
|
||||
|
||||
//get default page size from configuration
|
||||
_defaultPageSize = Integer.valueOf(_configs.get("default.page.size"));
|
||||
if (_defaultPageSize == null) {
|
||||
_defaultPageSize = 50;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected Map<String, String> getConfigs() {
|
||||
|
|
@ -8474,5 +8482,10 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
return accountVlanMaps.get(0).getDomainId();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getDefaultPageSize() {
|
||||
return _defaultPageSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
INSERT INTO configuration VALUES ('Advanced', 'DEFAULT', 'management-server', 'default.page.size', '50', 'Default page size for API list* commands');
|
||||
Loading…
Reference in New Issue