cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sanjaytripa...@apache.org
Subject git commit: updated refs/heads/master to f789a03
Date Thu, 15 May 2014 08:50:16 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master ee29915ef -> f789a0376


CLOUDSTACK-6678: API:MS: listCapacity returns; errorcode":530,"cserrorcode":9999,"errortext":"Index:
0, Size: 0"}.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f789a037
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f789a037
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f789a037

Branch: refs/heads/master
Commit: f789a0376955d6a95f2976b43e99f980a7ec34b8
Parents: ee29915
Author: Sanjay Tripathi <sanjay.tripathi@citrix.com>
Authored: Thu May 15 14:07:10 2014 +0530
Committer: Sanjay Tripathi <sanjay.tripathi@citrix.com>
Committed: Thu May 15 14:22:40 2014 +0530

----------------------------------------------------------------------
 server/src/com/cloud/api/ApiResponseHelper.java | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f789a037/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 1965a95..3ec5abc 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -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);
         }


Mime
View raw message