mirror of https://github.com/apache/cloudstack.git
Bug 13059: For listing top consumed resources only uyse enabled zone for sec storage Also improve the transaction logic.
Reviewed-By: Kishan
This commit is contained in:
parent
034b5890e6
commit
cbc47b9021
|
|
@ -53,13 +53,13 @@ public class ListCapacityCmd extends BaseListCmd {
|
|||
private Long podId;
|
||||
|
||||
@IdentityMapper(entityTableName="cluster")
|
||||
@Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.LONG, description="lists capacity by the Cluster ID")
|
||||
@Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.LONG, since="3.0.0", description="lists capacity by the Cluster ID")
|
||||
private Long clusterId;
|
||||
|
||||
@Parameter(name=ApiConstants.FETCH_LATEST, type=CommandType.BOOLEAN, description="recalculate capacities and fetch the latest")
|
||||
@Parameter(name=ApiConstants.FETCH_LATEST, type=CommandType.BOOLEAN, since="3.0.0", description="recalculate capacities and fetch the latest")
|
||||
private Boolean fetchLatest;
|
||||
|
||||
@Parameter(name=ApiConstants.SORT_BY_USAGE, type=CommandType.BOOLEAN, description="if true then lists the top consumed resources at various hierarchy level")
|
||||
@Parameter(name=ApiConstants.SORT_BY_USAGE, type=CommandType.BOOLEAN, since="3.0.0", description="if true then lists the top consumed resources at various hierarchy level and in enabled resource state")
|
||||
private Boolean sortByUsage;
|
||||
|
||||
@Parameter(name=ApiConstants.TYPE, type=CommandType.INTEGER, description="lists capacity by type" +
|
||||
|
|
|
|||
|
|
@ -708,20 +708,15 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||
}
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
txn.start();
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
||||
pstmt.setString(1, capacityState);
|
||||
for (int i = 0; i < resourceIdList.size(); i++){
|
||||
pstmt.setLong( 2+i, resourceIdList.get(i));
|
||||
}
|
||||
pstmt.executeUpdate();
|
||||
txn.commit();
|
||||
} catch (Exception e) {
|
||||
txn.rollback();
|
||||
s_logger.warn("Error updating CapacityVO", e);
|
||||
} finally {
|
||||
txn.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ import com.cloud.network.NetworkVO;
|
|||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.LoadBalancerDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.org.Grouping.AllocationState;
|
||||
import com.cloud.projects.Project;
|
||||
import com.cloud.projects.Project.ListProjectResourcesCriteria;
|
||||
import com.cloud.projects.ProjectManager;
|
||||
|
|
@ -2004,9 +2005,12 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
|
||||
List<SummedCapacity> getSecStorageUsed(Long zoneId, Integer capacityType){
|
||||
if (capacityType == null || capacityType == Capacity.CAPACITY_TYPE_SECONDARY_STORAGE){
|
||||
List<SummedCapacity> list = new ArrayList<SummedCapacity>();
|
||||
|
||||
List<SummedCapacity> list = new ArrayList<SummedCapacity>();
|
||||
if (zoneId != null){
|
||||
DataCenterVO zone = ApiDBUtils.findZoneById(zoneId);
|
||||
if(zone == null || zone.getAllocationState() == AllocationState.Disabled){
|
||||
return null;
|
||||
}
|
||||
CapacityVO capacity = _storageMgr.getSecondaryStorageUsedStats(null, zoneId);
|
||||
if (capacity.getTotalCapacity()!= 0){
|
||||
capacity.setUsedPercentage( capacity.getUsedCapacity() / capacity.getTotalCapacity() );
|
||||
|
|
@ -2016,7 +2020,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
SummedCapacity summedCapacity = new SummedCapacity(capacity.getUsedPercentage(), capacity.getCapacityType(), capacity.getDataCenterId(), capacity.getPodId(), capacity.getClusterId());
|
||||
list.add(summedCapacity) ;
|
||||
}else {
|
||||
List<DataCenterVO> dcList = ApiDBUtils.listZones();
|
||||
List<DataCenterVO> dcList = _dcDao.listEnabledZones();
|
||||
for(DataCenterVO dc : dcList){
|
||||
CapacityVO capacity = _storageMgr.getSecondaryStorageUsedStats(null, dc.getId());
|
||||
if (capacity.getTotalCapacity()!= 0){
|
||||
|
|
|
|||
Loading…
Reference in New Issue