CLOUDSTACK-4810: Enable hypervisor snapshots for CloudStack-managed storage (for XenServer and VMware)

This commit is contained in:
Mike Tutkowski 2013-11-13 14:24:56 -07:00
parent 27821d55bd
commit 742bf3cccc
2 changed files with 41 additions and 4 deletions

View File

@ -29,6 +29,10 @@ import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
import org.apache.cloudstack.framework.config.ConfigDepot;
import org.apache.cloudstack.framework.config.ConfigKey;
import org.apache.cloudstack.framework.config.Configurable;
@ -70,6 +74,8 @@ import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.storage.StorageManager;
import com.cloud.storage.VMTemplateStoragePoolVO;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.Volume;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.VMTemplatePoolDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.utils.DateUtil;
@ -132,6 +138,8 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
ClusterDao _clusterDao;
@Inject
ConfigDepot _configDepot;
@Inject
DataStoreProviderManager _dataStoreProviderMgr;
@Inject
ClusterDetailsDao _clusterDetailsDao;
@ -474,14 +482,41 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
}
private long getUsedBytes(StoragePoolVO pool) {
long usedBytes = 0;
List<VolumeVO> volumes = _volumeDao.findByPoolId(pool.getId(), null);
if (volumes != null && volumes.size() > 0) {
DataStoreProvider storeProvider = _dataStoreProviderMgr.getDataStoreProvider(pool.getStorageProviderName());
DataStoreDriver storeDriver = storeProvider.getDataStoreDriver();
PrimaryDataStoreDriver primaryStoreDriver = null;
if (storeDriver instanceof PrimaryDataStoreDriver) {
primaryStoreDriver = (PrimaryDataStoreDriver)storeDriver;
}
for (VolumeVO volume : volumes) {
if (primaryStoreDriver != null) {
usedBytes += primaryStoreDriver.getVolumeSizeIncludingHypervisorSnapshotReserve(volume, pool);
}
else {
usedBytes += volume.getSize();
}
}
}
return usedBytes;
}
@Override
public long getAllocatedPoolCapacity(StoragePoolVO pool, VMTemplateVO templateForVmCreation) {
long totalAllocatedSize = 0;
// if the storage pool is managed, the used bytes can be larger than the sum of the sizes of all of the non-destroyed volumes
// in this case, just get the used bytes from the storage pool object
// in this case, call getUsedBytes(StoragePoolVO)
if (pool.isManaged()) {
totalAllocatedSize = pool.getUsedBytes();
totalAllocatedSize = getUsedBytes(pool);
}
else {
// Get size for all the non-destroyed volumes

View File

@ -1523,11 +1523,13 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
if (requestedVolumes == null || requestedVolumes.isEmpty() || pool == null) {
return false;
}
// Only Solidfire type primary storage is using/setting Iops.
// This check will fix to return the storage has enough Iops when capacityIops is set to NULL for any PS Storage provider
// Only SolidFire-type primary storage is using/setting IOPS.
// This check returns true for storage that does not specify IOPS.
if (pool.getCapacityIops() == null ) {
return true;
}
long currentIops = 0;
List<VolumeVO> volumesInPool = _volumeDao.findByPoolId(pool.getId(), null);