@@ -426,8 +426,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
426426
427427 private static final long GiB_TO_BYTES = 1024 * 1024 * 1024;
428428
429- private static final String KVM_BLANK_VM_TEMPLATE_NAME = "kvm-blank-vm-template";
430-
431429
432430 @Inject
433431 private EntityManager _entityMgr;
@@ -3939,7 +3937,7 @@ public UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, Service
39393937 _accountMgr.checkAccess(owner, _diskOfferingDao.findById(diskOfferingId), zone);
39403938
39413939 // If no network is specified, find system security group enabled network
3942- if (isBlankInstance(template)) {
3940+ if (_itMgr. isBlankInstance(template)) {
39433941 logger.debug("Blank instance for {} hypervisor, skipping network allocation in an advanced security group enabled zone", hypervisor);
39443942 } else if (networkIdList == null || networkIdList.isEmpty()) {
39453943 Network networkWithSecurityGroup = _networkModel.getNetworkWithSGWithFreeIPs(owner, zone.getId());
@@ -4054,7 +4052,7 @@ public UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serv
40544052 _accountMgr.checkAccess(owner, diskOffering, zone);
40554053
40564054 List<HypervisorType> vpcSupportedHTypes = _vpcMgr.getSupportedVpcHypervisors();
4057- if (isBlankInstance(template)) {
4055+ if (_itMgr. isBlankInstance(template)) {
40584056 logger.debug("Template is a dummy template for hypervisor {}, skipping network allocation in an advanced zone", hypervisor);
40594057 } else if (networkIdList == null || networkIdList.isEmpty()) {
40604058 NetworkVO defaultNetwork = getDefaultNetwork(zone, owner, false);
@@ -4290,7 +4288,7 @@ private UserVm createVirtualMachine(DataCenter zone, ServiceOffering serviceOffe
42904288 if (isIso) {
42914289 if (diskOfferingId == null) {
42924290 DiskOfferingVO diskOffering = _diskOfferingDao.findById(rootDiskOfferingId);
4293- if (diskOffering.isComputeOnly()) {
4291+ if (diskOffering.isComputeOnly() && !_itMgr.isBlankInstance(template) ) {
42944292 throw new InvalidParameterValueException("Installing from ISO requires a disk offering to be specified for the root disk.");
42954293 }
42964294 } else {
@@ -4488,7 +4486,7 @@ private UserVm getUncheckedUserVmResource(DataCenter zone, String hostName, Stri
44884486 }
44894487
44904488 if (TemplateType.SYSTEM.equals(template.getTemplateType()) && !CKS_NODE.equals(vmType) &&
4491- !SHAREDFSVM.equals(vmType) && !isBlankInstanceDefaultTemplate(template)) {
4489+ !SHAREDFSVM.equals(vmType) && !_itMgr. isBlankInstanceDefaultTemplate(template)) {
44924490 throw new InvalidParameterValueException(String.format("Unable to use system template %s to deploy a user vm", template));
44934491 }
44944492
@@ -4501,7 +4499,7 @@ private UserVm getUncheckedUserVmResource(DataCenter zone, String hostName, Stri
45014499 if (CollectionUtils.isEmpty(snapshotsOnZone)) {
45024500 throw new InvalidParameterValueException("The snapshot does not exist on zone " + zone.getId());
45034501 }
4504- } else if (!isBlankInstanceDefaultTemplate(template)) {
4502+ } else if (!_itMgr. isBlankInstanceDefaultTemplate(template)) {
45054503 List<VMTemplateZoneVO> listZoneTemplate = _templateZoneDao.listByZoneTemplate(zone.getId(), template.getId());
45064504 if (listZoneTemplate == null || listZoneTemplate.isEmpty()) {
45074505 throw new InvalidParameterValueException("The template " + template.getId() + " is not available for use");
@@ -4616,7 +4614,7 @@ private UserVm getUncheckedUserVmResource(DataCenter zone, String hostName, Stri
46164614 // by Agent Manager in order to configure default
46174615 // gateway for the vm
46184616 if (defaultNetworkNumber == 0) {
4619- if (isBlankInstance(template)) {
4617+ if (_itMgr. isBlankInstance(template)) {
46204618 logger.debug("Template is a dummy template for hypervisor {}, vm can be created without a default network", hypervisorType);
46214619 } else {
46224620 throw new InvalidParameterValueException("At least 1 default network has to be specified for the vm");
@@ -6658,7 +6656,7 @@ private UserVm createVirtualMachine(BaseDeployVMCmd cmd, DataCenter zone, Accoun
66586656 applyLeaseOnCreateInstance(vm, cmd.getLeaseDuration(), cmd.getLeaseExpiryAction(), svcOffering);
66596657 }
66606658
6661- if (isBlankInstance(template) && cmd instanceof DeployVMCmd && ((DeployVMCmd) cmd).isBlankInstance()) {
6659+ if (_itMgr. isBlankInstance(template) && cmd instanceof DeployVMCmd && ((DeployVMCmd) cmd).isBlankInstance()) {
66626660 logger.info("Revoking launch permission for Dummy template");
66636661 launchPermissionDao.removePermissions(template.getId(), Collections.singletonList(owner.getId()));
66646662 }
@@ -10104,26 +10102,13 @@ private void setVncPasswordForKvmIfAvailable(Map<String, String> customParameter
1010410102 }
1010510103 }
1010610104
10107- protected boolean isBlankInstanceDefaultTemplate(VirtualMachineTemplate template) {
10108- return KVM_BLANK_VM_TEMPLATE_NAME.equals(template.getUniqueName());
10109- }
10110-
10111- @Override
10112- public boolean isBlankInstance(VirtualMachineTemplate template) {
10113- if (isBlankInstanceDefaultTemplate(template)) {
10114- return true;
10115- }
10116- return Boolean.TRUE.equals(
10117- MapUtils.getBoolean(CallContext.current().getContextParameters(), ApiConstants.BLANK_INSTANCE));
10118- }
10119-
10120- VMTemplateVO getBlankInstanceTemplate() {
10121- VMTemplateVO template = _templateDao.findByName(KVM_BLANK_VM_TEMPLATE_NAME);
10105+ protected VMTemplateVO getBlankInstanceTemplate() {
10106+ VMTemplateVO template = _templateDao.findByName(VirtualMachineManager.KVM_BLANK_VM_TEMPLATE_NAME);
1012210107 if (template != null) {
1012310108 return template;
1012410109 }
1012510110 template = VMTemplateVO.createSystemIso(_templateDao.getNextInSequence(Long.class, "id"),
10126- KVM_BLANK_VM_TEMPLATE_NAME, KVM_BLANK_VM_TEMPLATE_NAME, true,
10111+ VirtualMachineManager. KVM_BLANK_VM_TEMPLATE_NAME, VirtualMachineManager. KVM_BLANK_VM_TEMPLATE_NAME, true,
1012710112 "", true, 64, Account.ACCOUNT_ID_SYSTEM, "",
1012810113 "Blank Template for KVM VM", false, 1);
1012910114 template.setState(VirtualMachineTemplate.State.Active);
0 commit comments