mirror of https://github.com/apache/cloudstack.git
Merge pull request #1819 from Accelerite/ListCapacityIssue
CLOUDSTACK-9653 The system capacity was not getting calculated correctly
This commit is contained in:
commit
1be37e41ed
|
|
@ -23,7 +23,6 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
|
@ -356,11 +355,11 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||
|
||||
switch (level) {
|
||||
case 1: // List all the capacities grouped by zone, capacity Type
|
||||
finalQuery.append(LIST_CAPACITY_GROUP_BY_CLUSTER_TYPE_PART2);
|
||||
finalQuery.append(LIST_CAPACITY_GROUP_BY_ZONE_TYPE_PART2);
|
||||
break;
|
||||
|
||||
case 2: // List all the capacities grouped by pod, capacity Type
|
||||
finalQuery.append(LIST_CAPACITY_GROUP_BY_CLUSTER_TYPE_PART2);
|
||||
finalQuery.append(LIST_CAPACITY_GROUP_BY_POD_TYPE_PART2);
|
||||
break;
|
||||
|
||||
case 3: // List all the capacities grouped by cluster, capacity Type
|
||||
|
|
@ -392,22 +391,7 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||
results.add(summedCapacity);
|
||||
}
|
||||
|
||||
HashMap<Integer, SummedCapacity> capacityMap = new HashMap<Integer, SummedCapacity>();
|
||||
for (SummedCapacity result: results) {
|
||||
if (capacityMap.containsKey(result.getCapacityType().intValue())) {
|
||||
SummedCapacity tempCapacity = capacityMap.get(result.getCapacityType().intValue());
|
||||
tempCapacity.setUsedCapacity(tempCapacity.getUsedCapacity()+result.getUsedCapacity());
|
||||
tempCapacity.setReservedCapacity(tempCapacity.getReservedCapacity()+result.getReservedCapacity());
|
||||
tempCapacity.setSumTotal(tempCapacity.getTotalCapacity()+result.getTotalCapacity());
|
||||
}else {
|
||||
capacityMap.put(result.getCapacityType().intValue(),result);
|
||||
}
|
||||
}
|
||||
List<SummedCapacity> summedCapacityList = new ArrayList<SummedCapacity>();
|
||||
for (Entry<Integer, SummedCapacity> entry : capacityMap.entrySet()) {
|
||||
summedCapacityList.add(entry.getValue());
|
||||
}
|
||||
return summedCapacityList;
|
||||
return results;
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("DB Exception on: " + finalQuery, e);
|
||||
} catch (Throwable e) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue