diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java index a293da5c9a7..30fb322f415 100644 --- a/server/src/com/cloud/storage/VolumeManagerImpl.java +++ b/server/src/com/cloud/storage/VolumeManagerImpl.java @@ -527,7 +527,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { @DB protected VolumeInfo createVolumeFromSnapshot(VolumeVO volume, - SnapshotVO snapshot) { + SnapshotVO snapshot) throws StorageUnavailableException { Account account = _accountDao.findById(volume.getAccountId()); final HashSet poolsToAvoid = new HashSet(); @@ -555,6 +555,12 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { } } + if (pool == null) { + String msg = "There are no available storage pools to store the volume in"; + s_logger.info(msg); + throw new StorageUnavailableException(msg, -1); + } + VolumeInfo vol = volFactory.getVolume(volume.getId()); DataStore store = dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary); SnapshotInfo snapInfo = snapshotFactory.getSnapshot(snapshot.getId(), DataStoreRole.Image); @@ -605,7 +611,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { } } - protected VolumeVO createVolumeFromSnapshot(VolumeVO volume, long snapshotId) { + protected VolumeVO createVolumeFromSnapshot(VolumeVO volume, long snapshotId) throws StorageUnavailableException { VolumeInfo createdVolume = null; SnapshotVO snapshot = _snapshotDao.findById(snapshotId); createdVolume = createVolumeFromSnapshot(volume,