Skip to content

Commit bbcffbb

Browse files
anshulgangwardevdeep
authored andcommitted
CLOUDSTACK-6965: fixed the NullPointerException introduced by fix for cloudstack
6935 in AbstractStoragePoolAllocator#filter method for Zone Wide storage
1 parent 6416de5 commit bbcffbb

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

engine/storage/src/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@
2727
import javax.inject.Inject;
2828
import javax.naming.ConfigurationException;
2929

30+
import org.apache.log4j.Logger;
31+
3032
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
3133
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
3234
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
3335
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
34-
import org.apache.log4j.Logger;
3536

3637
import com.cloud.dc.ClusterVO;
3738
import com.cloud.dc.dao.ClusterDao;
@@ -171,10 +172,17 @@ protected boolean filter(ExcludeList avoid, StoragePool pool, DiskProfile dskCh,
171172
}
172173

173174
Long clusterId = pool.getClusterId();
174-
ClusterVO cluster = _clusterDao.findById(clusterId);
175-
if (!(cluster.getHypervisorType() == dskCh.getHypervisorType())) {
175+
if (clusterId != null) {
176+
ClusterVO cluster = _clusterDao.findById(clusterId);
177+
if (!(cluster.getHypervisorType() == dskCh.getHypervisorType())) {
178+
if (s_logger.isDebugEnabled()) {
179+
s_logger.debug("StoragePool's Cluster does not have required hypervisorType, skipping this pool");
180+
}
181+
return false;
182+
}
183+
} else if (pool.getHypervisor() != null && !(pool.getHypervisor() == dskCh.getHypervisorType())) {
176184
if (s_logger.isDebugEnabled()) {
177-
s_logger.debug("StoragePool's Cluster does not have required hypervisorType, skipping this pool");
185+
s_logger.debug("StoragePool does not have required hypervisorType, skipping this pool");
178186
}
179187
return false;
180188
}

0 commit comments

Comments
 (0)