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/26 07:57:52 UTC

[2/2] git commit: updated refs/heads/master to 8204a44

When creating a template from a managed-storage snapshot, put the snapshot in the Copying state before performing the copy (don't want to do anything with the snapshot until this process has completed)


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

Branch: refs/heads/master
Commit: 8204a448900c09fa81c1c4c867ac84e1f59f4457
Parents: f23c5de
Author: Mike Tutkowski <mi...@solidfire.com>
Authored: Sun Jan 25 22:50:47 2015 -0700
Committer: Mike Tutkowski <mi...@solidfire.com>
Committed: Sun Jan 25 23:29:27 2015 -0700

----------------------------------------------------------------------
 .../motion/StorageSystemDataMotionStrategy.java | 33 +++++++++++++++-----
 1 file changed, 26 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8204a448/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java
index de98f55..26a631b 100644
--- a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java
+++ b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java
@@ -177,6 +177,13 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy {
     }
 
     private Void handleCreateTemplateFromSnapshot(SnapshotInfo snapshotInfo, TemplateInfo templateInfo, AsyncCompletionCallback<CopyCommandResult> callback) {
+        try {
+            snapshotInfo.processEvent(Event.CopyingRequested);
+        }
+        catch (Exception ex) {
+            throw new CloudRuntimeException("This snapshot is not currently in a state where it can be used to create a template.");
+        }
+
         HostVO hostVO = getHost(snapshotInfo.getDataStore().getId());
         DataStore srcDataStore = snapshotInfo.getDataStore();
 
@@ -184,6 +191,8 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy {
         int primaryStorageDownloadWait = NumbersUtil.parseInt(value, Integer.parseInt(Config.PrimaryStorageDownloadWait.getDefaultValue()));
         CopyCommand copyCommand = new CopyCommand(snapshotInfo.getTO(), templateInfo.getTO(), primaryStorageDownloadWait, VirtualMachineManager.ExecuteInSequence.value());
 
+        String errMsg = null;
+
         CopyCmdAnswer copyCmdAnswer = null;
 
         try {
@@ -205,16 +214,26 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy {
             catch (Exception ex) {
                 s_logger.debug(ex.getMessage(), ex);
             }
-        }
 
-        String errMsg = null;
+            if (copyCmdAnswer == null || !copyCmdAnswer.getResult()) {
+                if (copyCmdAnswer != null && copyCmdAnswer.getDetails() != null && !copyCmdAnswer.getDetails().isEmpty()) {
+                    errMsg = copyCmdAnswer.getDetails();
+                }
+                else {
+                    errMsg = "Unable to perform host-side operation";
+                }
+            }
 
-        if (copyCmdAnswer == null || !copyCmdAnswer.getResult()) {
-            if (copyCmdAnswer != null && copyCmdAnswer.getDetails() != null && !copyCmdAnswer.getDetails().isEmpty()) {
-                errMsg = copyCmdAnswer.getDetails();
+            try {
+                if (errMsg == null) {
+                    snapshotInfo.processEvent(Event.OperationSuccessed);
+                }
+                else {
+                    snapshotInfo.processEvent(Event.OperationFailed);
+                }
             }
-            else {
-                errMsg = "Unable to perform host-side operation";
+            catch (Exception ex) {
+                s_logger.debug(ex.getMessage(), ex);
             }
         }