mirror of https://github.com/apache/cloudstack.git
Add ResourceState as a searching condition of ListHostCmd
This commit is contained in:
parent
e9b1c5f9c3
commit
83b7b6a412
|
|
@ -309,6 +309,7 @@ public class ApiConstants {
|
|||
public static final String SERVICE = "service";
|
||||
public static final String ASSOCIATED_NETWORK_ID = "associatednetworkid";
|
||||
public static final String SOURCE_NAT_SUPPORTED = "sourcenatsupported";
|
||||
public static final String RESOURCE_STATE = "resourcestate";
|
||||
|
||||
public enum HostDetails {
|
||||
all, capacity, events, stats, min;
|
||||
|
|
|
|||
|
|
@ -77,8 +77,8 @@ public class ListHostsCmd extends BaseListCmd {
|
|||
@Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.LONG, required=false, description="lists hosts in the same cluster as this VM and flag hosts with enough CPU/RAm to host this VM")
|
||||
private Long virtualMachineId;
|
||||
|
||||
@Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="list hosts by allocation state")
|
||||
private String allocationState;
|
||||
@Parameter(name=ApiConstants.RESOURCE_STATE, type=CommandType.STRING, description="list hosts by resource state. Resource state represents current state determined by admin of host, valule can be one of [Enabled, Disabled, Unmanaged, PrepareForMaintenance, ErrorInMaintenance, Maintenance, Error]")
|
||||
private String resourceState;
|
||||
|
||||
@Parameter(name=ApiConstants.DETAILS, type=CommandType.LIST, collectionType=CommandType.STRING, description="comma separated list of host details requested, value can be a list of [ min, all, capacity, events, stats]" )
|
||||
private List<String> viewDetails;
|
||||
|
|
@ -139,8 +139,8 @@ public class ListHostsCmd extends BaseListCmd {
|
|||
return dv;
|
||||
}
|
||||
|
||||
public String getAllocationState() {
|
||||
return allocationState;
|
||||
public String getResourceState() {
|
||||
return resourceState;
|
||||
}
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
|
|
|||
|
|
@ -854,9 +854,9 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
Object cluster = cmd.getClusterId();
|
||||
Object id = cmd.getId();
|
||||
Object keyword = cmd.getKeyword();
|
||||
Object allocationState = cmd.getAllocationState();
|
||||
Object resourceState = cmd.getResourceState();
|
||||
|
||||
return searchForServers(cmd.getStartIndex(), cmd.getPageSizeVal(), name, type, state, zoneId, pod, cluster, id, keyword, allocationState);
|
||||
return searchForServers(cmd.getStartIndex(), cmd.getPageSizeVal(), name, type, state, zoneId, pod, cluster, id, keyword, resourceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -950,7 +950,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
}
|
||||
|
||||
private List<HostVO> searchForServers(Long startIndex, Long pageSize, Object name, Object type, Object state, Object zone, Object pod, Object cluster, Object id, Object keyword,
|
||||
Object allocationState) {
|
||||
Object resourceState) {
|
||||
Filter searchFilter = new Filter(HostVO.class, "id", Boolean.TRUE, startIndex, pageSize);
|
||||
SearchCriteria<HostVO> sc = _hostDao.createSearchCriteria();
|
||||
|
||||
|
|
@ -986,8 +986,8 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
sc.addAnd("clusterId", SearchCriteria.Op.EQ, cluster);
|
||||
}
|
||||
|
||||
if (allocationState != null) {
|
||||
sc.addAnd("hostAllocationState", SearchCriteria.Op.EQ, allocationState);
|
||||
if (resourceState != null) {
|
||||
sc.addAnd("resourceState", SearchCriteria.Op.EQ, resourceState);
|
||||
}
|
||||
|
||||
return _hostDao.search(sc, searchFilter);
|
||||
|
|
|
|||
Loading…
Reference in New Issue