mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fix deploy as-is disks cleanup
This commit is contained in:
parent
41354227e2
commit
7a8dd46b32
@ -62,6 +62,7 @@ public class VolumeObjectTO implements DataTO {
|
||||
private Hypervisor.HypervisorType hypervisorType;
|
||||
private MigrationOptions migrationOptions;
|
||||
private boolean directDownload;
|
||||
private boolean deployAsIs;
|
||||
|
||||
public VolumeObjectTO() {
|
||||
|
||||
@ -102,6 +103,7 @@ public class VolumeObjectTO implements DataTO {
|
||||
setDeviceId(volume.getDeviceId());
|
||||
this.migrationOptions = volume.getMigrationOptions();
|
||||
this.directDownload = volume.isDirectDownload();
|
||||
this.deployAsIs = volume.isDeployAsIs();
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
@ -313,4 +315,8 @@ public class VolumeObjectTO implements DataTO {
|
||||
public boolean isDirectDownload() {
|
||||
return directDownload;
|
||||
}
|
||||
|
||||
public boolean isDeployAsIs() {
|
||||
return deployAsIs;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2474,9 +2474,14 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
|
||||
List<Map<String, String>> dynamicTargetsToRemove = null;
|
||||
|
||||
boolean deployAsIs = vol.isDeployAsIs();
|
||||
if (vmMo != null) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Destroy root volume and VM itself. vmName " + vmName);
|
||||
if (deployAsIs) {
|
||||
s_logger.info("Destroying root volume " + vol.getPath() + " of deploy-as-is VM " + vmName);
|
||||
} else {
|
||||
s_logger.info("Destroy root volume and VM itself. vmName " + vmName);
|
||||
}
|
||||
}
|
||||
|
||||
VirtualMachineDiskInfo diskInfo = null;
|
||||
@ -2524,6 +2529,24 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (deployAsIs) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Destroying root volume " + vol.getPath() + " of already removed deploy-as-is VM " + vmName);
|
||||
}
|
||||
// The disks of the deploy-as-is VM have been detached from the VM and moved to root folder
|
||||
String deployAsIsRootDiskPath = dsMo.searchFileInSubFolders(vol.getPath() + VmwareResource.VMDK_EXTENSION,
|
||||
true, null);
|
||||
if (StringUtils.isNotBlank(deployAsIsRootDiskPath)) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Removing disk " + deployAsIsRootDiskPath);
|
||||
}
|
||||
dsMo.deleteFile(deployAsIsRootDiskPath, morDc, true);
|
||||
String deltaFilePath = dsMo.searchFileInSubFolders(vol.getPath() + "-delta" + VmwareResource.VMDK_EXTENSION,
|
||||
true, null);
|
||||
if (StringUtils.isNotBlank(deltaFilePath)) {
|
||||
dsMo.deleteFile(deltaFilePath, morDc, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user