Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,7 @@ protected VMTemplateVO getTemplateForImportInstance(Long templateId, Hypervisor.
if (templateId == null) {
template = templateDao.findByName(VM_IMPORT_DEFAULT_TEMPLATE_NAME);
if (template == null) {
template = createDefaultDummyVmImportTemplate(false);
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()));
}
Expand Down Expand Up @@ -2342,14 +2342,7 @@ private UserVmResponse importKvmInstance(ImportVmCmd cmd) {
if (CollectionUtils.isNotEmpty(userVOs)) {
userId = userVOs.get(0).getId();
}
VMTemplateVO template = templateDao.findByName(KVM_VM_IMPORT_DEFAULT_TEMPLATE_NAME);
if (template == null) {
template = createDefaultDummyVmImportTemplate(true);
if (template == null) {
throw new InvalidParameterValueException("Error while creating default Import Vm Template");
}
}

VMTemplateVO template = getTemplateForImportInstance(cmd.getTemplateId(), Hypervisor.HypervisorType.KVM);
final Long serviceOfferingId = cmd.getServiceOfferingId();
if (serviceOfferingId == null) {
throw new InvalidParameterValueException(String.format("Service offering ID cannot be null"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,6 @@ public void testImportFromExternalTest() throws InsufficientServerCapacityExcept
when(cmd.getPassword()).thenReturn("pass");
when(cmd.getImportSource()).thenReturn("external");
when(cmd.getDomainId()).thenReturn(null);
VMTemplateVO template = Mockito.mock(VMTemplateVO.class);
when(templateDao.findByName(anyString())).thenReturn(template);
HostVO host = Mockito.mock(HostVO.class);
when(userVmDao.getNextInSequence(Long.class, "id")).thenReturn(1L);
DeployDestination mockDest = Mockito.mock(DeployDestination.class);
Expand Down Expand Up @@ -738,8 +736,6 @@ private void importFromDisk(String source) throws InsufficientServerCapacityExce
when(cmd.getImportSource()).thenReturn(source);
when(cmd.getDiskPath()).thenReturn("/var/lib/libvirt/images/test.qcow2");
when(cmd.getDomainId()).thenReturn(null);
VMTemplateVO template = Mockito.mock(VMTemplateVO.class);
when(templateDao.findByName(anyString())).thenReturn(template);
HostVO host = Mockito.mock(HostVO.class);
when(hostDao.findById(anyLong())).thenReturn(host);
NetworkOffering netOffering = Mockito.mock(NetworkOffering.class);
Expand Down
Loading