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
This commit is contained in:
Anthony Xu 2013-05-29 14:11:57 -07:00
parent 0b728f2e77
commit a91f04e759
1 changed files with 19 additions and 0 deletions

View File

@ -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();
}
}
}