Skip to content

Commit 20076ee

Browse files
tanganelliloreDaanHoogland
authored andcommitted
fix template id unmanaged vm (apache#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 6d8999c commit 20076ee

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
@@ -1564,11 +1564,12 @@ private ServiceOfferingVO getServiceOfferingForImportInstance(Long serviceOfferi
15641564
protected VMTemplateVO getTemplateForImportInstance(Long templateId, Hypervisor.HypervisorType hypervisorType) {
15651565
VMTemplateVO template;
15661566
if (templateId == null) {
1567-
template = templateDao.findByName(VM_IMPORT_DEFAULT_TEMPLATE_NAME);
1567+
String templateName = (Hypervisor.HypervisorType.KVM.equals(hypervisorType)) ? KVM_VM_IMPORT_DEFAULT_TEMPLATE_NAME : VM_IMPORT_DEFAULT_TEMPLATE_NAME;
1568+
template = templateDao.findByName(templateName);
15681569
if (template == null) {
15691570
template = createDefaultDummyVmImportTemplate(Hypervisor.HypervisorType.KVM == hypervisorType);
15701571
if (template == null) {
1571-
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()));
1572+
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()));
15721573
}
15731574
}
15741575
} else {

0 commit comments

Comments
 (0)