cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject git commit: updated refs/heads/4.2 to 6abc3da
Date Wed, 14 Aug 2013 21:58:29 GMT
Updated Branches:
  refs/heads/4.2 1451b8b64 -> 6abc3da82


CLOUDSTACK-4318: clean up snapshot stored in staging area, after backup snapshot to object
store


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

Branch: refs/heads/4.2
Commit: 6abc3da828e1fb32a52222685cfe573f34d50c7a
Parents: 1451b8b
Author: Edison Su <sudison@gmail.com>
Authored: Wed Aug 14 14:58:01 2013 -0700
Committer: Edison Su <sudison@gmail.com>
Committed: Wed Aug 14 14:58:01 2013 -0700

----------------------------------------------------------------------
 .../hypervisor/kvm/storage/KVMStorageProcessor.java | 14 +++++++++++---
 .../VmwareStorageSubsystemCommandHandler.java       | 16 ++++++++++++++--
 2 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6abc3da8/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
index e00e4d2..81ab6aa 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
@@ -563,12 +563,13 @@ public class KVMStorageProcessor implements StorageProcessor {
         String srcSnapshotDir = srcPath.substring(0, index);
         String srcFileName = srcPath.substring(index + 1);
         KVMStoragePool srcStorePool = null;
+        File srcFile = null;
         try {
             srcStorePool = storagePoolMgr.getStoragePoolByURI(srcStore.getUrl() + File.separator
+ srcSnapshotDir);
             if (srcStorePool == null) {
                 return new CopyCmdAnswer("Can't get store:" + srcStore.getUrl());
             }
-            File srcFile = new File(srcStorePool.getLocalPath() + File.separator + srcFileName);
+            srcFile = new File(srcStorePool.getLocalPath() + File.separator + srcFileName);
             if (!srcFile.exists()) {
                 return new CopyCmdAnswer("Can't find src file: " + srcPath);
             }
@@ -582,8 +583,15 @@ public class KVMStorageProcessor implements StorageProcessor {
             newSnapshot.setPath(destPath);
             return new CopyCmdAnswer(newSnapshot);
         } finally {
-            if (srcStorePool != null) {
-                srcStorePool.delete();
+            try {
+                if (srcFile != null) {
+                    srcFile.delete();
+                }
+                if (srcStorePool != null) {
+                    srcStorePool.delete();
+                }
+            } catch(Exception e) {
+                s_logger.debug("Failed to clean up:", e);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6abc3da8/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageSubsystemCommandHandler.java
----------------------------------------------------------------------
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 f4a7db0..f2ba492 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageSubsystemCommandHandler.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageSubsystemCommandHandler.java
@@ -29,14 +29,16 @@ import com.cloud.hypervisor.vmware.manager.VmwareStorageManager;
 import com.cloud.storage.DataStoreRole;
 import org.apache.cloudstack.storage.command.CopyCmdAnswer;
 import org.apache.cloudstack.storage.command.CopyCommand;
+import org.apache.cloudstack.storage.command.DeleteCommand;
 import org.apache.cloudstack.storage.to.SnapshotObjectTO;
 import org.apache.cloudstack.storage.to.TemplateObjectTO;
 import org.apache.cloudstack.storage.to.VolumeObjectTO;
+import org.apache.log4j.Logger;
 
 import java.io.File;
 
 public class VmwareStorageSubsystemCommandHandler extends StorageSubsystemCommandHandlerBase
{
-
+    private static final Logger s_logger = Logger.getLogger(VmwareStorageSubsystemCommandHandler.class);
     private VmwareStorageManager storageManager;
     private PremiumSecondaryStorageResource storageResource;
 
@@ -125,7 +127,17 @@ public class VmwareStorageSubsystemCommandHandler extends StorageSubsystemComman
                 newSnapshot.setPath(newSnapshot.getPath() + ".ova");
                 newSnapshot.setDataStore(cmd.getCacheTO().getDataStore());
                 CopyCommand newCmd = new CopyCommand(newSnapshot, destData, cmd.getWait(),
cmd.executeInSequence());
-                return storageResource.defaultAction(newCmd);
+                Answer result = storageResource.defaultAction(newCmd);
+
+                //clean up data on staging area
+                try {
+                    newSnapshot.setPath(path);
+                    DeleteCommand deleteCommand = new DeleteCommand(newSnapshot);
+                    storageResource.defaultAction(deleteCommand);
+                } catch (Exception e) {
+                    s_logger.debug("Failed to clean up staging area:", e);
+                }
+                return result;
             }
         }
 


Mime
View raw message