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

git commit: updated refs/heads/master-6-17-stable to 527080e

Updated Branches:
  refs/heads/master-6-17-stable 1c0239099 -> 527080e8e


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


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

Branch: refs/heads/master-6-17-stable
Commit: 527080e8effe675e7875fff6a0a69de606e3e3eb
Parents: 1c02390
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Thu Jun 6 16:43:04 2013 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Wed Jul 10 18:21:38 2013 +0530

----------------------------------------------------------------------
 server/src/com/cloud/storage/VolumeManagerImpl.java | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/527080e8/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 d36374a..5eece13 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -496,7 +496,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>();
@@ -523,7 +523,13 @@ 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 = this.volFactory.getVolume(volume.getId());
         DataStore store = this.dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary);
         SnapshotInfo snapInfo = this.snapshotFactory.getSnapshot(snapshot.getId());
@@ -582,7 +588,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,