From c8478316624e334749a91a975d08ed035a9293ed Mon Sep 17 00:00:00 2001 From: Mike Tutkowski Date: Mon, 26 Jan 2015 09:15:56 -0700 Subject: [PATCH] Do not allow deletion of the snapshot if the snapshot is being copied --- .../storage/snapshot/StorageSystemSnapshotStrategy.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java index c4946ab5dba..90c7244b34f 100644 --- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java +++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java @@ -28,6 +28,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreCapabilities; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; +import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine; import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory; import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo; import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotResult; @@ -117,6 +118,10 @@ public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase { return true; } + if (ObjectInDataStoreStateMachine.State.Copying.equals(snapshotObj.getStatus())) { + throw new InvalidParameterValueException("Unable to delete snapshotshot " + snapshotId + " because it is in the copying state."); + } + try { snapshotObj.processEvent(Snapshot.Event.DestroyRequested); }