cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject git commit: updated refs/heads/4.4 to da97f3f
Date Thu, 15 May 2014 09:13:25 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4 f20b2f47d -> da97f3f6e


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/da97f3f6
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/da97f3f6
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/da97f3f6

Branch: refs/heads/4.4
Commit: da97f3f6e509debc66537840eba8a9ed6527056e
Parents: f20b2f4
Author: Sanjay Tripathi <sanjay.tripathi@citrix.com>
Authored: Thu May 15 14:07:10 2014 +0530
Committer: Daan Hoogland <daan@onecht.net>
Committed: Thu May 15 11:13:08 2014 +0200

----------------------------------------------------------------------
 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/da97f3f6/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 4ce9fa6..ce685c6 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -1738,7 +1738,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;
@@ -1771,7 +1771,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