mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Handle listsystemvms cmd in case of datastore clusters
This commit is contained in:
parent
61dd85876b
commit
1244fca367
@ -982,7 +982,6 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
|||||||
if (storageId != null) {
|
if (storageId != null) {
|
||||||
StoragePoolVO poolVO = _storagePoolDao.findById((Long) storageId);
|
StoragePoolVO poolVO = _storagePoolDao.findById((Long) storageId);
|
||||||
if (poolVO.getPoolType() == Storage.StoragePoolType.DatastoreCluster) {
|
if (poolVO.getPoolType() == Storage.StoragePoolType.DatastoreCluster) {
|
||||||
List<StoragePoolVO> childDatastores = _storagePoolDao.listChildStoragePoolsInDatastoreCluster((Long) storageId);
|
|
||||||
sb.and("poolId", sb.entity().getPoolId(), SearchCriteria.Op.IN);
|
sb.and("poolId", sb.entity().getPoolId(), SearchCriteria.Op.IN);
|
||||||
} else {
|
} else {
|
||||||
sb.and("poolId", sb.entity().getPoolId(), SearchCriteria.Op.EQ);
|
sb.and("poolId", sb.entity().getPoolId(), SearchCriteria.Op.EQ);
|
||||||
|
|||||||
@ -40,6 +40,7 @@ import javax.crypto.spec.SecretKeySpec;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
|
import com.cloud.storage.Storage;
|
||||||
import org.apache.cloudstack.acl.ControlledEntity;
|
import org.apache.cloudstack.acl.ControlledEntity;
|
||||||
import org.apache.cloudstack.affinity.AffinityGroupProcessor;
|
import org.apache.cloudstack.affinity.AffinityGroupProcessor;
|
||||||
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
|
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
|
||||||
@ -838,6 +839,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||||||
private KeystoreManager _ksMgr;
|
private KeystoreManager _ksMgr;
|
||||||
@Inject
|
@Inject
|
||||||
private DpdkHelper dpdkHelper;
|
private DpdkHelper dpdkHelper;
|
||||||
|
@Inject
|
||||||
|
private PrimaryDataStoreDao _primaryDataStoreDao;
|
||||||
|
|
||||||
private LockMasterListener _lockMasterListener;
|
private LockMasterListener _lockMasterListener;
|
||||||
private final ScheduledExecutorService _eventExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("EventChecker"));
|
private final ScheduledExecutorService _eventExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("EventChecker"));
|
||||||
@ -3323,10 +3326,17 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||||||
sb.and("nulltype", sb.entity().getType(), SearchCriteria.Op.IN);
|
sb.and("nulltype", sb.entity().getType(), SearchCriteria.Op.IN);
|
||||||
|
|
||||||
if (storageId != null) {
|
if (storageId != null) {
|
||||||
|
StoragePoolVO storagePool = _primaryDataStoreDao.findById(storageId);
|
||||||
|
if (storagePool.getPoolType() == Storage.StoragePoolType.DatastoreCluster) {
|
||||||
|
final SearchBuilder<VolumeVO> volumeSearch = _volumeDao.createSearchBuilder();
|
||||||
|
volumeSearch.and("poolId", volumeSearch.entity().getPoolId(), SearchCriteria.Op.IN);
|
||||||
|
sb.join("volumeSearch", volumeSearch, sb.entity().getId(), volumeSearch.entity().getInstanceId(), JoinBuilder.JoinType.INNER);
|
||||||
|
} else {
|
||||||
final SearchBuilder<VolumeVO> volumeSearch = _volumeDao.createSearchBuilder();
|
final SearchBuilder<VolumeVO> volumeSearch = _volumeDao.createSearchBuilder();
|
||||||
volumeSearch.and("poolId", volumeSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
|
volumeSearch.and("poolId", volumeSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
|
||||||
sb.join("volumeSearch", volumeSearch, sb.entity().getId(), volumeSearch.entity().getInstanceId(), JoinBuilder.JoinType.INNER);
|
sb.join("volumeSearch", volumeSearch, sb.entity().getId(), volumeSearch.entity().getInstanceId(), JoinBuilder.JoinType.INNER);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final SearchCriteria<VMInstanceVO> sc = sb.create();
|
final SearchCriteria<VMInstanceVO> sc = sb.create();
|
||||||
|
|
||||||
@ -3365,8 +3375,15 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (storageId != null) {
|
if (storageId != null) {
|
||||||
|
StoragePoolVO storagePool = _primaryDataStoreDao.findById(storageId);
|
||||||
|
if (storagePool.getPoolType() == Storage.StoragePoolType.DatastoreCluster) {
|
||||||
|
List<StoragePoolVO> childDataStores = _primaryDataStoreDao.listChildStoragePoolsInDatastoreCluster(storageId);
|
||||||
|
List<Long> childDatastoreIds = childDataStores.stream().map(mo -> mo.getId()).collect(Collectors.toList());
|
||||||
|
sc.setJoinParameters("volumeSearch", "poolId", childDatastoreIds.toArray());
|
||||||
|
} else {
|
||||||
sc.setJoinParameters("volumeSearch", "poolId", storageId);
|
sc.setJoinParameters("volumeSearch", "poolId", storageId);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final Pair<List<VMInstanceVO>, Integer> result = _vmInstanceDao.searchAndCount(sc, searchFilter);
|
final Pair<List<VMInstanceVO>, Integer> result = _vmInstanceDao.searchAndCount(sc, searchFilter);
|
||||||
return new Pair<List<? extends VirtualMachine>, Integer>(result.first(), result.second());
|
return new Pair<List<? extends VirtualMachine>, Integer>(result.first(), result.second());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user