Skip to content

Commit d6c192c

Browse files
fix template id unmanaged vm (#12288)
* fix template id unmanaged vm * Update == to equals Co-authored-by: dahn <daan.hoogland@gmail.com> --------- Co-authored-by: dahn <daan.hoogland@gmail.com>
1 parent cd2d711 commit d6c192c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,11 +1550,12 @@ private ServiceOfferingVO getServiceOfferingForImportInstance(Long serviceOfferi
15501550
protected VMTemplateVO getTemplateForImportInstance(Long templateId, Hypervisor.HypervisorType hypervisorType) {
15511551
VMTemplateVO template;
15521552
if (templateId == null) {
1553-
template = templateDao.findByName(VM_IMPORT_DEFAULT_TEMPLATE_NAME);
1553+
String templateName = (Hypervisor.HypervisorType.KVM.equals(hypervisorType)) ? KVM_VM_IMPORT_DEFAULT_TEMPLATE_NAME : VM_IMPORT_DEFAULT_TEMPLATE_NAME;
1554+
template = templateDao.findByName(templateName);
15541555
if (template == null) {
15551556
template = createDefaultDummyVmImportTemplate(Hypervisor.HypervisorType.KVM == hypervisorType);
15561557
if (template == null) {
1557-
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()));
1558+
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()));
15581559
}
15591560
}
15601561
} else {

0 commit comments

Comments
 (0)