mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
CLOUDSTACK-6678: API:MS: listCapacity returns; errorcode":530,"cserrorcode":9999,"errortext":"Index: 0, Size: 0"}.
This commit is contained in:
parent
ee29915ef0
commit
f789a03769
@ -1470,7 +1470,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
}
|
||||
|
||||
List<VgpuTypesInfo> gpuCapacities;
|
||||
if ((gpuCapacities = ApiDBUtils.getGpuCapacites(result.get(0).getDataCenterId(), result.get(0).getPodId(), result.get(0).getClusterId())) != null) {
|
||||
if (!result.isEmpty() && (gpuCapacities = ApiDBUtils.getGpuCapacites(result.get(0).getDataCenterId(), result.get(0).getPodId(), result.get(0).getClusterId())) != null) {
|
||||
HashMap<String, Long> vgpuVMs = ApiDBUtils.getVgpuVmsCount(result.get(0).getDataCenterId(), result.get(0).getPodId(), result.get(0).getClusterId());
|
||||
|
||||
float capacityUsed = 0;
|
||||
@ -1503,7 +1503,11 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
capacityResponse.setCapacityType(Capacity.CAPACITY_TYPE_GPU);
|
||||
capacityResponse.setCapacityUsed((long)Math.ceil(capacityUsed));
|
||||
capacityResponse.setCapacityTotal(capacityMax);
|
||||
capacityResponse.setPercentUsed(format.format(capacityUsed / capacityMax * 100f));
|
||||
if (capacityMax > 0) {
|
||||
capacityResponse.setPercentUsed(format.format(capacityUsed / capacityMax * 100f));
|
||||
} else {
|
||||
capacityResponse.setPercentUsed(format.format(0));
|
||||
}
|
||||
capacityResponse.setObjectName("capacity");
|
||||
capacityResponses.add(capacityResponse);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user