mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
bug 14247: implemented search by storage id in listSystemVms
status 14247: resolved fixed
This commit is contained in:
parent
2b437f6a12
commit
251af27a7a
@ -66,6 +66,10 @@ public class ListSystemVMsCmd extends BaseListCmd {
|
||||
@IdentityMapper(entityTableName="data_center")
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the Zone ID of the system VM")
|
||||
private Long zoneId;
|
||||
|
||||
@IdentityMapper(entityTableName="storage_pool")
|
||||
@Parameter(name=ApiConstants.STORAGE_ID, type=CommandType.LONG, description="the storage ID where vm's volumes belong to")
|
||||
private Long storageId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
@ -98,6 +102,10 @@ public class ListSystemVMsCmd extends BaseListCmd {
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public Long getStorageId() {
|
||||
return storageId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
||||
@ -2577,6 +2577,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
String keyword = cmd.getKeyword();
|
||||
Long podId = cmd.getPodId();
|
||||
Long hostId = cmd.getHostId();
|
||||
Long storageId = cmd.getStorageId();
|
||||
|
||||
Filter searchFilter = new Filter(VMInstanceVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
SearchBuilder<VMInstanceVO> sb = _vmInstanceDao.createSearchBuilder();
|
||||
@ -2589,6 +2590,12 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
sb.and("hostId", sb.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
sb.and("type", sb.entity().getType(), SearchCriteria.Op.EQ);
|
||||
sb.and("nulltype", sb.entity().getType(), SearchCriteria.Op.IN);
|
||||
|
||||
if (storageId != null) {
|
||||
SearchBuilder<VolumeVO> volumeSearch = _volumeDao.createSearchBuilder();
|
||||
volumeSearch.and("poolId", volumeSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
|
||||
sb.join("volumeSearch", volumeSearch, sb.entity().getId(), volumeSearch.entity().getInstanceId(), JoinBuilder.JoinType.INNER);
|
||||
}
|
||||
|
||||
SearchCriteria<VMInstanceVO> sc = sb.create();
|
||||
|
||||
@ -2596,9 +2603,9 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
SearchCriteria<VMInstanceVO> ssc = _vmInstanceDao.createSearchCriteria();
|
||||
ssc.addOr("hostName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("state", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
|
||||
|
||||
sc.addAnd("hostName", SearchCriteria.Op.SC, ssc);
|
||||
}
|
||||
}
|
||||
|
||||
if (id != null) {
|
||||
sc.setParameters("id", id);
|
||||
@ -2625,6 +2632,10 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
} else {
|
||||
sc.setParameters("nulltype", VirtualMachine.Type.SecondaryStorageVm, VirtualMachine.Type.ConsoleProxy);
|
||||
}
|
||||
|
||||
if (storageId != null) {
|
||||
sc.setJoinParameters("volumeSearch", "poolId", storageId);
|
||||
}
|
||||
|
||||
return _vmInstanceDao.search(sc, searchFilter);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user