You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ki...@apache.org on 2014/09/05 16:09:01 UTC

[2/2] git commit: updated refs/heads/master to 41fdc41

CLOUDSTACK-7478, CLOUDSTACK-7479: Move pool type filter to seperate method


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/bab81f0d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/bab81f0d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/bab81f0d

Branch: refs/heads/master
Commit: bab81f0d6fd6000acdad465b3a9a6a8f0f0efcc0
Parents: b145a7d
Author: Kishan Kavala <ki...@apache.org>
Authored: Fri Sep 5 17:33:57 2014 +0530
Committer: Kishan Kavala <ki...@apache.org>
Committed: Fri Sep 5 19:38:55 2014 +0530

----------------------------------------------------------------------
 .../allocator/AbstractStoragePoolAllocator.java | 36 +++++++++++++-------
 1 file changed, 23 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bab81f0d/engine/storage/src/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java b/engine/storage/src/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
index d717f72..71360ee 100755
--- a/engine/storage/src/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
@@ -180,27 +180,37 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement
             return false;
         }
 
-        if(HypervisorType.LXC.equals(dskCh.getHypervisorType())){
-            if(Volume.Type.ROOT.equals(dskCh.getType())){
+        if(!checkHypervisorCompatibility(dskCh.getHypervisorType(), dskCh.getType(), pool.getPoolType())){
+            return false;
+        }
+
+        // check capacity
+        Volume volume = _volumeDao.findById(dskCh.getVolumeId());
+        List<Volume> requestVolumes = new ArrayList<Volume>();
+        requestVolumes.add(volume);
+        return storageMgr.storagePoolHasEnoughIops(requestVolumes, pool) && storageMgr.storagePoolHasEnoughSpace(requestVolumes, pool);
+    }
+
+    /*
+    Check StoragePool and Volume type compatibility for the hypervisor
+     */
+    private boolean checkHypervisorCompatibility(HypervisorType hyperType, Volume.Type volType, Storage.StoragePoolType poolType){
+        if(HypervisorType.LXC.equals(hyperType)){
+            if(Volume.Type.ROOT.equals(volType)){
                 //LXC ROOT disks supports NFS and local storage pools only
-                if(!(Storage.StoragePoolType.NetworkFilesystem.equals(pool.getPoolType()) ||
-                        Storage.StoragePoolType.Filesystem.equals(pool.getPoolType())) ){
+                if(!(Storage.StoragePoolType.NetworkFilesystem.equals(poolType) ||
+                        Storage.StoragePoolType.Filesystem.equals(poolType)) ){
                     s_logger.debug("StoragePool does not support LXC ROOT disk, skipping this pool");
                     return false;
                 }
-            } else if (Volume.Type.DATADISK.equals(dskCh.getType())){
-                //LXC DATA disks supports NFS and local storage pools only
-                if(!Storage.StoragePoolType.RBD.equals(pool.getPoolType())){
+            } else if (Volume.Type.DATADISK.equals(volType)){
+                //LXC DATA disks supports RBD storage pool only
+                if(!Storage.StoragePoolType.RBD.equals(poolType)){
                     s_logger.debug("StoragePool does not support LXC DATA disk, skipping this pool");
                     return false;
                 }
             }
         }
-
-        // check capacity
-        Volume volume = _volumeDao.findById(dskCh.getVolumeId());
-        List<Volume> requestVolumes = new ArrayList<Volume>();
-        requestVolumes.add(volume);
-        return storageMgr.storagePoolHasEnoughIops(requestVolumes, pool) && storageMgr.storagePoolHasEnoughSpace(requestVolumes, pool);
+        return true;
     }
 }