From e607998afaf091194906a5cae4463adbf9787c4c Mon Sep 17 00:00:00 2001 From: Min Chen Date: Mon, 9 Sep 2013 16:07:46 -0700 Subject: [PATCH] CLOUDSTACK-4628:[Automation] Failed to create template from snapshot with same name; after deleting the first one. --- .../cloudstack/storage/motion/AncientDataMotionStrategy.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 1d579219e19..dce8c4e6294 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 @@ -431,7 +431,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); } @@ -441,7 +443,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;