mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 01:32:18 +02:00
kvm: honor templateId passed in importVM API (#11640)
This commit is contained in:
parent
a749206eb8
commit
a18b5514e6
@ -1493,7 +1493,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
|
||||
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()));
|
||||
}
|
||||
@ -2331,14 +2331,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
|
||||
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"));
|
||||
|
||||
@ -504,8 +504,6 @@ public class UnmanagedVMsManagerImplTest {
|
||||
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);
|
||||
DeployDestination mockDest = Mockito.mock(DeployDestination.class);
|
||||
when(deploymentPlanningManager.planDeployment(any(), any(), any(), any())).thenReturn(mockDest);
|
||||
@ -736,8 +734,6 @@ public class UnmanagedVMsManagerImplTest {
|
||||
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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user