From b6c259d72a5d5776634e07cb56b74e8cb4828434 Mon Sep 17 00:00:00 2001 From: Abhinandan Prateek Date: Wed, 22 Feb 2017 12:18:35 +0530 Subject: [PATCH] CLOUDSTACK-5806: add presetup to storage types that support over provisioning Ideally this should be configurable via global settings --- api/src/com/cloud/storage/Storage.java | 4 ++++ .../src/com/cloud/configuration/ConfigurationManagerImpl.java | 3 +-- server/src/com/cloud/storage/StorageManagerImpl.java | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/api/src/com/cloud/storage/Storage.java b/api/src/com/cloud/storage/Storage.java index 25ae5ca4dc9..c94cefe732f 100644 --- a/api/src/com/cloud/storage/Storage.java +++ b/api/src/com/cloud/storage/Storage.java @@ -143,6 +143,10 @@ public class Storage { public boolean isShared() { return shared; } + + public boolean supportsOverProvisioning() { + return this == StoragePoolType.NetworkFilesystem || this == StoragePoolType.VMFS || this == StoragePoolType.PreSetup; + } } public static List getNonSharedStoragePoolTypes() { diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 10136c6bf32..9ea701979c0 100644 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -184,7 +184,6 @@ import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.service.dao.ServiceOfferingDetailsDao; import com.cloud.storage.DiskOfferingVO; import com.cloud.storage.Storage.ProvisioningType; -import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.StorageManager; import com.cloud.storage.dao.DiskOfferingDao; import com.cloud.storage.dao.VolumeDao; @@ -508,7 +507,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati throw new InvalidParameterValueException("unable to find storage pool by id " + resourceId); } if(name.equals(CapacityManager.StorageOverprovisioningFactor.key())) { - if(pool.getPoolType() != StoragePoolType.NetworkFilesystem && pool.getPoolType() != StoragePoolType.VMFS) { + if(!pool.getPoolType().supportsOverProvisioning() ) { throw new InvalidParameterValueException("Unable to update storage pool with id " + resourceId + ". Overprovision not supported for " + pool.getPoolType()); } } diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index b239655546c..93ea579fd9f 100644 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -971,7 +971,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C List capacities = _capacityDao.search(capacitySC, null); long totalOverProvCapacity; - if (storagePool.getPoolType() == StoragePoolType.NetworkFilesystem || storagePool.getPoolType() == StoragePoolType.VMFS) { + if (storagePool.getPoolType().supportsOverProvisioning()) { // All this is for the inaccuracy of floats for big number multiplication. BigDecimal overProvFactor = getStorageOverProvisioningFactor(storagePool.getId()); totalOverProvCapacity = overProvFactor.multiply(new BigDecimal(storagePool.getCapacityBytes())).longValue(); @@ -1824,7 +1824,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C } long totalOverProvCapacity; - if (pool.getPoolType() == StoragePoolType.NetworkFilesystem || pool.getPoolType() == StoragePoolType.VMFS || pool.getPoolType() == StoragePoolType.Filesystem) { + if (pool.getPoolType().supportsOverProvisioning()) { BigDecimal overProvFactor = getStorageOverProvisioningFactor(pool.getId()); totalOverProvCapacity = overProvFactor.multiply(new BigDecimal(pool.getCapacityBytes())).longValue(); s_logger.debug("Found storage pool " + poolVO.getName() + " of type " + pool.getPoolType().toString() + " with overprovisioning factor "