Skip to content

Commit 7791ff3

Browse files
committed
Don't show object store and backup capacity if total capacity is 0
1 parent c72a10e commit 7791ff3

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

api/src/main/java/org/apache/cloudstack/api/command/admin/resource/ListCapacityCmd.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ public int compare(CapacityResponse resp1, CapacityResponse resp2) {
134134
int res = resp1.getZoneName().compareTo(resp2.getZoneName());
135135
if (res != 0) {
136136
return res;
137+
} else if (getSortBy() != null) {
138+
return 0;
137139
} else {
138140
return resp1.getCapacityType().compareTo(resp2.getCapacityType());
139141
}

server/src/main/java/com/cloud/api/ApiResponseHelper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,6 +2073,11 @@ public List<CapacityResponse> createCapacityResponse(List<? extends Capacity> re
20732073
List<CapacityResponse> capacityResponses = new ArrayList<CapacityResponse>();
20742074

20752075
for (Capacity summedCapacity : result) {
2076+
if (summedCapacity.getTotalCapacity() == 0 &&
2077+
(summedCapacity.getCapacityType() == Capacity.CAPACITY_TYPE_BACKUP_STORAGE ||
2078+
summedCapacity.getCapacityType() == Capacity.CAPACITY_TYPE_OBJECT_STORAGE)) {
2079+
continue;
2080+
}
20762081
CapacityResponse capacityResponse = new CapacityResponse();
20772082
capacityResponse.setCapacityTotal(summedCapacity.getTotalCapacity());
20782083
if (summedCapacity.getAllocatedCapacity() != null) {

server/src/main/java/com/cloud/storage/StorageManagerImpl.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4248,7 +4248,7 @@ public ObjectStore discoverObjectStore(String name, String url, Long size, Strin
42484248
params.put("url", url);
42494249
params.put("name", name);
42504250
if (size == null) {
4251-
params.put("size", 0);
4251+
params.put("size", 0L);
42524252
} else {
42534253
params.put("size", size);
42544254
}
@@ -4347,11 +4347,12 @@ public CapacityVO getObjectStorageUsedStats(Long zoneId) {
43474347
Long allocated = 0L;
43484348
Long total = 0L;
43494349
for (ObjectStoreVO objectStore: objectStores) {
4350-
if (objectStore.getAllocatedSize() == null || objectStore.getTotalSize() == null) {
4351-
continue;
4350+
if (objectStore.getAllocatedSize() != null) {
4351+
allocated += objectStore.getAllocatedSize();
4352+
}
4353+
if (objectStore.getTotalSize() != null) {
4354+
total += objectStore.getTotalSize();
43524355
}
4353-
allocated += objectStore.getAllocatedSize();
4354-
total += objectStore.getTotalSize();
43554356
}
43564357
CapacityVO capacity = new CapacityVO(null, zoneId, null, null, allocated, total, Capacity.CAPACITY_TYPE_OBJECT_STORAGE);
43574358
return capacity;

0 commit comments

Comments
 (0)