Updated Branches:
  refs/heads/master-6-17-stable 67cab313c -> 2c1a3b5f5


CLOUDSTACK-3264: [ZWPS]NPE while finding storage pools for migration

Description:

    Filter primary storage pools based on zonewide/clusterwide configuration
    when considering pools to list for storage migration of volumes.

Signed-off-by: Sateesh Chodapuneedi <[email protected]>


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

Branch: refs/heads/master-6-17-stable
Commit: 2c1a3b5f578fae7b2cd0dba7cc96cb3656a0223b
Parents: 67cab31
Author: Vijayendra Bhamidipati <[email protected]>
Authored: Mon Jul 8 13:15:23 2013 -0700
Committer: Sateesh Chodapuneedi <[email protected]>
Committed: Tue Jul 9 10:05:49 2013 +0530

----------------------------------------------------------------------
 .../storage/allocator/AbstractStoragePoolAllocator.java   |  5 ++++-
 .../allocator/ClusterScopeStoragePoolAllocator.java       |  4 ++++
 .../storage/allocator/LocalStoragePoolAllocator.java      |  3 +++
 .../storage/allocator/RandomStoragePoolAllocator.java     |  4 ++++
 server/src/com/cloud/server/ManagementServerImpl.java     | 10 ++++++++--
 5 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2c1a3b5f/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 5326701..daa8f96 100755
--- 
a/engine/storage/src/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
+++ 
b/engine/storage/src/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
@@ -97,7 +97,7 @@ public abstract class AbstractStoragePoolAllocator extends 
AdapterBase implement
        public
     List<StoragePool> allocateToPool(DiskProfile dskCh, 
VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, 
ExcludeList avoid, int returnUpTo) {
        List<StoragePool> pools = select(dskCh, vmProfile, plan, avoid, 
returnUpTo);
-       return reOrder(pools, vmProfile, plan);
+        return reOrder(pools, vmProfile, plan);
     }
     
     protected List<StoragePool> reorderPoolsByNumberOfVolumes(DeploymentPlan 
plan, List<StoragePool> pools, Account account) {
@@ -133,6 +133,9 @@ public abstract class AbstractStoragePoolAllocator extends 
AdapterBase implement
     protected List<StoragePool> reOrder(List<StoragePool> pools, 
                VirtualMachineProfile<? extends VirtualMachine> vmProfile,
                DeploymentPlan plan) {
+        if (pools == null) {
+            return null;
+        }
        Account account = null;
        if(vmProfile.getVirtualMachine() != null){
                account = vmProfile.getOwner();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2c1a3b5f/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java
----------------------------------------------------------------------
diff --git 
a/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java
 
b/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java
index 5b1f8cd..2ee8d81 100644
--- 
a/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java
+++ 
b/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java
@@ -58,6 +58,10 @@ public class ClusterScopeStoragePoolAllocator extends 
AbstractStoragePoolAllocat
                Long podId = plan.getPodId();
                Long clusterId = plan.getClusterId();
 
+               if (clusterId == null) {
+                       return null;
+               }
+
         if(dskCh.getTags() != null && dskCh.getTags().length != 0){
                s_logger.debug("Looking for pools in dc: " + dcId + "  pod:" + 
podId + "  cluster:" + clusterId + " having tags:" + 
Arrays.toString(dskCh.getTags()));
         }else{

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2c1a3b5f/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java
----------------------------------------------------------------------
diff --git 
a/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java
 
b/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java
index 632ba43..667c36e 100644
--- 
a/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java
+++ 
b/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java
@@ -95,6 +95,9 @@ public class LocalStoragePoolAllocator extends 
AbstractStoragePoolAllocator {
                 }
             }
         } else {
+            if (plan.getClusterId() == null) {
+                return null;
+            }
                List<StoragePoolVO> availablePools = 
_storagePoolDao.findLocalStoragePoolsByTags(plan.getDataCenterId(), 
plan.getPodId(), plan.getClusterId(), dskCh.getTags());
                for (StoragePoolVO pool : availablePools) {
                        if (suitablePools.size() == returnUpTo) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2c1a3b5f/plugins/storage-allocators/random/src/org/apache/cloudstack/storage/allocator/RandomStoragePoolAllocator.java
----------------------------------------------------------------------
diff --git 
a/plugins/storage-allocators/random/src/org/apache/cloudstack/storage/allocator/RandomStoragePoolAllocator.java
 
b/plugins/storage-allocators/random/src/org/apache/cloudstack/storage/allocator/RandomStoragePoolAllocator.java
index cbe6647..4ab400b 100644
--- 
a/plugins/storage-allocators/random/src/org/apache/cloudstack/storage/allocator/RandomStoragePoolAllocator.java
+++ 
b/plugins/storage-allocators/random/src/org/apache/cloudstack/storage/allocator/RandomStoragePoolAllocator.java
@@ -45,6 +45,10 @@ public class RandomStoragePoolAllocator extends 
AbstractStoragePoolAllocator {
                long dcId = plan.getDataCenterId();
                Long podId = plan.getPodId();
                Long clusterId = plan.getClusterId();
+               if (clusterId == null) {
+                       return null;
+               }
+
         s_logger.debug("Looking for pools in dc: " + dcId + "  pod:" + podId + 
"  cluster:" + clusterId);
        List<StoragePoolVO> pools = _storagePoolDao.listBy(dcId, podId, 
clusterId, ScopeType.CLUSTER);
         if (pools.size() == 0) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2c1a3b5f/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java 
b/server/src/com/cloud/server/ManagementServerImpl.java
index 682332c..93073bb 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -1334,8 +1334,14 @@ public class ManagementServerImpl extends ManagerBase 
implements ManagementServe
 
             // Get all the pools available. Only shared pools are considered 
because only a volume on a shared pools
             // can be live migrated while the virtual machine stays on the 
same host.
-            List<StoragePoolVO> storagePools = 
_poolDao.findPoolsByTags(volume.getDataCenterId(),
-                    volume.getPodId(), srcVolumePool.getClusterId(), null);
+            List<StoragePoolVO> storagePools = null;
+
+            if (srcVolumePool.getClusterId() == null) {
+                storagePools = 
_poolDao.findZoneWideStoragePoolsByTags(volume.getDataCenterId(), null);
+            } else {
+                storagePools = 
_poolDao.findPoolsByTags(volume.getDataCenterId(), volume.getPodId(), 
srcVolumePool.getClusterId(), null);
+            }
+
             storagePools.remove(srcVolumePool);
             for (StoragePoolVO pool : storagePools) {
                 if (pool.isShared()) {

Reply via email to