cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtutkow...@apache.org
Subject git commit: updated refs/heads/4.3 to 742bf3c
Date Wed, 13 Nov 2013 21:26:12 GMT
Updated Branches:
  refs/heads/4.3 27821d55b -> 742bf3ccc


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/742bf3cc
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/742bf3cc
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/742bf3cc

Branch: refs/heads/4.3
Commit: 742bf3cccc1bf7e90f8419844e0bd78d69288563
Parents: 27821d5
Author: Mike Tutkowski <mike.tutkowski@solidfire.com>
Authored: Wed Nov 13 14:24:56 2013 -0700
Committer: Mike Tutkowski <mike.tutkowski@solidfire.com>
Committed: Wed Nov 13 14:25:31 2013 -0700

----------------------------------------------------------------------
 .../com/cloud/capacity/CapacityManagerImpl.java | 39 +++++++++++++++++++-
 .../com/cloud/storage/StorageManagerImpl.java   |  6 ++-
 2 files changed, 41 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/742bf3cc/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 52cab12..a4c1bd2 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;
@@ -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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/742bf3cc/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 e81e30e..b4446e7 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -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);
 


Mime
View raw message