Skip to content

Commit 1fc0afe

Browse files
committed
Bug 13059: Remove the listTipConsumedResources api and introduced a sortbyusage flag in the listCapacity call.
Reviewed-By: Kishan
1 parent d0e63bc commit 1fc0afe

5 files changed

Lines changed: 13 additions & 129 deletions

File tree

‎api/src/com/cloud/api/ApiConstants.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ public class ApiConstants {
172172
public static final String SNAPSHOT_POLICY_ID = "snapshotpolicyid";
173173
public static final String SNAPSHOT_TYPE = "snapshottype";
174174
public static final String SOURCE_ZONE_ID = "sourcezoneid";
175+
public static final String SORT_BY_USAGE = "sortbyusage";
175176
public static final String START_DATE = "startdate";
176177
public static final String START_IP = "startip";
177178
public static final String START_PORT = "startport";

‎api/src/com/cloud/api/commands/ListCapacityCmd.java‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import com.cloud.api.IdentityMapper;
2929
import com.cloud.api.Implementation;
3030
import com.cloud.api.Parameter;
31-
import com.cloud.api.BaseCmd.CommandType;
3231
import com.cloud.api.response.CapacityResponse;
3332
import com.cloud.api.response.ListResponse;
3433
import com.cloud.capacity.Capacity;
@@ -60,8 +59,8 @@ public class ListCapacityCmd extends BaseListCmd {
6059
@Parameter(name=ApiConstants.FETCH_LATEST, type=CommandType.BOOLEAN, description="recalculate capacities and fetch the latest")
6160
private Boolean fetchLatest;
6261

63-
@Parameter(name=ApiConstants.RESOURCE_STATE, type=CommandType.BOOLEAN, description="list capacities by resource state. Resource state represents current state determined by admin of the resource, value can be one of [Enabled, Disabled, Maintenance]")
64-
private Boolean resourceState;
62+
@Parameter(name=ApiConstants.SORT_BY_USAGE, type=CommandType.BOOLEAN, description="if true then lists the top consumed resources at various hierarchy level")
63+
private Boolean sortByUsage;
6564

6665
@Parameter(name=ApiConstants.TYPE, type=CommandType.INTEGER, description="lists capacity by type" +
6766
"* CAPACITY_TYPE_MEMORY = 0" +
@@ -101,6 +100,9 @@ public Integer getType() {
101100
return type;
102101
}
103102

103+
public Boolean getSortByUsage() {
104+
return sortByUsage;
105+
}
104106

105107
/////////////////////////////////////////////////////
106108
/////////////// API Implementation///////////////////

‎api/src/com/cloud/api/commands/ListTopConsumedResources.java‎

Lines changed: 0 additions & 122 deletions
This file was deleted.

‎api/src/com/cloud/server/ManagementService.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
import com.cloud.api.commands.ListStoragePoolsCmd;
5151
import com.cloud.api.commands.ListSystemVMsCmd;
5252
import com.cloud.api.commands.ListTemplatesCmd;
53-
import com.cloud.api.commands.ListTopConsumedResources;
5453
import com.cloud.api.commands.ListVMGroupsCmd;
5554
import com.cloud.api.commands.ListVlanIpRangesCmd;
5655
import com.cloud.api.commands.ListZonesByCmd;
@@ -441,6 +440,6 @@ public interface ManagementService {
441440
* @param cmd
442441
* @return List of capacities
443442
*/
444-
List<? extends Capacity> listTopConsumedResources(ListTopConsumedResources cmd);
443+
List<? extends Capacity> listTopConsumedResources(ListCapacityCmd cmd);
445444

446445
}

‎server/src/com/cloud/server/ManagementServerImpl.java‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
import com.cloud.api.commands.ListStoragePoolsCmd;
8585
import com.cloud.api.commands.ListSystemVMsCmd;
8686
import com.cloud.api.commands.ListTemplatesCmd;
87-
import com.cloud.api.commands.ListTopConsumedResources;
8887
import com.cloud.api.commands.ListVMGroupsCmd;
8988
import com.cloud.api.commands.ListVlanIpRangesCmd;
9089
import com.cloud.api.commands.ListZonesByCmd;
@@ -1939,7 +1938,7 @@ public List<? extends Alert> searchForAlerts(ListAlertsCmd cmd) {
19391938
}
19401939

19411940
@Override
1942-
public List<CapacityVO> listTopConsumedResources(ListTopConsumedResources cmd) {
1941+
public List<CapacityVO> listTopConsumedResources(ListCapacityCmd cmd) {
19431942

19441943
Integer capacityType = cmd.getType();
19451944
Long zoneId = cmd.getZoneId();
@@ -2042,11 +2041,16 @@ public List<CapacityVO> listCapacities(ListCapacityCmd cmd) {
20422041
Long podId = cmd.getPodId();
20432042
Long clusterId = cmd.getClusterId();
20442043
Boolean fetchLatest = cmd.getFetchLatest();
2044+
Boolean sortByUsage = cmd.getSortByUsage();
20452045

20462046
zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), zoneId);
20472047
if (fetchLatest != null && fetchLatest){
20482048
_alertMgr.recalculateCapacity();
20492049
}
2050+
2051+
if (sortByUsage != null && sortByUsage){
2052+
return listTopConsumedResources(cmd);
2053+
}
20502054
List<SummedCapacity> summedCapacities = _capacityDao.findCapacityBy(capacityType, zoneId, podId, clusterId);
20512055
List<CapacityVO> capacities = new ArrayList<CapacityVO>();
20522056

0 commit comments

Comments
 (0)