diff --git a/core/src/main/java/com/cloud/agent/api/CleanupConvertedInstanceDisksCommand.java b/core/src/main/java/com/cloud/agent/api/CleanupConvertedInstanceDisksCommand.java index 7fbd13666c9..00373ec7536 100644 --- a/core/src/main/java/com/cloud/agent/api/CleanupConvertedInstanceDisksCommand.java +++ b/core/src/main/java/com/cloud/agent/api/CleanupConvertedInstanceDisksCommand.java @@ -21,6 +21,9 @@ package com.cloud.agent.api; import com.cloud.agent.api.to.DataStoreTO; +/** + * This command is used to cleanup the converted instance disks from the storage pool: vmVolumesStore and the prefix: vmVolumesPrefix. + */ public class CleanupConvertedInstanceDisksCommand extends Command { private DataStoreTO vmVolumesStore; diff --git a/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java b/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java index 12b39d88b17..6ea16abb431 100644 --- a/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java +++ b/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java @@ -2243,26 +2243,29 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { throw new CloudRuntimeException(err); } finally { if (cleanupConvertedDisks) { - logger.debug("Cleaning up the converted disks for the VM {} through " + - "the conversion host {}", sourceVM, convertHost.getName()); - CleanupConvertedInstanceDisksCommand cleanupCommand = - new CleanupConvertedInstanceDisksCommand(temporaryConvertLocation, convertedDisksPrefix); - try { - Answer cleanupAnswer = agentManager.send(convertHost.getId(), cleanupCommand); - if (!cleanupAnswer.getResult()) { - logger.warn("Failed to cleanup the converted disks for the VM {} through " + - "the conversion host {}: {}", sourceVM, convertHost.getName(), cleanupAnswer.getDetails()); - } - } catch (AgentUnavailableException | OperationTimedoutException e) { - logger.error("Error cleaning up converted disks for VM {} through the conversion host {}", - sourceVM, convertHost.getName(), e); - } + cleanupConvertedDisks(sourceVM, convertHost, temporaryConvertLocation, convertedDisksPrefix); } } return ((ImportConvertedInstanceAnswer) importAnswer).getConvertedInstance(); } + private void cleanupConvertedDisks(String sourceVM, HostVO convertHost, DataStoreTO temporaryConvertLocation, String convertedDisksPrefix) { + logger.debug("Cleaning up the converted disks for the VM {} through the conversion host {}", sourceVM, convertHost.getName()); + CleanupConvertedInstanceDisksCommand cleanupCommand = + new CleanupConvertedInstanceDisksCommand(temporaryConvertLocation, convertedDisksPrefix); + try { + Answer cleanupAnswer = agentManager.send(convertHost.getId(), cleanupCommand); + if (!cleanupAnswer.getResult()) { + logger.warn("Failed to cleanup the converted disks for the VM {} through " + + "the conversion host {}: {}", sourceVM, convertHost.getName(), cleanupAnswer.getDetails()); + } + } catch (AgentUnavailableException | OperationTimedoutException e) { + logger.error("Error cleaning up converted disks for VM {} through the conversion host {}", + sourceVM, convertHost.getName(), e); + } + } + private List findInstanceConversionDestinationStoragePoolsInCluster( Cluster destinationCluster, ServiceOfferingVO serviceOffering, Map dataDiskOfferingMap,