mirror of https://github.com/apache/cloudstack.git
Refactoring work on listCapacities, listConfigurations, listClusters, and listDiskOfferings commands. The work represents consolidating the Criteria object into just pulling the search criteria directly from the command. Also changed BaseListCmd to server the startIndex and pageSizeVal [includes default page size of 50] rather than have each search command compute these things.
This commit is contained in:
parent
68275debc0
commit
e55e6c283f
|
|
@ -2,6 +2,8 @@ package com.cloud.api;
|
|||
|
||||
|
||||
public abstract class BaseListCmd extends BaseCmd {
|
||||
private static final long DEFAULT_PAGE_SIZE = 50;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////// BaseList API parameters /////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -31,4 +33,25 @@ public abstract class BaseListCmd extends BaseCmd {
|
|||
public Integer getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public Long getPageSizeVal() {
|
||||
Long pageSize = DEFAULT_PAGE_SIZE;
|
||||
Integer pageSizeInt = getPageSize();
|
||||
if (pageSizeInt != null) {
|
||||
pageSize = pageSizeInt.longValue();
|
||||
}
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public Long getStartIndex() {
|
||||
Long startIndex = Long.valueOf(0);
|
||||
Long pageSizeVal = getPageSizeVal();
|
||||
if (page != null) {
|
||||
int pageNum = page.intValue();
|
||||
if (pageNum > 0) {
|
||||
startIndex = Long.valueOf(pageSizeVal * (pageNum-1));
|
||||
}
|
||||
}
|
||||
return startIndex;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,31 +30,25 @@ import java.util.StringTokenizer;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.CapacityResponse;
|
||||
import com.cloud.capacity.CapacityVO;
|
||||
import com.cloud.serializer.SerializerHelper;
|
||||
import com.cloud.server.Criteria;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
public class ListCapacityCmd extends BaseCmd{
|
||||
|
||||
@Implementation(method="listCapacities")
|
||||
public class ListCapacityCmd extends BaseListCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(ListCapacityCmd.class.getName());
|
||||
private static final DecimalFormat s_percentFormat = new DecimalFormat("####.##");
|
||||
|
||||
private static final String s_name = "listcapacityresponse";
|
||||
private static final List<Pair<Enum, Boolean>> s_properties = new ArrayList<Pair<Enum, Boolean>>();
|
||||
|
||||
static {
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.HOST_ID, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.POD_ID, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.TYPE, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ZONE_ID, Boolean.FALSE));
|
||||
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.PAGE, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.PAGESIZE, Boolean.FALSE));
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
|
|
@ -97,86 +91,54 @@ public class ListCapacityCmd extends BaseCmd{
|
|||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
public List<Pair<Enum, Boolean>> getProperties() {
|
||||
return s_properties;
|
||||
}
|
||||
|
||||
public List<Pair<String, Object>> execute(Map<String, Object> params) {
|
||||
Long zoneId = (Long)params.get(BaseCmd.Properties.ZONE_ID.getName());
|
||||
Long podId = (Long)params.get(BaseCmd.Properties.POD_ID.getName());
|
||||
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 startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 1000000;
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
if (page != null) {
|
||||
int pageNum = page.intValue();
|
||||
if (pageNum > 0) {
|
||||
startIndex = Long.valueOf(pageSizeNum * (pageNum-1));
|
||||
}
|
||||
}
|
||||
|
||||
Criteria c = new Criteria ("capacityType", Boolean.TRUE, startIndex, Long.valueOf(pageSizeNum));
|
||||
c.addCriteria(Criteria.DATACENTERID, zoneId);
|
||||
c.addCriteria(Criteria.PODID, podId);
|
||||
c.addCriteria(Criteria.HOSTID, hostId);
|
||||
c.addCriteria(Criteria.TYPE, type);
|
||||
|
||||
List<CapacityVO> capacities = getManagementServer().listCapacities(c);
|
||||
|
||||
if (capacities == null ) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "unable to get capacity statistic");
|
||||
}
|
||||
|
||||
List<CapacityVO> summedCapacities = sumCapacities(capacities);
|
||||
List<Pair<String, Object>> capacitiesTags = new ArrayList<Pair<String, Object>>();
|
||||
Object[] cTag = new Object[summedCapacities.size()];
|
||||
int i=0;
|
||||
|
||||
for (CapacityVO capacity : summedCapacities) {
|
||||
List<Pair<String, Object>> capacityData = new ArrayList<Pair<String, Object>>();
|
||||
capacityData.add(new Pair<String, Object>(BaseCmd.Properties.TYPE.getName(), capacity.getCapacityType()));
|
||||
capacityData.add(new Pair<String, Object>(BaseCmd.Properties.ZONE_ID.getName(), capacity.getDataCenterId()));
|
||||
capacityData.add(new Pair<String, Object>(BaseCmd.Properties.ZONE_NAME.getName(), getManagementServer().getDataCenterBy(capacity.getDataCenterId()).getName()));
|
||||
if (capacity.getPodId() != null) {
|
||||
capacityData.add(new Pair<String, Object>(BaseCmd.Properties.POD_ID.getName(), capacity.getPodId()));
|
||||
capacityData.add(new Pair<String, Object>(BaseCmd.Properties.POD_NAME.getName(), (capacity.getPodId() > 0) ? getManagementServer().findHostPodById(capacity.getPodId()).getName() : "All"));
|
||||
}
|
||||
capacityData.add(new Pair<String, Object>(BaseCmd.Properties.CAPACITY_USED.getName(), Long.valueOf(capacity.getUsedCapacity()).toString()));
|
||||
capacityData.add(new Pair<String, Object>(BaseCmd.Properties.CAPACITY_TOTAL.getName(), Long.valueOf(capacity.getTotalCapacity()).toString()));
|
||||
try {
|
||||
if (capacity.getTotalCapacity() != 0) {
|
||||
float percent = (float)capacity.getUsedCapacity()/(float)capacity.getTotalCapacity()*100;
|
||||
capacityData.add(new Pair<String, Object>(BaseCmd.Properties.PERCENT_USED.getName(), s_percentFormat.format(percent)));
|
||||
}
|
||||
else {
|
||||
capacityData.add(new Pair<String, Object>(BaseCmd.Properties.PERCENT_USED.getName(), s_percentFormat.format(0)));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new ServerApiException (BaseCmd.INTERNAL_ERROR, "unable to get capacity statistic");
|
||||
}
|
||||
cTag[i++] = capacityData;
|
||||
}
|
||||
|
||||
Pair<String, Object> capacityTag = new Pair<String, Object>("capacity", cTag);
|
||||
capacitiesTags.add(capacityTag);
|
||||
return capacitiesTags;
|
||||
@Override
|
||||
public Long getPageSizeVal() {
|
||||
Long pageSizeVal = 1000000L;
|
||||
Integer pageSize = getPageSize();
|
||||
if (pageSize != null) {
|
||||
pageSizeVal = pageSize.longValue();
|
||||
}
|
||||
return pageSizeVal;
|
||||
}
|
||||
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
public String getResponse() {
|
||||
List<CapacityVO> capacities = (List<CapacityVO>)getResponseObject();
|
||||
|
||||
List<CapacityVO> summedCapacities = sumCapacities(capacities);
|
||||
List<CapacityResponse> response = new ArrayList<CapacityResponse>();
|
||||
for (CapacityVO summedCapacity : summedCapacities) {
|
||||
CapacityResponse capacityResponse = new CapacityResponse();
|
||||
capacityResponse.setCapacityTotal(summedCapacity.getTotalCapacity());
|
||||
capacityResponse.setCapacityType(summedCapacity.getCapacityType());
|
||||
capacityResponse.setCapacityUsed(summedCapacity.getUsedCapacity());
|
||||
capacityResponse.setPodId(summedCapacity.getPodId());
|
||||
capacityResponse.setZoneId(summedCapacity.getDataCenterId());
|
||||
// TODO: implement
|
||||
// capacityResponse.setPodName(podName);
|
||||
// capacityResponse.setZoneName(zoneName);
|
||||
if (summedCapacity.getTotalCapacity() != 0) {
|
||||
capacityResponse.setPercentUsed(s_percentFormat.format(summedCapacity.getUsedCapacity() / summedCapacity.getTotalCapacity()));
|
||||
} else {
|
||||
capacityResponse.setPercentUsed(s_percentFormat.format(0L));
|
||||
}
|
||||
}
|
||||
|
||||
return SerializerHelper.toSerializedString(response);
|
||||
}
|
||||
|
||||
public List<CapacityVO> sumCapacities(List<CapacityVO> hostCapacities) {
|
||||
private List<CapacityVO> sumCapacities(List<CapacityVO> hostCapacities) {
|
||||
Map<String, Long> totalCapacityMap = new HashMap<String, Long>();
|
||||
Map<String, Long> usedCapacityMap = new HashMap<String, Long>();
|
||||
|
||||
Set<Long> poolIdsToIgnore = new HashSet<Long>();
|
||||
Criteria c = new Criteria();
|
||||
// TODO: implement
|
||||
List<? extends StoragePoolVO> allStoragePools = getManagementServer().searchForStoragePools(c);
|
||||
for (StoragePoolVO pool : allStoragePools) {
|
||||
StoragePoolType poolType = pool.getPoolType();
|
||||
|
|
|
|||
|
|
@ -20,31 +20,21 @@ package com.cloud.api.commands;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.ConfigurationResponse;
|
||||
import com.cloud.configuration.ConfigurationVO;
|
||||
import com.cloud.server.Criteria;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.serializer.SerializerHelper;
|
||||
|
||||
public class ListCfgsByCmd extends BaseCmd {
|
||||
@Implementation(method="searchForConfigurations")
|
||||
public class ListCfgsByCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListCfgsByCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listconfigurationsresponse";
|
||||
private static final List<Pair<Enum, Boolean>> s_properties = new ArrayList<Pair<Enum, Boolean>>();
|
||||
|
||||
static {
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.NAME, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.CATEGORY, Boolean.FALSE));
|
||||
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.KEYWORD, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.PAGE, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.PAGESIZE, Boolean.FALSE));
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
|
|
@ -74,61 +64,26 @@ public class ListCfgsByCmd extends BaseCmd {
|
|||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
public List<Pair<Enum, Boolean>> getProperties() {
|
||||
return s_properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<String, Object>> execute(Map<String, Object> params) {
|
||||
String name = (String) params.get(BaseCmd.Properties.NAME.getName());
|
||||
String category = (String) params.get(BaseCmd.Properties.CATEGORY.getName());
|
||||
String keyword = (String)params.get(BaseCmd.Properties.KEYWORD.getName());
|
||||
Integer page = (Integer)params.get(BaseCmd.Properties.PAGE.getName());
|
||||
Integer pageSize = (Integer)params.get(BaseCmd.Properties.PAGESIZE.getName());
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 100;
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
if (page != null) {
|
||||
int pageNum = page.intValue();
|
||||
if (pageNum > 0) {
|
||||
startIndex = Long.valueOf(pageSizeNum * (pageNum-1));
|
||||
}
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
public String getResponse() {
|
||||
List<ConfigurationVO> configurations = (List<ConfigurationVO>)getResponseObject();
|
||||
|
||||
List<ConfigurationResponse> response = new ArrayList<ConfigurationResponse>();
|
||||
for (ConfigurationVO cfg : configurations) {
|
||||
ConfigurationResponse cfgResponse = new ConfigurationResponse();
|
||||
cfgResponse.setCategory(cfg.getCategory());
|
||||
cfgResponse.setDescription(cfg.getDescription());
|
||||
cfgResponse.setName(cfg.getName());
|
||||
cfgResponse.setValue(cfg.getValue());
|
||||
|
||||
response.add(cfgResponse);
|
||||
}
|
||||
|
||||
Criteria c = new Criteria ("name", Boolean.TRUE, startIndex, Long.valueOf(pageSizeNum));
|
||||
if (keyword != null) {
|
||||
c.addCriteria(Criteria.KEYWORD, keyword);
|
||||
} else {
|
||||
c.addCriteria(Criteria.NAME, name);
|
||||
c.addCriteria(Criteria.CATEGORY, category);
|
||||
}
|
||||
|
||||
List<ConfigurationVO> configs = getManagementServer().searchForConfigurations(c, false);
|
||||
|
||||
if (configs == null) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Unable to find configuration values for specified search criteria.");
|
||||
}
|
||||
|
||||
List<Pair<String, Object>> cfgTags = new ArrayList<Pair<String, Object>>();
|
||||
Object[] cfgDataTags = new Object[configs.size()];
|
||||
|
||||
int i = 0;
|
||||
for (ConfigurationVO config : configs) {
|
||||
List<Pair<String, Object>> cfgData = new ArrayList<Pair<String, Object>>();
|
||||
cfgData.add(new Pair<String, Object>(BaseCmd.Properties.CATEGORY.getName(), config.getCategory()));
|
||||
cfgData.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), config.getName()));
|
||||
cfgData.add(new Pair<String, Object>(BaseCmd.Properties.VALUE.getName(), config.getValue()));
|
||||
cfgData.add(new Pair<String, Object>(BaseCmd.Properties.DESCRIPTION.getName(), config.getDescription()));
|
||||
cfgDataTags[i++] = cfgData;
|
||||
}
|
||||
Pair<String, Object> cfgTag = new Pair<String, Object>("configuration", cfgDataTags);
|
||||
cfgTags.add(cfgTag);
|
||||
return cfgTags;
|
||||
|
||||
return SerializerHelper.toSerializedString(response);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,34 +20,21 @@ package com.cloud.api.commands;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.ClusterResponse;
|
||||
import com.cloud.dc.ClusterVO;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.server.Criteria;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.serializer.SerializerHelper;
|
||||
|
||||
public class ListClustersCmd extends BaseCmd {
|
||||
@Implementation(method="searchForClusters")
|
||||
public class ListClustersCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListServiceOfferingsCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listclustersresponse";
|
||||
private static final List<Pair<Enum, Boolean>> s_properties = new ArrayList<Pair<Enum, Boolean>>();
|
||||
|
||||
static {
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ID, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.NAME, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.POD_ID, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ZONE_ID, Boolean.FALSE));
|
||||
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.PAGE, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.PAGESIZE, Boolean.FALSE));
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
|
|
@ -90,68 +77,29 @@ public class ListClustersCmd extends BaseCmd {
|
|||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
public List<Pair<Enum, Boolean>> getProperties() {
|
||||
return s_properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<String, Object>> execute(Map<String, Object> params) {
|
||||
Long id = (Long) params.get(BaseCmd.Properties.ID.getName());
|
||||
String name = (String) params.get(BaseCmd.Properties.NAME.getName());
|
||||
Long podId = (Long) params.get(BaseCmd.Properties.POD_ID.getName());
|
||||
Long zoneId = (Long) params.get(BaseCmd.Properties.ZONE_ID.getName());
|
||||
Integer page = (Integer) params.get(BaseCmd.Properties.PAGE.getName());
|
||||
Integer pageSize = (Integer) params.get(BaseCmd.Properties.PAGESIZE.getName());
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
if (page != null) {
|
||||
int pageNum = page.intValue();
|
||||
if (pageNum > 0) {
|
||||
startIndex = Long.valueOf(pageSizeNum * (pageNum-1));
|
||||
}
|
||||
}
|
||||
Criteria c = new Criteria("id", Boolean.TRUE, startIndex, Long.valueOf(pageSizeNum));
|
||||
c.addCriteria(Criteria.ID, id);
|
||||
c.addCriteria(Criteria.NAME, name);
|
||||
c.addCriteria(Criteria.PODID, podId);
|
||||
c.addCriteria(Criteria.DATACENTERID, zoneId);
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
public String getResponse() {
|
||||
List<ClusterVO> clusters = (List<ClusterVO>)getResponseObject();
|
||||
|
||||
List<ClusterVO> clusters = getManagementServer().searchForClusters(c);
|
||||
|
||||
if (clusters == null) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "unable to find clusters");
|
||||
}
|
||||
|
||||
List<Pair<String, Object>> clusterTags = new ArrayList<Pair<String, Object>>();
|
||||
Object[] cTag = new Object[clusters.size()];
|
||||
int i = 0;
|
||||
List<ClusterResponse> response = new ArrayList<ClusterResponse>();
|
||||
for (ClusterVO cluster : clusters) {
|
||||
List<Pair<String, Object>> clusterData = new ArrayList<Pair<String, Object>>();
|
||||
|
||||
clusterData.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), cluster.getId()));
|
||||
clusterData.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), cluster.getName()));
|
||||
|
||||
HostPodVO pod = getManagementServer().findHostPodById(cluster.getPodId());
|
||||
clusterData.add(new Pair<String, Object>(BaseCmd.Properties.POD_ID.getName(), pod.getId()));
|
||||
clusterData.add(new Pair<String, Object>(BaseCmd.Properties.POD_NAME.getName(), pod.getName()));
|
||||
|
||||
DataCenterVO zone = getManagementServer().findDataCenterById(cluster.getDataCenterId());
|
||||
clusterData.add(new Pair<String, Object>(BaseCmd.Properties.ZONE_ID.getName(), zone.getId()));
|
||||
clusterData.add(new Pair<String, Object>(BaseCmd.Properties.ZONE_NAME.getName(), zone.getName()));
|
||||
|
||||
cTag[i++] = clusterData;
|
||||
ClusterResponse clusterResponse = new ClusterResponse();
|
||||
clusterResponse.setId(cluster.getId());
|
||||
clusterResponse.setName(cluster.getName());
|
||||
clusterResponse.setPodId(cluster.getPodId());
|
||||
clusterResponse.setZoneId(cluster.getDataCenterId());
|
||||
// TODO: implement
|
||||
// HostPodVO pod = getManagementServer().findHostPodById(cluster.getPodId());
|
||||
// clusterResponse.setPodName(podName);
|
||||
// DataCenterVO zone = getManagementServer().findDataCenterById(cluster.getDataCenterId());
|
||||
// clusterResponse.setZoneName(zoneName);
|
||||
}
|
||||
|
||||
Pair<String, Object> clusterTag = new Pair<String, Object>("cluster", cTag);
|
||||
clusterTags.add(clusterTag);
|
||||
|
||||
return clusterTags;
|
||||
|
||||
return SerializerHelper.toSerializedString(response);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,34 +20,22 @@ package com.cloud.api.commands;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.server.Criteria;
|
||||
import com.cloud.api.response.DiskOfferingResponse;
|
||||
import com.cloud.serializer.SerializerHelper;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
public class ListDiskOfferingsCmd extends BaseCmd {
|
||||
|
||||
@Implementation(method="searchForDiskOfferings")
|
||||
public class ListDiskOfferingsCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListDiskOfferingsCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listdiskofferingsresponse";
|
||||
private static final List<Pair<Enum, Boolean>> s_properties = new ArrayList<Pair<Enum, Boolean>>();
|
||||
|
||||
static {
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ACCOUNT_OBJ, Boolean.FALSE));
|
||||
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.DOMAIN_ID, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ID, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.NAME, Boolean.FALSE));
|
||||
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.KEYWORD, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.PAGE, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.PAGESIZE, Boolean.FALSE));
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -86,62 +74,28 @@ public class ListDiskOfferingsCmd extends BaseCmd {
|
|||
@Override
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
@Override
|
||||
public List<Pair<Enum, Boolean>> getProperties() {
|
||||
return s_properties;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<String, Object>> execute(Map<String, Object> params) {
|
||||
Long id = (Long)params.get(BaseCmd.Properties.ID.getName());
|
||||
Long domainId = (Long)params.get(BaseCmd.Properties.DOMAIN_ID.getName());
|
||||
String name = (String)params.get(BaseCmd.Properties.NAME.getName());
|
||||
String keyword = (String)params.get(BaseCmd.Properties.KEYWORD.getName());
|
||||
Integer page = (Integer)params.get(BaseCmd.Properties.PAGE.getName());
|
||||
Integer pageSize = (Integer)params.get(BaseCmd.Properties.PAGESIZE.getName());
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
if (page != null) {
|
||||
int pageNum = page.intValue();
|
||||
if (pageNum > 0) {
|
||||
startIndex = Long.valueOf(pageSizeNum * (pageNum-1));
|
||||
}
|
||||
}
|
||||
|
||||
Criteria c = new Criteria("id", Boolean.TRUE, startIndex, Long.valueOf(pageSizeNum));
|
||||
if (keyword != null) {
|
||||
c.addCriteria(Criteria.KEYWORD, keyword);
|
||||
}else {
|
||||
c.addCriteria(Criteria.ID, id);
|
||||
c.addCriteria(Criteria.NAME, name);
|
||||
c.addCriteria(Criteria.DOMAINID, domainId);
|
||||
}
|
||||
|
||||
List<DiskOfferingVO> offerings = getManagementServer().searchForDiskOfferings(c);
|
||||
|
||||
List<Pair<String, Object>> offeringTags = new ArrayList<Pair<String, Object>>();
|
||||
Object[] diskOffTag = new Object[offerings.size()];
|
||||
int i = 0;
|
||||
for (DiskOfferingVO offering : offerings) {
|
||||
List<Pair<String, Object>> offeringData = new ArrayList<Pair<String, Object>>();
|
||||
|
||||
offeringData.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), Long.toString(offering.getId())));
|
||||
offeringData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN_ID.getName(), offering.getDomainId()));
|
||||
offeringData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN.getName(), getManagementServer().findDomainIdById(offering.getDomainId()).getName()));
|
||||
offeringData.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), offering.getName()));
|
||||
offeringData.add(new Pair<String, Object>(BaseCmd.Properties.DISPLAY_TEXT.getName(), offering.getDisplayText()));
|
||||
offeringData.add(new Pair<String, Object>(BaseCmd.Properties.DISK_SIZE.getName(), offering.getDiskSizeInBytes()));
|
||||
offeringData.add(new Pair<String, Object>(BaseCmd.Properties.IS_MIRRORED.getName(), offering.isMirrored()));
|
||||
offeringData.add(new Pair<String, Object>(BaseCmd.Properties.TAGS.getName(), offering.getTags()));
|
||||
diskOffTag[i++] = offeringData;
|
||||
}
|
||||
Pair<String, Object> offeringTag = new Pair<String, Object>("diskoffering", diskOffTag);
|
||||
offeringTags.add(offeringTag);
|
||||
return offeringTags;
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
public String getResponse() {
|
||||
List<DiskOfferingVO> offerings = (List<DiskOfferingVO>)getResponseObject();
|
||||
|
||||
List<DiskOfferingResponse> response = new ArrayList<DiskOfferingResponse>();
|
||||
for (DiskOfferingVO offering : offerings) {
|
||||
DiskOfferingResponse diskOffResp = new DiskOfferingResponse();
|
||||
diskOffResp.setCreated(offering.getCreated());
|
||||
diskOffResp.setDiskSize(offering.getDiskSize());
|
||||
diskOffResp.setDisplayText(offering.getDisplayText());
|
||||
diskOffResp.setDomainId(offering.getDomainId());
|
||||
diskOffResp.setId(offering.getId());
|
||||
diskOffResp.setName(offering.getName());
|
||||
diskOffResp.setTags(offering.getTags());
|
||||
// TODO: implement
|
||||
// getManagementServer().findDomainIdById(offering.getDomainId()).getName()
|
||||
// diskOffResp.setDomain(domain);
|
||||
|
||||
}
|
||||
|
||||
return SerializerHelper.toSerializedString(response);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,94 @@
|
|||
package com.cloud.api.response;
|
||||
|
||||
import com.cloud.api.ResponseObject;
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
public class CapacityResponse implements ResponseObject {
|
||||
@Param(name="type")
|
||||
private Short capacityType;
|
||||
|
||||
@Param(name="zoneid")
|
||||
private Long zoneId;
|
||||
|
||||
@Param(name="zonename")
|
||||
private String zoneName;
|
||||
|
||||
@Param(name="podid")
|
||||
private Long podId;
|
||||
|
||||
@Param(name="podname")
|
||||
private String podName;
|
||||
|
||||
@Param(name="capacityused")
|
||||
private Long capacityUsed;
|
||||
|
||||
@Param(name="capacityTotal")
|
||||
private Long capacityTotal;
|
||||
|
||||
@Param(name="percentused")
|
||||
private String percentUsed;
|
||||
|
||||
public Short getCapacityType() {
|
||||
return capacityType;
|
||||
}
|
||||
|
||||
public void setCapacityType(Short capacityType) {
|
||||
this.capacityType = capacityType;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setZoneId(Long zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
}
|
||||
|
||||
public void setZoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
}
|
||||
|
||||
public Long getPodId() {
|
||||
return podId;
|
||||
}
|
||||
|
||||
public void setPodId(Long podId) {
|
||||
this.podId = podId;
|
||||
}
|
||||
|
||||
public String getPodName() {
|
||||
return podName;
|
||||
}
|
||||
|
||||
public void setPodName(String podName) {
|
||||
this.podName = podName;
|
||||
}
|
||||
|
||||
public Long getCapacityUsed() {
|
||||
return capacityUsed;
|
||||
}
|
||||
|
||||
public void setCapacityUsed(Long capacityUsed) {
|
||||
this.capacityUsed = capacityUsed;
|
||||
}
|
||||
|
||||
public Long getCapacityTotal() {
|
||||
return capacityTotal;
|
||||
}
|
||||
|
||||
public void setCapacityTotal(Long capacityTotal) {
|
||||
this.capacityTotal = capacityTotal;
|
||||
}
|
||||
|
||||
public String getPercentUsed() {
|
||||
return percentUsed;
|
||||
}
|
||||
|
||||
public void setPercentUsed(String percentUsed) {
|
||||
this.percentUsed = percentUsed;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package com.cloud.api.response;
|
||||
|
||||
import com.cloud.api.ResponseObject;
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
public class ClusterResponse implements ResponseObject {
|
||||
@Param(name="id")
|
||||
private Long id;
|
||||
|
||||
@Param(name="name")
|
||||
private String name;
|
||||
|
||||
@Param(name="podid")
|
||||
private Long podId;
|
||||
|
||||
@Param(name="podname")
|
||||
private String podName;
|
||||
|
||||
@Param(name="zoneid")
|
||||
private Long zoneId;
|
||||
|
||||
@Param(name="zonename")
|
||||
private String zoneName;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getPodId() {
|
||||
return podId;
|
||||
}
|
||||
|
||||
public void setPodId(Long podId) {
|
||||
this.podId = podId;
|
||||
}
|
||||
|
||||
public String getPodName() {
|
||||
return podName;
|
||||
}
|
||||
|
||||
public void setPodName(String podName) {
|
||||
this.podName = podName;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setZoneId(Long zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
}
|
||||
|
||||
public void setZoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
package com.cloud.api.response;
|
||||
|
||||
import com.cloud.api.ResponseObject;
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
public class ConfigurationResponse implements ResponseObject {
|
||||
@Param(name="category")
|
||||
private String category;
|
||||
|
||||
@Param(name="name")
|
||||
private String name;
|
||||
|
||||
@Param(name="value")
|
||||
private String value;
|
||||
|
||||
@Param(name="description")
|
||||
private String description;
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
|
@ -33,6 +33,10 @@ import com.cloud.api.commands.EnableUserCmd;
|
|||
import com.cloud.api.commands.GetCloudIdentifierCmd;
|
||||
import com.cloud.api.commands.ListAlertsCmd;
|
||||
import com.cloud.api.commands.ListAsyncJobsCmd;
|
||||
import com.cloud.api.commands.ListCapacityCmd;
|
||||
import com.cloud.api.commands.ListCfgsByCmd;
|
||||
import com.cloud.api.commands.ListClustersCmd;
|
||||
import com.cloud.api.commands.ListDiskOfferingsCmd;
|
||||
import com.cloud.api.commands.LockAccountCmd;
|
||||
import com.cloud.api.commands.LockUserCmd;
|
||||
import com.cloud.api.commands.RebootSystemVmCmd;
|
||||
|
|
@ -837,7 +841,7 @@ public interface ManagementServer {
|
|||
* returns the a map of the names/values in the configuraton table
|
||||
* @return map of configuration name/values
|
||||
*/
|
||||
List<ConfigurationVO> searchForConfigurations(Criteria c, boolean showHidden);
|
||||
List<ConfigurationVO> searchForConfigurations(ListCfgsByCmd c);
|
||||
|
||||
/**
|
||||
* returns the instance id of this management server.
|
||||
|
|
@ -866,7 +870,7 @@ public interface ManagementServer {
|
|||
* @param c
|
||||
* @return
|
||||
*/
|
||||
List<ClusterVO> searchForClusters(Criteria c);
|
||||
List<ClusterVO> searchForClusters(ListClustersCmd c);
|
||||
|
||||
/**
|
||||
* Searches for Pods by the specified search criteria
|
||||
|
|
@ -1526,10 +1530,10 @@ public interface ManagementServer {
|
|||
|
||||
/**
|
||||
* list all the capacity rows in capacity operations table
|
||||
* @param c
|
||||
* @param cmd
|
||||
* @return List of capacities
|
||||
*/
|
||||
List<CapacityVO> listCapacities(Criteria c);
|
||||
List<CapacityVO> listCapacities(ListCapacityCmd cmd);
|
||||
|
||||
public long getMemoryUsagebyHost(Long hostId);
|
||||
|
||||
|
|
@ -1636,12 +1640,11 @@ public interface ManagementServer {
|
|||
|
||||
/**
|
||||
* Search for disk offerings based on search criteria
|
||||
* @param c the criteria to use for searching for disk offerings
|
||||
* @param cmd the command containing the criteria to use for searching for disk offerings
|
||||
* @return a list of disk offerings that match the given criteria
|
||||
*/
|
||||
List<DiskOfferingVO> searchForDiskOfferings(Criteria c);
|
||||
|
||||
|
||||
List<DiskOfferingVO> searchForDiskOfferings(ListDiskOfferingsCmd cmd);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param jobId async-call job id
|
||||
|
|
|
|||
|
|
@ -72,6 +72,10 @@ import com.cloud.api.commands.EnableUserCmd;
|
|||
import com.cloud.api.commands.GetCloudIdentifierCmd;
|
||||
import com.cloud.api.commands.ListAlertsCmd;
|
||||
import com.cloud.api.commands.ListAsyncJobsCmd;
|
||||
import com.cloud.api.commands.ListCapacityCmd;
|
||||
import com.cloud.api.commands.ListCfgsByCmd;
|
||||
import com.cloud.api.commands.ListClustersCmd;
|
||||
import com.cloud.api.commands.ListDiskOfferingsCmd;
|
||||
import com.cloud.api.commands.LockAccountCmd;
|
||||
import com.cloud.api.commands.LockUserCmd;
|
||||
import com.cloud.api.commands.PrepareForMaintenanceCmd;
|
||||
|
|
@ -3859,14 +3863,14 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ClusterVO> searchForClusters(Criteria c) {
|
||||
Filter searchFilter = new Filter(ClusterVO.class, c.getOrderBy(), c.getAscending(), c.getOffset(), c.getLimit());
|
||||
public List<ClusterVO> searchForClusters(ListClustersCmd cmd) {
|
||||
Filter searchFilter = new Filter(ClusterVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
SearchCriteria<ClusterVO> sc = _clusterDao.createSearchCriteria();
|
||||
|
||||
Object id = c.getCriteria(Criteria.ID);
|
||||
Object name = c.getCriteria(Criteria.NAME);
|
||||
Object podId = c.getCriteria(Criteria.PODID);
|
||||
Object zoneId = c.getCriteria(Criteria.DATACENTERID);
|
||||
Object id = cmd.getId();
|
||||
Object name = cmd.getName();
|
||||
Object podId = cmd.getPodId();
|
||||
Object zoneId = cmd.getZoneId();
|
||||
|
||||
if (id != null) {
|
||||
sc.addAnd("id", SearchCriteria.Op.EQ, id);
|
||||
|
|
@ -4073,13 +4077,13 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ConfigurationVO> searchForConfigurations(Criteria c, boolean showHidden) {
|
||||
Filter searchFilter = new Filter(ConfigurationVO.class, c.getOrderBy(), c.getAscending(), c.getOffset(), c.getLimit());
|
||||
public List<ConfigurationVO> searchForConfigurations(ListCfgsByCmd cmd) {
|
||||
Filter searchFilter = new Filter(ConfigurationVO.class, "name", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
SearchCriteria<ConfigurationVO> sc = _configDao.createSearchCriteria();
|
||||
|
||||
Object name = c.getCriteria(Criteria.NAME);
|
||||
Object category = c.getCriteria(Criteria.CATEGORY);
|
||||
Object keyword = c.getCriteria(Criteria.KEYWORD);
|
||||
Object name = cmd.getConfigName();
|
||||
Object category = cmd.getCategory();
|
||||
Object keyword = cmd.getKeyword();
|
||||
|
||||
if (keyword != null) {
|
||||
SearchCriteria<ConfigurationVO> ssc = _configDao.createSearchCriteria();
|
||||
|
|
@ -4101,9 +4105,8 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
sc.addAnd("category", SearchCriteria.Op.EQ, category);
|
||||
}
|
||||
|
||||
if (!showHidden) {
|
||||
sc.addAnd("category", SearchCriteria.Op.NEQ, "Hidden");
|
||||
}
|
||||
// hidden configurations are not displayed using the search API
|
||||
sc.addAnd("category", SearchCriteria.Op.NEQ, "Hidden");
|
||||
|
||||
return _configDao.search(sc, searchFilter);
|
||||
}
|
||||
|
|
@ -6302,21 +6305,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
|
||||
@Override
|
||||
public List<AlertVO> searchForAlerts(ListAlertsCmd cmd) {
|
||||
Integer page = cmd.getPage();
|
||||
Integer pageSize = cmd.getPageSize();
|
||||
Long startIndex = Long.valueOf(0);
|
||||
long pageSizeNum = 50;
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
if (page != null) {
|
||||
int pageNum = page.intValue();
|
||||
if (pageNum > 0) {
|
||||
startIndex = pageSizeNum * (pageNum - 1L);
|
||||
}
|
||||
}
|
||||
|
||||
Filter searchFilter = new Filter(AlertVO.class, "lastSent", false, startIndex, pageSizeNum);
|
||||
Filter searchFilter = new Filter(AlertVO.class, "lastSent", false, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
SearchCriteria<AlertVO> sc = _alertDao.createSearchCriteria();
|
||||
|
||||
|
||||
|
|
@ -6338,20 +6327,20 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<CapacityVO> listCapacities(Criteria c) {
|
||||
public List<CapacityVO> listCapacities(ListCapacityCmd cmd) {
|
||||
// make sure capacity is accurate before displaying it anywhere
|
||||
// NOTE: listCapacities is currently called by the UI only, so this
|
||||
// shouldn't be called much since it checks all hosts/VMs
|
||||
// to figure out what has been allocated.
|
||||
_alertMgr.recalculateCapacity();
|
||||
|
||||
Filter searchFilter = new Filter(CapacityVO.class, c.getOrderBy(), c.getAscending(), c.getOffset(), c.getLimit());
|
||||
Filter searchFilter = new Filter(CapacityVO.class, "capacityType", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
SearchCriteria<CapacityVO> sc = _capacityDao.createSearchCriteria();
|
||||
|
||||
Object type = c.getCriteria(Criteria.TYPE);
|
||||
Object zoneId = c.getCriteria(Criteria.DATACENTERID);
|
||||
Object podId = c.getCriteria(Criteria.PODID);
|
||||
Object hostId = c.getCriteria(Criteria.HOSTID);
|
||||
Object type = cmd.getType();
|
||||
Object zoneId = cmd.getZoneId();
|
||||
Object podId = cmd.getPodId();
|
||||
Object hostId = cmd.getHostId();
|
||||
|
||||
if (type != null) {
|
||||
sc.addAnd("capacityType", SearchCriteria.Op.EQ, type);
|
||||
|
|
@ -6715,16 +6704,15 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<DiskOfferingVO> searchForDiskOfferings(Criteria c) {
|
||||
Filter searchFilter = new Filter(DiskOfferingVO.class, c.getOrderBy(), c.getAscending(), c.getOffset(), c.getLimit());
|
||||
public List<DiskOfferingVO> searchForDiskOfferings(ListDiskOfferingsCmd cmd) {
|
||||
Filter searchFilter = new Filter(DiskOfferingVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
SearchBuilder<DiskOfferingVO> sb = _diskOfferingDao.createSearchBuilder();
|
||||
|
||||
// SearchBuilder and SearchCriteria are now flexible so that the search builder can be built with all possible
|
||||
// search terms and only those with criteria can be set. The proper SQL should be generated as a result.
|
||||
Object name = c.getCriteria(Criteria.NAME);
|
||||
//Object domainId = c.getCriteria(Criteria.DOMAINID);
|
||||
Object id = c.getCriteria(Criteria.ID);
|
||||
Object keyword = c.getCriteria(Criteria.KEYWORD);
|
||||
Object name = cmd.getDiskOfferingName();
|
||||
Object id = cmd.getId();
|
||||
Object keyword = cmd.getKeyword();
|
||||
|
||||
sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
|
||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||
|
|
@ -7645,21 +7633,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
|
||||
@Override
|
||||
public List<AsyncJobVO> searchForAsyncJobs(ListAsyncJobsCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
Integer pageSize = cmd.getPageSize();
|
||||
Integer page = cmd.getPage();
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
if (page != null) {
|
||||
int pageNum = page.intValue();
|
||||
if (pageNum > 0) {
|
||||
startIndex = Long.valueOf(pageSizeNum * (pageNum-1));
|
||||
}
|
||||
}
|
||||
|
||||
Filter searchFilter = new Filter(AsyncJobVO.class, "id", true, startIndex, Long.valueOf(pageSizeNum));
|
||||
Filter searchFilter = new Filter(AsyncJobVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
SearchBuilder<AsyncJobVO> sb = _jobDao.createSearchBuilder();
|
||||
|
||||
Object accountId = null;
|
||||
|
|
@ -8025,19 +7999,12 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
User user = findUserById(userId);
|
||||
if ((user == null) || (user.getRemoved() != null))
|
||||
throw new InvalidParameterValueException("Unable to find active user by id " + userId);
|
||||
|
||||
Criteria c = new Criteria ();
|
||||
c.addCriteria(Criteria.NAME, "cloud.identifier");
|
||||
|
||||
List<ConfigurationVO> configs = searchForConfigurations(c, true);
|
||||
|
||||
String cloudIdentifier;
|
||||
if (configs == null || configs.size() != 1) {
|
||||
cloudIdentifier = "";
|
||||
} else {
|
||||
cloudIdentifier = configs.get(0).getValue();
|
||||
String cloudIdentifier = _configDao.getValue("cloud.identifier");
|
||||
if (cloudIdentifier == null) {
|
||||
cloudIdentifier = "";
|
||||
}
|
||||
|
||||
|
||||
String signature = "";
|
||||
try {
|
||||
//get the user obj to get his secret key
|
||||
|
|
|
|||
Loading…
Reference in New Issue