migrate volume in Vmware leaves a copy of this volume untracked in secondary 
storage,
this patch removes the volume in secondary storag after volume migration


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

Branch: refs/heads/vmware-storage-motion
Commit: a91f04e759be7132ceda11ec5b3e1ff19d83c4e3
Parents: 0b728f2
Author: Anthony Xu <anthony...@citrix.com>
Authored: Wed May 29 14:11:57 2013 -0700
Committer: Anthony Xu <anthony...@citrix.com>
Committed: Wed May 29 14:11:57 2013 -0700

----------------------------------------------------------------------
 .../vmware/manager/VmwareStorageManagerImpl.java   |   19 +++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a91f04e7/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
index 9f1351e..faadbac 100644
--- 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
+++ 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
@@ -491,6 +491,7 @@ public class VmwareStorageManagerImpl implements 
VmwareStorageManager {
                                                hyperHost, volumeId,
                                                new DatastoreMO(context, 
morDatastore),
                                                secondaryStorageURL, 
volumePath);
+                                deleteVolumeDirOnSecondaryStorage(volumeId, 
secondaryStorageURL);
                        }
                        return new CopyVolumeAnswer(cmd, true, null, 
result.first(), result.second());
                } catch (Throwable e) {
@@ -1438,4 +1439,22 @@ public class VmwareStorageManagerImpl implements 
VmwareStorageManager {
         workingVM = hyperHost.findVmOnHyperHost(uniqueName);
         return workingVM;
     }
+
+
+
+    private String deleteVolumeDirOnSecondaryStorage(long volumeId, String 
secStorageUrl) throws Exception {
+        String secondaryMountPoint = 
_mountService.getMountPoint(secStorageUrl);
+        String volumeMountRoot = secondaryMountPoint + "/" + 
getVolumeRelativeDirInSecStroage(volumeId);
+
+        return deleteDir(volumeMountRoot);
+    }
+
+    private String deleteDir(String dir) {
+        synchronized(dir.intern()) {
+            Script command = new Script(false, "rm", _timeout, s_logger);
+            command.add("-rf");
+            command.add(dir);
+            return command.execute();
+        }
+    }
 }

Reply via email to