Skip to content

Commit a91f04e

Browse files
author
Anthony Xu
committed
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
1 parent 0b728f2 commit a91f04e

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ public Answer execute(VmwareHostService hostService, CopyVolumeCommand cmd) {
491491
hyperHost, volumeId,
492492
new DatastoreMO(context, morDatastore),
493493
secondaryStorageURL, volumePath);
494+
deleteVolumeDirOnSecondaryStorage(volumeId, secondaryStorageURL);
494495
}
495496
return new CopyVolumeAnswer(cmd, true, null, result.first(), result.second());
496497
} catch (Throwable e) {
@@ -1438,4 +1439,22 @@ private VirtualMachineMO createWorkingVM(DatastoreMO dsMo, VmwareHypervisorHost
14381439
workingVM = hyperHost.findVmOnHyperHost(uniqueName);
14391440
return workingVM;
14401441
}
1442+
1443+
1444+
1445+
private String deleteVolumeDirOnSecondaryStorage(long volumeId, String secStorageUrl) throws Exception {
1446+
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
1447+
String volumeMountRoot = secondaryMountPoint + "/" + getVolumeRelativeDirInSecStroage(volumeId);
1448+
1449+
return deleteDir(volumeMountRoot);
1450+
}
1451+
1452+
private String deleteDir(String dir) {
1453+
synchronized(dir.intern()) {
1454+
Script command = new Script(false, "rm", _timeout, s_logger);
1455+
command.add("-rf");
1456+
command.add(dir);
1457+
return command.execute();
1458+
}
1459+
}
14411460
}

0 commit comments

Comments
 (0)