CLOUDSTACK-4628:[Automation] Failed to create template from snapshot
with same name; after deleting the first one.


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

Branch: refs/heads/kvm-vnc-listen
Commit: 16a1f150eb3fd6f9633b9926a153575d34076787
Parents: 771b837
Author: Min Chen <[email protected]>
Authored: Mon Sep 9 16:07:46 2013 -0700
Committer: Min Chen <[email protected]>
Committed: Mon Sep 9 16:10:33 2013 -0700

----------------------------------------------------------------------
 .../cloudstack/storage/motion/AncientDataMotionStrategy.java     | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/16a1f150/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
----------------------------------------------------------------------
diff --git 
a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
 
b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
index 4bcaedb..c8a24c6 100644
--- 
a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
+++ 
b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
@@ -432,7 +432,9 @@ public class
         int _createprivatetemplatefromsnapshotwait = 
NumbersUtil.parseInt(value,
                 
Integer.parseInt(Config.CreatePrivateTemplateFromSnapshotWait.getDefaultValue()));
 
+        boolean needCache = false;
         if (needCacheStorage(srcData, destData)) {
+            needCache = true;
             SnapshotInfo snapshot = (SnapshotInfo) srcData;
             srcData = cacheSnapshotChain(snapshot);
         }
@@ -442,7 +444,7 @@ public class
         Answer answer = ep.sendMessage(cmd);
         
         // clean up snapshot copied to staging 
-        if (srcData != null) {
+        if (needCache && srcData != null) {
             cacheMgr.deleteCacheObject(srcData);
         }
         return answer;

Reply via email to