Skip to content

Commit

Permalink
CLOUDSTACK-4882:
Browse files Browse the repository at this point in the history
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<[email protected]>
  • Loading branch information
nitinmeh committed Oct 16, 2013
1 parent 81d078f commit fc6c1ec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ public List<SummedCapacity> listCapacitiesGroupedByLevelAndType(Integer capacit
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);

Expand Down Expand Up @@ -565,6 +565,11 @@ public SummedCapacity(long sumUsed, long sumTotal, float percentUsed, short capa
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;
}
Expand Down
6 changes: 3 additions & 3 deletions server/src/com/cloud/api/ApiResponseHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ public PodResponse createPodResponse(Pod pod, Boolean showCapacities) {
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());
Expand Down Expand Up @@ -846,7 +846,7 @@ public static List<CapacityResponse> getDataCenterCapacityResponse(Long zoneId)
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());
Expand Down Expand Up @@ -967,7 +967,7 @@ public ClusterResponse createClusterResponse(Cluster cluster, Boolean showCapaci
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());
Expand Down
2 changes: 1 addition & 1 deletion server/src/com/cloud/server/ManagementServerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2370,7 +2370,7 @@ public int compare(SummedCapacity arg0, SummedCapacity arg1) {
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);
}
Expand Down

0 comments on commit fc6c1ec

Please sign in to comment.