mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-04 00:02:37 +01:00
If the HypervisorType of a storage pool is Any, we need to retrieve hosts in the given zone for each HypervisorType.
This commit is contained in:
parent
326a175c08
commit
31f67c2b3c
@ -105,6 +105,8 @@ public interface ResourceManager extends ResourceService {
|
||||
|
||||
public List<HostVO> listAllUpAndEnabledHostsInOneZoneByHypervisor(HypervisorType type, long dcId);
|
||||
|
||||
public List<HostVO> listAllUpAndEnabledHostsInOneZone(long dcId);
|
||||
|
||||
public List<HostVO> listAllHostsInOneZoneByType(Host.Type type, long dcId);
|
||||
|
||||
public List<HostVO> listAllHostsInAllZonesByType(Type type);
|
||||
|
||||
@ -2531,6 +2531,17 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
||||
return sc.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listAllUpAndEnabledHostsInOneZone(long dcId) {
|
||||
QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
|
||||
|
||||
sc.and(sc.entity().getDataCenterId(), Op.EQ, dcId);
|
||||
sc.and(sc.entity().getStatus(), Op.EQ, Status.Up);
|
||||
sc.and(sc.entity().getResourceState(), Op.EQ, ResourceState.Enabled);
|
||||
|
||||
return sc.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHostGpuEnabled(long hostId) {
|
||||
SearchCriteria<HostGpuGroupsVO> sc = _gpuAvailability.create();
|
||||
|
||||
@ -38,6 +38,7 @@ import com.cloud.agent.api.ModifyStoragePoolCommand;
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||
@ -128,7 +129,12 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
|
||||
// if the storage scope is ZONE wide, then get all the hosts for which hypervisor ZWSP created to send Modifystoragepoolcommand
|
||||
//TODO: if it's zone wide, this code will list a lot of hosts in the zone, which may cause performance/OOM issue.
|
||||
if (pool.getScope().equals(ScopeType.ZONE)) {
|
||||
hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(pool.getHypervisor(), pool.getDataCenterId());
|
||||
if (HypervisorType.Any.equals(pool.getHypervisor())) {
|
||||
hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZone(pool.getDataCenterId());
|
||||
}
|
||||
else {
|
||||
hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(pool.getHypervisor(), pool.getDataCenterId());
|
||||
}
|
||||
} else {
|
||||
hosts = _resourceMgr.listHostsInClusterByStatus(pool.getClusterId(), Status.Up);
|
||||
}
|
||||
@ -290,7 +296,12 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
|
||||
List<HostVO> hosts = new ArrayList<HostVO>();
|
||||
// if the storage scope is ZONE wide, then get all the hosts for which hypervisor ZWSP created to send Modifystoragepoolcommand
|
||||
if (poolVO.getScope().equals(ScopeType.ZONE)) {
|
||||
hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(poolVO.getHypervisor(), pool.getDataCenterId());
|
||||
if (HypervisorType.Any.equals(pool.getHypervisor())) {
|
||||
hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZone(pool.getDataCenterId());
|
||||
}
|
||||
else {
|
||||
hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(poolVO.getHypervisor(), pool.getDataCenterId());
|
||||
}
|
||||
} else {
|
||||
hosts = _resourceMgr.listHostsInClusterByStatus(pool.getClusterId(), Status.Up);
|
||||
}
|
||||
|
||||
@ -552,6 +552,12 @@ public class MockResourceManagerImpl extends ManagerBase implements ResourceMana
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listAllUpAndEnabledHostsInOneZone(long dcId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean releaseHostReservation(Long hostId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user