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.
This commit is contained in:
Vijayendra Bhamidipati 2013-07-08 13:15:23 -07:00 committed by Edison Su
parent 505ab2eebe
commit d9ce49b1f1
5 changed files with 22 additions and 2 deletions

View File

@ -145,6 +145,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();

View File

@ -59,6 +59,9 @@ 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()));

View File

@ -96,6 +96,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) {

View File

@ -46,6 +46,11 @@ 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) {

View File

@ -1258,8 +1258,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()) {