You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mt...@apache.org on 2015/01/30 01:35:24 UTC
git commit: updated refs/heads/master to 326a175
Repository: cloudstack
Updated Branches:
refs/heads/master bd6a89939 -> 326a175c0
Don't allow managed (primary) storage to be deleted if it contains one or more snapshots.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/326a175c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/326a175c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/326a175c
Branch: refs/heads/master
Commit: 326a175c08fc9895f68f7c353cffbc9dac60b0b1
Parents: bd6a899
Author: Mike Tutkowski <mi...@solidfire.com>
Authored: Thu Jan 29 16:51:45 2015 -0700
Committer: Mike Tutkowski <mi...@solidfire.com>
Committed: Thu Jan 29 16:51:45 2015 -0700
----------------------------------------------------------------------
.../SolidFirePrimaryDataStoreLifeCycle.java | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/326a175c/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFirePrimaryDataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFirePrimaryDataStoreLifeCycle.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFirePrimaryDataStoreLifeCycle.java
index bc08704..7c36416 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFirePrimaryDataStoreLifeCycle.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFirePrimaryDataStoreLifeCycle.java
@@ -46,6 +46,10 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.resource.ResourceManager;
import com.cloud.storage.StoragePool;
import com.cloud.storage.Storage.StoragePoolType;
+import com.cloud.storage.dao.SnapshotDao;
+import com.cloud.storage.dao.SnapshotDetailsDao;
+import com.cloud.storage.dao.SnapshotDetailsVO;
+import com.cloud.storage.SnapshotVO;
import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePoolAutomation;
import com.cloud.utils.exception.CloudRuntimeException;
@@ -58,6 +62,8 @@ public class SolidFirePrimaryDataStoreLifeCycle implements PrimaryDataStoreLifeC
@Inject private PrimaryDataStoreDao storagePoolDao;
@Inject private PrimaryDataStoreHelper dataStoreHelper;
@Inject private ResourceManager _resourceMgr;
+ @Inject private SnapshotDao _snapshotDao;
+ @Inject private SnapshotDetailsDao _snapshotDetailsDao;
@Inject private StorageManager _storageMgr;
@Inject private StoragePoolAutomation storagePoolAutomation;
@@ -231,6 +237,19 @@ public class SolidFirePrimaryDataStoreLifeCycle implements PrimaryDataStoreLifeC
// invoked to delete primary storage that is based on the SolidFire plug-in
@Override
public boolean deleteDataStore(DataStore store) {
+ List<SnapshotVO> lstSnapshots = _snapshotDao.listAll();
+
+ if (lstSnapshots != null) {
+ for (SnapshotVO snapshot : lstSnapshots) {
+ SnapshotDetailsVO snapshotDetails = _snapshotDetailsDao.findDetail(snapshot.getId(), SolidFireUtil.STORAGE_POOL_ID);
+
+ // if this snapshot belongs to the storagePool that was passed in
+ if (snapshotDetails != null && snapshotDetails.getValue() != null && Long.parseLong(snapshotDetails.getValue()) == store.getId()) {
+ throw new CloudRuntimeException("This primary storage cannot be deleted because it currently contains one or more snapshots.");
+ }
+ }
+ }
+
return dataStoreHelper.deletePrimaryDataStore(store);
}