You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ts...@apache.org on 2013/07/01 16:48:37 UTC

[2/2] git commit: updated refs/heads/4.2 to 216e374

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

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit ffd5f1a777ac9af5b65b1fcd357684d7dafcce87)


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/58e69704
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/58e69704
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/58e69704

Branch: refs/heads/4.2
Commit: 58e69704ea9876b3c5195d085f9a7056b7f65298
Parents: 1032d5c
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Thu Jun 6 16:43:04 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Mon Jul 1 20:18:14 2013 +0530

----------------------------------------------------------------------
 server/src/com/cloud/storage/VolumeManagerImpl.java | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58e69704/server/src/com/cloud/storage/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java
index a293da5..30fb322 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<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,