mirror of https://github.com/apache/cloudstack.git
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:
parent
0b728f2e77
commit
a91f04e759
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue