From b2fd1f6d32f418942bbe88d9e924646af1a4272d Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Fri, 3 Sep 2021 16:25:11 +0530 Subject: [PATCH] server: Allow public templates with no url to be migrated (#5404) This PR allows migration of public templates that are created from snapshots / volumes. Data migration across secondary stores initially excluded all public templates on the pretext that public templates are automatically synced when a new image store is added; however, this assumption isn't true for templates marked as "public" when created from snapshots / volumes. Such templates can be identified if their url is null --- .../engine/orchestration/DataMigrationUtility.java | 3 ++- .../java/com/cloud/api/query/dao/TemplateJoinDaoImpl.java | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/DataMigrationUtility.java b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/DataMigrationUtility.java index 7fad871462d..9d044f3c7da 100644 --- a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/DataMigrationUtility.java +++ b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/DataMigrationUtility.java @@ -179,7 +179,8 @@ public class DataMigrationUtility { List templates = templateDataStoreDao.listByStoreId(srcDataStore.getId()); for (TemplateDataStoreVO template : templates) { VMTemplateVO templateVO = templateDao.findById(template.getTemplateId()); - if (template.getState() == ObjectInDataStoreStateMachine.State.Ready && templateVO != null && !templateVO.isPublicTemplate() && + if (template.getState() == ObjectInDataStoreStateMachine.State.Ready && templateVO != null && + (!templateVO.isPublicTemplate() || (templateVO.isPublicTemplate() && templateVO.getUrl() == null)) && templateVO.getHypervisorType() != Hypervisor.HypervisorType.Simulator) { files.add(templateFactory.getTemplate(template.getTemplateId(), srcDataStore)); } diff --git a/server/src/main/java/com/cloud/api/query/dao/TemplateJoinDaoImpl.java b/server/src/main/java/com/cloud/api/query/dao/TemplateJoinDaoImpl.java index d80786352bf..3739b068c8d 100644 --- a/server/src/main/java/com/cloud/api/query/dao/TemplateJoinDaoImpl.java +++ b/server/src/main/java/com/cloud/api/query/dao/TemplateJoinDaoImpl.java @@ -122,7 +122,11 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation