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 d5e8a84516f..4bcaedb6172 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 @@ -440,6 +440,11 @@ public class CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _createprivatetemplatefromsnapshotwait, _mgmtServer.getExecuteInSequence()); EndPoint ep = selector.select(srcData, destData); Answer answer = ep.sendMessage(cmd); + + // clean up snapshot copied to staging + if (srcData != null) { + cacheMgr.deleteCacheObject(srcData); + } return answer; } diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageSubsystemCommandHandler.java b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageSubsystemCommandHandler.java index f2ba492c7b9..ba72e8ff167 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageSubsystemCommandHandler.java +++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageSubsystemCommandHandler.java @@ -102,7 +102,15 @@ public class VmwareStorageSubsystemCommandHandler extends StorageSubsystemComman TemplateObjectTO template = (TemplateObjectTO)answer.getNewData(); template.setDataStore(srcDataStore); CopyCommand newCmd = new CopyCommand(template, destData, cmd.getWait(), cmd.executeInSequence()); - return storageResource.defaultAction(newCmd); + Answer result = storageResource.defaultAction(newCmd); + //clean up template data on staging area + try { + DeleteCommand deleteCommand = new DeleteCommand(template); + storageResource.defaultAction(deleteCommand); + } catch (Exception e) { + s_logger.debug("Failed to clean up staging area:", e); + } + return result; } needDelegation = true; } diff --git a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java index 3e19b641256..3a563cb6655 100755 --- a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java +++ b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java @@ -526,6 +526,14 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S SwiftUtil.putObject(swift, properties, containterName, _tmpltpp); } + //clean up template data on staging area + try { + DeleteCommand deleteCommand = new DeleteCommand(newTemplate); + execute(deleteCommand); + } catch (Exception e) { + s_logger.debug("Failed to clean up staging area:", e); + } + TemplateObjectTO template = new TemplateObjectTO(); template.setPath(swiftPath); template.setSize(templateFile.length()); @@ -543,7 +551,15 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S TemplateObjectTO newTemplate = (TemplateObjectTO)answer.getNewData(); newTemplate.setDataStore(srcDataStore); CopyCommand newCpyCmd = new CopyCommand(newTemplate, destData, cmd.getWait(), cmd.executeInSequence()); - return copyFromNfsToS3(newCpyCmd); + Answer result = copyFromNfsToS3(newCpyCmd); + //clean up template data on staging area + try { + DeleteCommand deleteCommand = new DeleteCommand(newTemplate); + execute(deleteCommand); + } catch (Exception e) { + s_logger.debug("Failed to clean up staging area:", e); + } + return result; } } s_logger.debug("Failed to create templat from snapshot");