filter hosts to query on zone wide storage (#3733)

This commit is contained in:
dahn 2019-12-20 14:12:10 +01:00 committed by GitHub
parent 90ce1d8c39
commit 3ac03c8858
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -40,6 +40,7 @@ import java.util.stream.Stream;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import com.cloud.storage.ScopeType;
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.affinity.AffinityGroupService;
@ -1942,14 +1943,23 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
@Override
public HashMap<String, VolumeStatsEntry> getVolumeStatistics(long clusterId, String poolUuid, StoragePoolType poolType, List<String> volumeLocators, int timeout) {
List<HostVO> neighbors = _resourceMgr.listHostsInClusterByStatus(clusterId, Status.Up);
StoragePool storagePool = _storagePoolDao.findPoolByUUID(poolUuid);
StoragePoolVO storagePool = _storagePoolDao.findPoolByUUID(poolUuid);
for (HostVO neighbor : neighbors) {
if (storagePool.isManaged()) {
// apply filters:
// - managed storage
// - local storage
if (storagePool.isManaged() || storagePool.isLocal()) {
volumeLocators = getVolumesByHost(neighbor, storagePool);
}
// - zone wide storage for specific hypervisortypes
if (ScopeType.ZONE.equals(storagePool.getScope()) && storagePool.getHypervisor() != neighbor.getHypervisorType()) {
// skip this neighbour if their hypervisor type is not the same as that of the store
continue;
}
GetVolumeStatsCommand cmd = new GetVolumeStatsCommand(poolType, poolUuid, volumeLocators);
if (timeout > 0) {