CLOUDSTACK-4882:

list Clusters/pods/zones API not accounting for reserved in the used capacity percentage.
Fix listCapacity cmd for reserved as well
Signed off by : nitin mehta<nitin.mehta@citrix.com>
This commit is contained in:
Nitin Mehta 2013-10-16 15:01:33 -07:00
parent 81d078fb79
commit fc6c1ec812
3 changed files with 10 additions and 5 deletions

View File

@ -360,7 +360,7 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
if(level == 3 && rs.getLong(7) != 0)
capacityClusterId = rs.getLong(7);
SummedCapacity summedCapacity = new SummedCapacity( rs.getLong(1), rs.getLong(3), rs.getFloat(4),
SummedCapacity summedCapacity = new SummedCapacity( rs.getLong(1), rs.getLong(2), rs.getLong(3), rs.getFloat(4),
(short)rs.getLong(5), rs.getLong(6),
capacityPodId, capacityClusterId);
@ -565,6 +565,11 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
this.dcId = zoneId;
}
public SummedCapacity(long sumUsed, long sumReserved, long sumTotal, float percentUsed, short capacityType, Long zoneId, Long podId, Long clusterId) {
this(sumUsed, sumTotal, percentUsed, capacityType, zoneId, podId, clusterId);
this.sumReserved = sumReserved;
}
public Short getCapacityType() {
return capacityType;
}

View File

@ -809,7 +809,7 @@ public class ApiResponseHelper implements ResponseGenerator {
for (SummedCapacity capacity : capacities) {
CapacityResponse capacityResponse = new CapacityResponse();
capacityResponse.setCapacityType(capacity.getCapacityType());
capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
capacityResponse.setCapacityUsed(capacity.getUsedCapacity() + capacity.getReservedCapacity());
if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED) {
List<SummedCapacity> c = ApiDBUtils.findNonSharedStorageForClusterPodZone(null, pod.getId(), null);
capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity());
@ -846,7 +846,7 @@ public class ApiResponseHelper implements ResponseGenerator {
for (SummedCapacity capacity : capacities) {
CapacityResponse capacityResponse = new CapacityResponse();
capacityResponse.setCapacityType(capacity.getCapacityType());
capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
capacityResponse.setCapacityUsed(capacity.getUsedCapacity() + capacity.getReservedCapacity());
if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED) {
List<SummedCapacity> c = ApiDBUtils.findNonSharedStorageForClusterPodZone(zoneId, null, null);
capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity());
@ -967,7 +967,7 @@ public class ApiResponseHelper implements ResponseGenerator {
for (SummedCapacity capacity : capacities) {
CapacityResponse capacityResponse = new CapacityResponse();
capacityResponse.setCapacityType(capacity.getCapacityType());
capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
capacityResponse.setCapacityUsed(capacity.getUsedCapacity() + capacity.getReservedCapacity());
if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED) {
List<SummedCapacity> c = ApiDBUtils.findNonSharedStorageForClusterPodZone(null, null, cluster.getId());

View File

@ -2370,7 +2370,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
for (SummedCapacity summedCapacity : summedCapacities) {
CapacityVO capacity = new CapacityVO(summedCapacity.getDataCenterId(), summedCapacity.getPodId(), summedCapacity.getClusterId(),
summedCapacity.getCapacityType(), summedCapacity.getPercentUsed());
capacity.setUsedCapacity(summedCapacity.getUsedCapacity());
capacity.setUsedCapacity(summedCapacity.getUsedCapacity() + summedCapacity.getReservedCapacity());
capacity.setTotalCapacity(summedCapacity.getTotalCapacity());
capacities.add(capacity);
}