From d6c192c0f083a6dccacefcd1de4dd2c3e5f4dedf Mon Sep 17 00:00:00 2001 From: Lorenzo Tanganelli Date: Tue, 27 Jan 2026 13:45:16 +0100 Subject: [PATCH] fix template id unmanaged vm (#12288) * fix template id unmanaged vm * Update == to equals Co-authored-by: dahn --------- Co-authored-by: dahn --- .../org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 13fa2608016..14c67417015 100644 --- a/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java +++ b/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java @@ -1550,11 +1550,12 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { protected VMTemplateVO getTemplateForImportInstance(Long templateId, Hypervisor.HypervisorType hypervisorType) { VMTemplateVO template; if (templateId == null) { - template = templateDao.findByName(VM_IMPORT_DEFAULT_TEMPLATE_NAME); + String templateName = (Hypervisor.HypervisorType.KVM.equals(hypervisorType)) ? KVM_VM_IMPORT_DEFAULT_TEMPLATE_NAME : VM_IMPORT_DEFAULT_TEMPLATE_NAME; + template = templateDao.findByName(templateName); if (template == null) { template = createDefaultDummyVmImportTemplate(Hypervisor.HypervisorType.KVM == hypervisorType); if (template == null) { - throw new InvalidParameterValueException(String.format("Default VM import template with unique name: %s for hypervisor: %s cannot be created. Please use templateid parameter for import", VM_IMPORT_DEFAULT_TEMPLATE_NAME, hypervisorType.toString())); + throw new InvalidParameterValueException(String.format("Default VM import template with unique name: %s for hypervisor: %s cannot be created. Please use templateid parameter for import", templateName, hypervisorType.toString())); } } } else {