@@ -9509,6 +9509,13 @@ public UserVm importVM(final DataCenter zone, final Host host, final VirtualMach
95099509 throw new InvalidParameterValueException("Unable to import virtual machine with invalid host");
95109510 }
95119511
9512+ // Ensure template details are loaded so that commitUserVm can copy them into the VM's details map
9513+ VMTemplateVO vmTemplateVO = null;
9514+ if (template != null) {
9515+ vmTemplateVO = _templateDao.findById(template.getId());
9516+ _templateDao.loadDetails(vmTemplateVO);
9517+ }
9518+
95129519 final long id = _vmDao.getNextInSequence(Long.class, "id");
95139520 String instanceName = StringUtils.isBlank(instanceNameInternal) ?
95149521 getInternalName(owner.getAccountId(), id) :
@@ -9521,10 +9528,10 @@ public UserVm importVM(final DataCenter zone, final Host host, final VirtualMach
95219528
95229529 final String uuidName = _uuidMgr.generateUuid(UserVm.class, null);
95239530 final Host lastHost = powerState != VirtualMachine.PowerState.PowerOn ? host : null;
9524- final Boolean dynamicScalingEnabled = checkIfDynamicScalingCanBeEnabled(null, serviceOffering, template , zone.getId());
9525- return commitUserVm(true, zone, host, lastHost, template , hostName, displayName, owner,
9531+ final Boolean dynamicScalingEnabled = checkIfDynamicScalingCanBeEnabled(null, serviceOffering, vmTemplateVO , zone.getId());
9532+ return commitUserVm(true, zone, host, lastHost, vmTemplateVO , hostName, displayName, owner,
95269533 null, null, userData, null, null, isDisplayVm, keyboard,
9527- accountId, userId, serviceOffering, template .getFormat().equals(ImageFormat.ISO), sshPublicKeys, networkNicMap,
9534+ accountId, userId, serviceOffering, vmTemplateVO .getFormat().equals(ImageFormat.ISO), sshPublicKeys, networkNicMap,
95289535 id, instanceName, uuidName, hypervisorType, customParameters,
95299536 null, null, null, powerState, dynamicScalingEnabled, null, serviceOffering.getDiskOfferingId(), null, null, null, null);
95309537 });
0 commit comments