CLOUDSTACK-1405: add scope type in liststoragepoolcmd

This commit is contained in:
Edison Su 2013-06-19 14:08:12 -07:00
parent fde6637f90
commit 11b9d5ff64
2 changed files with 20 additions and 0 deletions

View File

@ -64,6 +64,10 @@ public class ListStoragePoolsCmd extends BaseListCmd {
description="the ID of the storage pool")
private Long id;
@Parameter(name=ApiConstants.SCOPE, type=CommandType.STRING, entityType = StoragePoolResponse.class,
description="the ID of the storage pool")
private String scope;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -115,4 +119,8 @@ public class ListStoragePoolsCmd extends BaseListCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
public String getScope() {
return scope;
}
}

View File

@ -55,6 +55,7 @@ import org.apache.cloudstack.api.command.user.volume.ListResourceDetailsCmd;
import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd;
import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd;
import org.apache.cloudstack.api.response.*;
import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
import org.apache.cloudstack.query.QueryService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@ -1862,6 +1863,14 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
}
private Pair<List<StoragePoolJoinVO>, Integer> searchForStoragePoolsInternal(ListStoragePoolsCmd cmd) {
ScopeType scopeType = null;
if (cmd.getScope() != null) {
try {
scopeType = Enum.valueOf(ScopeType.class, cmd.getScope().toUpperCase());
} catch (Exception e) {
throw new InvalidParameterValueException("Invalid scope type: " + cmd.getScope());
}
}
Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), cmd.getZoneId());
Object id = cmd.getId();
@ -1922,6 +1931,9 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
if (cluster != null) {
sc.setParameters("clusterId", cluster);
}
if (scopeType != null) {
sc.setParameters("scope", scopeType.toString());
}
// search Pool details by ids
Pair<List<StoragePoolJoinVO>, Integer> uniquePoolPair = _poolJoinDao.searchAndCount(sc, searchFilter);