You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mt...@apache.org on 2014/01/09 23:07:01 UTC
git commit: updated refs/heads/master to caf87ac
Updated Branches:
refs/heads/master 03118c296 -> caf87ac5d
Merge from 4.3: CLOUDSTACK-4810: Enable hypervisor snapshots for CloudStack-managed storage (for XenServer and VMware)
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/caf87ac5
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/caf87ac5
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/caf87ac5
Branch: refs/heads/master
Commit: caf87ac5d9bd51aff9d1800814866b9f781b4335
Parents: 03118c2
Author: Mike Tutkowski <mi...@solidfire.com>
Authored: Thu Jan 9 15:06:25 2014 -0700
Committer: Mike Tutkowski <mi...@solidfire.com>
Committed: Thu Jan 9 15:06:25 2014 -0700
----------------------------------------------------------------------
.../com/cloud/capacity/CapacityManagerImpl.java | 38 ++++++++++++++++++--
.../com/cloud/storage/StorageManagerImpl.java | 8 +++--
2 files changed, 41 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/caf87ac5/server/src/com/cloud/capacity/CapacityManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/capacity/CapacityManagerImpl.java b/server/src/com/cloud/capacity/CapacityManagerImpl.java
index 024c7f2..957a5d0 100755
--- a/server/src/com/cloud/capacity/CapacityManagerImpl.java
+++ b/server/src/com/cloud/capacity/CapacityManagerImpl.java
@@ -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;
@@ -72,6 +76,7 @@ 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.VolumeVO;
import com.cloud.storage.dao.VMTemplatePoolDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.utils.DateUtil;
@@ -135,6 +140,8 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
ClusterDao _clusterDao;
@Inject
ConfigDepot _configDepot;
+ @Inject
+ DataStoreProviderManager _dataStoreProviderMgr;
@Inject
ClusterDetailsDao _clusterDetailsDao;
@@ -498,14 +505,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
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/caf87ac5/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index c274e2c..52c2e7e 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -1485,11 +1485,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
- if (pool.getCapacityIops() == null) {
+
+ // 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);