Fix CS-15910

In case of volume creation from snapshot there is no associated VM so put a check for that.
Reviewed-by: Nitin
This commit is contained in:
Koushik Das 2012-08-09 19:32:39 +05:30
parent 2b3d4c5177
commit 20ba086d99
1 changed files with 3 additions and 2 deletions

View File

@ -74,9 +74,10 @@ public class FirstFitStoragePoolAllocator extends AbstractStoragePoolAllocator {
}
List<StoragePoolVO> pools = null;
if (!dskCh.useLocalStorage() || vmProfile.getVirtualMachine().getHostId() == null) {
// volume is shared "or" vm is not known "or" no host associated then go here
if (!dskCh.useLocalStorage() || vmProfile.getVirtualMachine() == null || vmProfile.getVirtualMachine().getHostId() == null) {
pools = _storagePoolDao.findPoolsByTags(dcId, podId, clusterId, dskCh.getTags(), !dskCh.useLocalStorage());
} else {
} else { // volume is local and vm host id is known
pools = new ArrayList<StoragePoolVO>();
List<StoragePoolHostVO> hostPools = _poolHostDao.listByHostId(vmProfile.getVirtualMachine().getHostId());
for (StoragePoolHostVO hostPool: hostPools) {