Fix listCapacity sort by usage (#11316)

This commit is contained in:
Abhisar Sinha 2025-07-30 17:35:03 +05:30 committed by GitHub
parent 7506a547af
commit 294aef5ecf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);