You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by vi...@apache.org on 2024/06/24 07:16:27 UTC
(cloudstack) branch 4.19 updated: Support migration of VM imported from a remote host (#9259)
This is an automated email from the ASF dual-hosted git repository.
vishesh pushed a commit to branch 4.19
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.19 by this push:
new f792684b9c4 Support migration of VM imported from a remote host (#9259)
f792684b9c4 is described below
commit f792684b9c40e6a1212176a83a9453ed4c3a5ca1
Author: Pearl Dsilva <pe...@gmail.com>
AuthorDate: Mon Jun 24 03:16:21 2024 -0400
Support migration of VM imported from a remote host (#9259)
---
.../storage/motion/StorageSystemDataMotionStrategy.java | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java b/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java
index a93f624aa53..71e8c0afc8f 100644
--- a/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java
+++ b/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java
@@ -24,6 +24,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
@@ -140,6 +141,9 @@ import java.util.HashSet;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
+import static org.apache.cloudstack.vm.UnmanagedVMsManagerImpl.KVM_VM_IMPORT_DEFAULT_TEMPLATE_NAME;
+import static org.apache.cloudstack.vm.UnmanagedVMsManagerImpl.VM_IMPORT_DEFAULT_TEMPLATE_NAME;
+
public class StorageSystemDataMotionStrategy implements DataMotionStrategy {
private static final Logger LOGGER = Logger.getLogger(StorageSystemDataMotionStrategy.class);
private static final Random RANDOM = new Random(System.nanoTime());
@@ -1932,7 +1936,10 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy {
continue;
}
- if (srcVolumeInfo.getTemplateId() != null) {
+ VMTemplateVO vmTemplate = _vmTemplateDao.findById(vmInstance.getTemplateId());
+ if (srcVolumeInfo.getTemplateId() != null &&
+ Objects.nonNull(vmTemplate) &&
+ !Arrays.asList(KVM_VM_IMPORT_DEFAULT_TEMPLATE_NAME, VM_IMPORT_DEFAULT_TEMPLATE_NAME).contains(vmTemplate.getName())) {
LOGGER.debug(String.format("Copying template [%s] of volume [%s] from source storage pool [%s] to target storage pool [%s].", srcVolumeInfo.getTemplateId(), srcVolumeInfo.getId(), sourceStoragePool.getId(), destStoragePool.getId()));
copyTemplateToTargetFilesystemStorageIfNeeded(srcVolumeInfo, sourceStoragePool, destDataStore, destStoragePool, destHost);
} else {
@@ -2151,7 +2158,7 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy {
if (srcVolumeInfo.getHypervisorType() == HypervisorType.KVM &&
srcVolumeInfo.getTemplateId() != null && srcVolumeInfo.getPoolId() != null) {
VMTemplateVO template = _vmTemplateDao.findById(srcVolumeInfo.getTemplateId());
- if (template.getFormat() != null && template.getFormat() != Storage.ImageFormat.ISO) {
+ if (Objects.nonNull(template) && template.getFormat() != null && template.getFormat() != Storage.ImageFormat.ISO) {
VMTemplateStoragePoolVO ref = templatePoolDao.findByPoolTemplate(srcVolumeInfo.getPoolId(), srcVolumeInfo.getTemplateId(), null);
return ref != null ? ref.getInstallPath() : null;
}