This is an automated email from the ASF dual-hosted git repository.
dahn pushed a commit to branch 4.19
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.19 by this push:
new 294aef5ecff Fix listCapacity sort by usage (#11316)
294aef5ecff is described below
commit 294aef5ecff1356976eff819cc3028f3439faa24
Author: Abhisar Sinha <[email protected]>
AuthorDate: Wed Jul 30 17:35:03 2025 +0530
Fix listCapacity sort by usage (#11316)
---
.../cloudstack/api/command/admin/resource/ListCapacityCmd.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git
a/api/src/main/java/org/apache/cloudstack/api/command/admin/resource/ListCapacityCmd.java
b/api/src/main/java/org/apache/cloudstack/api/command/admin/resource/ListCapacityCmd.java
index 253677616f0..fdc1087377f 100644
---
a/api/src/main/java/org/apache/cloudstack/api/command/admin/resource/ListCapacityCmd.java
+++
b/api/src/main/java/org/apache/cloudstack/api/command/admin/resource/ListCapacityCmd.java
@@ -127,14 +127,16 @@ public class ListCapacityCmd extends BaseListCmd {
Collections.sort(capacityResponses, new Comparator<CapacityResponse>()
{
public int compare(CapacityResponse resp1, CapacityResponse resp2)
{
int res = resp1.getZoneName().compareTo(resp2.getZoneName());
+ // Group by zone
if (res != 0) {
return res;
- } else {
- return
resp1.getCapacityType().compareTo(resp2.getCapacityType());
}
+ // Sort by capacity type only if not already sorted by usage
+ return (getSortBy() != null) ? 0 :
resp1.getCapacityType().compareTo(resp2.getCapacityType());
}
});
+
response.setResponses(capacityResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);