CLOUDSTACK-2288: NPE while creating volume from snapshot when the primary storage is in maintenance state.

Signed-off-by: Prasanna Santhanam <tsp@apache.org>
This commit is contained in:
Sanjay Tripathi 2013-06-06 16:43:04 +05:30 committed by Prasanna Santhanam
parent e07a8b3f51
commit ffd5f1a777

View File

@ -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<StoragePool> poolsToAvoid = new HashSet<StoragePool>();
@ -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,