From 9b51a706db75eb2fa5f463c44018b0af6f3ebb08 Mon Sep 17 00:00:00 2001 From: nvazquez Date: Wed, 30 Sep 2020 10:25:57 -0300 Subject: [PATCH] Set deploy-as-is to default on VMware --- .../template/VirtualMachineTemplate.java | 2 - .../cloud/vm/VirtualMachineManagerImpl.java | 10 +- .../orchestration/VolumeOrchestrator.java | 6 +- .../java/com/cloud/storage/VMTemplateVO.java | 15 +-- .../META-INF/db/schema-41400to41500.sql | 112 ------------------ .../storage/image/TemplateServiceImpl.java | 6 +- .../storage/image/store/TemplateObject.java | 6 +- .../image/BaseImageStoreDriverImpl.java | 3 +- .../storage/volume/VolumeObject.java | 4 +- .../storage/volume/VolumeServiceImpl.java | 4 +- .../com/cloud/hypervisor/guru/VMwareGuru.java | 2 +- .../hypervisor/guru/VmwareVmImplementer.java | 2 +- .../deploy/DeploymentPlanningManagerImpl.java | 2 +- .../storage/ImageStoreUploadMonitorImpl.java | 2 +- .../com/cloud/storage/TemplateProfile.java | 8 +- .../template/HypervisorTemplateAdapter.java | 6 +- .../cloud/template/TemplateAdapterBase.java | 4 +- .../cloud/template/TemplateManagerImpl.java | 2 +- .../vm/DeploymentPlanningManagerImplTest.java | 5 - 19 files changed, 28 insertions(+), 173 deletions(-) diff --git a/api/src/main/java/com/cloud/template/VirtualMachineTemplate.java b/api/src/main/java/com/cloud/template/VirtualMachineTemplate.java index 95d1ebf0b87..5177e51d401 100644 --- a/api/src/main/java/com/cloud/template/VirtualMachineTemplate.java +++ b/api/src/main/java/com/cloud/template/VirtualMachineTemplate.java @@ -138,6 +138,4 @@ public interface VirtualMachineTemplate extends ControlledEntity, Identity, Inte void incrUpdatedCount(); Date getUpdated(); - - boolean isDeployAsIs(); } diff --git a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java index e8a96f1d6fb..2cce812df41 100755 --- a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java @@ -597,12 +597,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac //remove the overcommit details from the uservm details userVmDetailsDao.removeDetails(vm.getId()); - // Remove details if VM deploy as-is - long templateId = vm.getTemplateId(); - VMTemplateVO template = _templateDao.findById(templateId); - if (template != null && template.isDeployAsIs()) { - userVmDeployAsIsDetailsDao.removeDetails(vm.getId()); - } + // Remove deploy as-is (if any) + userVmDeployAsIsDetailsDao.removeDetails(vm.getId()); // send hypervisor-dependent commands before removing final List finalizeExpungeCommands = hvGuru.finalizeExpunge(vm); @@ -1116,7 +1112,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac if (dest != null) { avoids.addHost(dest.getHost().getId()); - if (!template.isDeployAsIs()) { + if (template.getHypervisorType() == HypervisorType.VMware && vm.getType() == VirtualMachine.Type.User) { journal.record("Deployment found ", vmProfile, dest); } } diff --git a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java index b4d662d449c..aedaf4018f3 100644 --- a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java +++ b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java @@ -759,7 +759,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati Long size = _tmpltMgr.getTemplateSize(template.getId(), vm.getDataCenterId()); if (rootDisksize != null) { - if (template.isDeployAsIs()) { + if (vm.getHypervisorType() == HypervisorType.VMware && vm.getType() == VirtualMachine.Type.User) { // Volume size specified from template deploy-as-is size = rootDisksize; } else { @@ -824,7 +824,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati int volumesNumber = 1; List templateAsIsDisks = null; String configurationId = null; - if (template.isDeployAsIs()) { + if (vm.getHypervisorType() == HypervisorType.VMware && vm.getType() == VirtualMachine.Type.User) { UserVmDetailVO configurationDetail = userVmDetailsDao.findDetail(vm.getId(), VmDetailConstants.DEPLOY_AS_IS_CONFIGURATION); if (configurationDetail != null) { configurationId = configurationDetail.getValue(); @@ -849,7 +849,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati String volumeName = name; Long volumeSize = rootDisksize; long deviceId = type.equals(Type.ROOT) ? 0L : 1L; - if (template.isDeployAsIs()) { + if (vm.getHypervisorType() == HypervisorType.VMware && vm.getType() == VirtualMachine.Type.User) { int volumeNameSuffix = templateAsIsDisks.get(number).getDiskNumber(); volumeName = String.format("%s-%d", volumeName, volumeNameSuffix); volumeSize = templateAsIsDisks.get(number).getVirtualSize(); diff --git a/engine/schema/src/main/java/com/cloud/storage/VMTemplateVO.java b/engine/schema/src/main/java/com/cloud/storage/VMTemplateVO.java index 61df40e50d8..3bbebf9ba5f 100644 --- a/engine/schema/src/main/java/com/cloud/storage/VMTemplateVO.java +++ b/engine/schema/src/main/java/com/cloud/storage/VMTemplateVO.java @@ -152,9 +152,6 @@ public class VMTemplateVO implements VirtualMachineTemplate { @Column(name = "parent_template_id") private Long parentTemplateId; - @Column(name = "deploy_as_is") - private boolean deployAsIs; - @Override public String getUniqueName() { return uniqueName; @@ -196,8 +193,7 @@ public class VMTemplateVO implements VirtualMachineTemplate { } public VMTemplateVO(long id, String name, ImageFormat format, boolean isPublic, boolean featured, boolean isExtractable, TemplateType type, String url, boolean requiresHvm, int bits, long accountId, String cksum, String displayText, boolean enablePassword, long guestOSId, boolean bootable, - HypervisorType hyperType, String templateTag, Map details, boolean sshKeyEnabled, boolean isDynamicallyScalable, boolean directDownload, - boolean deployAsIs) { + HypervisorType hyperType, String templateTag, Map details, boolean sshKeyEnabled, boolean isDynamicallyScalable, boolean directDownload) { this(id, name, format, @@ -222,7 +218,6 @@ public class VMTemplateVO implements VirtualMachineTemplate { dynamicallyScalable = isDynamicallyScalable; state = State.Active; this.directDownload = directDownload; - this.deployAsIs = deployAsIs; } public static VMTemplateVO createPreHostIso(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic, boolean featured, TemplateType type, @@ -640,12 +635,4 @@ public class VMTemplateVO implements VirtualMachineTemplate { public void setParentTemplateId(Long parentTemplateId) { this.parentTemplateId = parentTemplateId; } - - @Override public boolean isDeployAsIs() { - return deployAsIs; - } - - public void setDeployAsIs(boolean deployAsIs) { - this.deployAsIs = deployAsIs; - } } diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41400to41500.sql b/engine/schema/src/main/resources/META-INF/db/schema-41400to41500.sql index 76907037af1..01969d6e215 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41400to41500.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41400to41500.sql @@ -260,118 +260,6 @@ CREATE VIEW `cloud`.`storage_pool_view` AS LEFT JOIN `async_job` ON (((`async_job`.`instance_id` = `storage_pool`.`id`) AND (`async_job`.`instance_type` = 'StoragePool') AND (`async_job`.`job_status` = 0)))); --- Add passthrough instruction for appliance deployments -ALTER TABLE `cloud`.`vm_template` ADD COLUMN `deploy_as_is` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'True if the template should be deployed with disks and networks as defined by OVF'; - --- Extend the template details value field -ALTER TABLE `cloud`.`vm_template_details` MODIFY COLUMN `value` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; - --- Changes to template_view for both deploying multidisk OVA/vApp as is -DROP VIEW IF EXISTS `cloud`.`template_view`; -CREATE VIEW `cloud`.`template_view` AS - SELECT - `vm_template`.`id` AS `id`, - `vm_template`.`uuid` AS `uuid`, - `vm_template`.`unique_name` AS `unique_name`, - `vm_template`.`name` AS `name`, - `vm_template`.`public` AS `public`, - `vm_template`.`featured` AS `featured`, - `vm_template`.`type` AS `type`, - `vm_template`.`hvm` AS `hvm`, - `vm_template`.`bits` AS `bits`, - `vm_template`.`url` AS `url`, - `vm_template`.`format` AS `format`, - `vm_template`.`created` AS `created`, - `vm_template`.`checksum` AS `checksum`, - `vm_template`.`display_text` AS `display_text`, - `vm_template`.`enable_password` AS `enable_password`, - `vm_template`.`dynamically_scalable` AS `dynamically_scalable`, - `vm_template`.`state` AS `template_state`, - `vm_template`.`guest_os_id` AS `guest_os_id`, - `guest_os`.`uuid` AS `guest_os_uuid`, - `guest_os`.`display_name` AS `guest_os_name`, - `vm_template`.`bootable` AS `bootable`, - `vm_template`.`prepopulate` AS `prepopulate`, - `vm_template`.`cross_zones` AS `cross_zones`, - `vm_template`.`hypervisor_type` AS `hypervisor_type`, - `vm_template`.`extractable` AS `extractable`, - `vm_template`.`template_tag` AS `template_tag`, - `vm_template`.`sort_key` AS `sort_key`, - `vm_template`.`removed` AS `removed`, - `vm_template`.`enable_sshkey` AS `enable_sshkey`, - `parent_template`.`id` AS `parent_template_id`, - `parent_template`.`uuid` AS `parent_template_uuid`, - `source_template`.`id` AS `source_template_id`, - `source_template`.`uuid` AS `source_template_uuid`, - `account`.`id` AS `account_id`, - `account`.`uuid` AS `account_uuid`, - `account`.`account_name` AS `account_name`, - `account`.`type` AS `account_type`, - `domain`.`id` AS `domain_id`, - `domain`.`uuid` AS `domain_uuid`, - `domain`.`name` AS `domain_name`, - `domain`.`path` AS `domain_path`, - `projects`.`id` AS `project_id`, - `projects`.`uuid` AS `project_uuid`, - `projects`.`name` AS `project_name`, - `data_center`.`id` AS `data_center_id`, - `data_center`.`uuid` AS `data_center_uuid`, - `data_center`.`name` AS `data_center_name`, - `launch_permission`.`account_id` AS `lp_account_id`, - `template_store_ref`.`store_id` AS `store_id`, - `image_store`.`scope` AS `store_scope`, - `template_store_ref`.`state` AS `state`, - `template_store_ref`.`download_state` AS `download_state`, - `template_store_ref`.`download_pct` AS `download_pct`, - `template_store_ref`.`error_str` AS `error_str`, - `template_store_ref`.`size` AS `size`, - `template_store_ref`.physical_size AS `physical_size`, - `template_store_ref`.`destroyed` AS `destroyed`, - `template_store_ref`.`created` AS `created_on_store`, - `vm_template_details`.`name` AS `detail_name`, - `vm_template_details`.`value` AS `detail_value`, - `resource_tags`.`id` AS `tag_id`, - `resource_tags`.`uuid` AS `tag_uuid`, - `resource_tags`.`key` AS `tag_key`, - `resource_tags`.`value` AS `tag_value`, - `resource_tags`.`domain_id` AS `tag_domain_id`, - `domain`.`uuid` AS `tag_domain_uuid`, - `domain`.`name` AS `tag_domain_name`, - `resource_tags`.`account_id` AS `tag_account_id`, - `account`.`account_name` AS `tag_account_name`, - `resource_tags`.`resource_id` AS `tag_resource_id`, - `resource_tags`.`resource_uuid` AS `tag_resource_uuid`, - `resource_tags`.`resource_type` AS `tag_resource_type`, - `resource_tags`.`customer` AS `tag_customer`, - CONCAT(`vm_template`.`id`, - '_', - IFNULL(`data_center`.`id`, 0)) AS `temp_zone_pair`, - `vm_template`.`direct_download` AS `direct_download`, - `vm_template`.`deploy_as_is` AS `deploy_as_is` - FROM - (((((((((((((`vm_template` - JOIN `guest_os` ON ((`guest_os`.`id` = `vm_template`.`guest_os_id`))) - JOIN `account` ON ((`account`.`id` = `vm_template`.`account_id`))) - JOIN `domain` ON ((`domain`.`id` = `account`.`domain_id`))) - LEFT JOIN `projects` ON ((`projects`.`project_account_id` = `account`.`id`))) - LEFT JOIN `vm_template_details` ON ((`vm_template_details`.`template_id` = `vm_template`.`id`))) - LEFT JOIN `vm_template` `source_template` ON ((`source_template`.`id` = `vm_template`.`source_template_id`))) - LEFT JOIN `template_store_ref` ON (((`template_store_ref`.`template_id` = `vm_template`.`id`) - AND (`template_store_ref`.`store_role` = 'Image') - AND (`template_store_ref`.`destroyed` = 0)))) - LEFT JOIN `vm_template` `parent_template` ON ((`parent_template`.`id` = `vm_template`.`parent_template_id`))) - LEFT JOIN `image_store` ON ((ISNULL(`image_store`.`removed`) - AND (`template_store_ref`.`store_id` IS NOT NULL) - AND (`image_store`.`id` = `template_store_ref`.`store_id`)))) - LEFT JOIN `template_zone_ref` ON (((`template_zone_ref`.`template_id` = `vm_template`.`id`) - AND ISNULL(`template_store_ref`.`store_id`) - AND ISNULL(`template_zone_ref`.`removed`)))) - LEFT JOIN `data_center` ON (((`image_store`.`data_center_id` = `data_center`.`id`) - OR (`template_zone_ref`.`zone_id` = `data_center`.`id`)))) - LEFT JOIN `launch_permission` ON ((`launch_permission`.`template_id` = `vm_template`.`id`))) - LEFT JOIN `resource_tags` ON (((`resource_tags`.`resource_id` = `vm_template`.`id`) - AND ((`resource_tags`.`resource_type` = 'Template') - OR (`resource_tags`.`resource_type` = 'ISO'))))); -- Add mincpu, maxcpu, minmemory and maxmemory to the view supporting constrained offerings DROP VIEW IF EXISTS `cloud`.`service_offering_view`; diff --git a/engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/TemplateServiceImpl.java b/engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/TemplateServiceImpl.java index ed9359d952a..a10aa203ebb 100644 --- a/engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/TemplateServiceImpl.java +++ b/engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/TemplateServiceImpl.java @@ -412,7 +412,7 @@ public class TemplateServiceImpl implements TemplateService { VirtualMachineTemplate.Event event = VirtualMachineTemplate.Event.OperationSucceeded; // For multi-disk OVA, check and create data disk templates if (tmplt.getFormat().equals(ImageFormat.OVA)) { - if (!createOvaDataDiskTemplates(_templateFactory.getTemplate(tmlpt.getId(), store), tmplt.isDeployAsIs())) { + if (!createOvaDataDiskTemplates(_templateFactory.getTemplate(tmlpt.getId(), store), true)) { event = VirtualMachineTemplate.Event.OperationFailed; } } @@ -710,7 +710,7 @@ public class TemplateServiceImpl implements TemplateService { // For multi-disk OVA, check and create data disk templates if (template.getFormat().equals(ImageFormat.OVA)) { - if (!createOvaDataDiskTemplates(template, template.isDeployAsIs())) { + if (!createOvaDataDiskTemplates(template, true)) { template.processEvent(ObjectInDataStoreStateMachine.Event.OperationFailed); result.setResult(callbackResult.getResult()); if (parentCallback != null) { @@ -799,7 +799,7 @@ public class TemplateServiceImpl implements TemplateService { String templateName = dataDiskTemplate.isIso() ? dataDiskTemplate.getPath().substring(dataDiskTemplate.getPath().lastIndexOf(File.separator) + 1) : template.getName() + suffix + diskCount; VMTemplateVO templateVO = new VMTemplateVO(templateId, templateName, format, false, false, false, ttype, template.getUrl(), template.requiresHvm(), template.getBits(), template.getAccountId(), null, templateName, false, guestOsId, false, template.getHypervisorType(), null, - null, false, false, false, false); + null, false, false, false); if (dataDiskTemplate.isIso()){ templateVO.setUniqueName(templateName); } diff --git a/engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/store/TemplateObject.java b/engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/store/TemplateObject.java index b7a44cd4f08..6d7ebebdc1d 100644 --- a/engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/store/TemplateObject.java +++ b/engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/store/TemplateObject.java @@ -376,10 +376,10 @@ public class TemplateObject implements TemplateInfo { @Override public boolean isDeployAsIs() { - if (this.imageVO == null) { - return false; + if (getHypervisorType() == HypervisorType.VMware) { + return true; } - return this.imageVO.isDeployAsIs(); + return false; } public void setInstallPath(String installPath) { diff --git a/engine/storage/src/main/java/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java b/engine/storage/src/main/java/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java index 37a7985ce6f..340347fc6f6 100644 --- a/engine/storage/src/main/java/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java +++ b/engine/storage/src/main/java/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java @@ -32,6 +32,7 @@ import java.util.stream.Collectors; import javax.inject.Inject; +import com.cloud.hypervisor.Hypervisor; import com.cloud.storage.Upload; import org.apache.cloudstack.storage.image.deployasis.DeployAsIsHelper; import org.apache.log4j.Logger; @@ -203,7 +204,7 @@ public abstract class BaseImageStoreDriverImpl implements ImageStoreDriver { TemplateDataStoreVO tmpltStoreVO = _templateStoreDao.findByStoreTemplate(store.getId(), obj.getId()); if (tmpltStoreVO != null) { if (tmpltStoreVO.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) { - if (template.isDeployAsIs()) { + if (template.getHypervisorType() == Hypervisor.HypervisorType.VMware) { boolean persistDeployAsIs = deployAsIsHelper.persistTemplateDeployAsIsDetails(template.getId(), answer, tmpltStoreVO); if (!persistDeployAsIs) { LOGGER.info("Failed persisting deploy-as-is template details for template " + template.getName()); diff --git a/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeObject.java b/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeObject.java index 45509c51c43..d40b30903ee 100644 --- a/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeObject.java +++ b/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeObject.java @@ -21,7 +21,6 @@ import java.util.Date; import javax.inject.Inject; import com.cloud.storage.MigrationOptions; -import com.cloud.storage.VMTemplateVO; import com.cloud.storage.VolumeDetailVO; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VolumeDetailsDao; @@ -446,8 +445,7 @@ public class VolumeObject implements VolumeInfo { @Override public boolean isDeployAsIs() { - VMTemplateVO template = templateDao.findById(getTemplateId()); - return template != null && template.isDeployAsIs(); + return getHypervisorType() == HypervisorType.VMware; } @Override diff --git a/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java index 3ccb7be8f60..53a36ede6bd 100644 --- a/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java +++ b/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java @@ -575,7 +575,7 @@ public class VolumeServiceImpl implements VolumeService { s_logger.info("Unable to acquire lock on VMTemplateStoragePool " + templatePoolRefId); } templatePoolRef = _tmpltPoolDao.findByPoolTemplate(dataStore.getId(), template.getId(), deployAsIsConfiguration); - if (templatePoolRef != null && templatePoolRef.getState() == ObjectInDataStoreStateMachine.State.Ready && !template.isDeployAsIs()) { + if (templatePoolRef != null && templatePoolRef.getState() == ObjectInDataStoreStateMachine.State.Ready) { s_logger.info( "Unable to acquire lock on VMTemplateStoragePool " + templatePoolRefId + ", But Template " + template.getUniqueName() + " is already copied to primary storage, skip copying"); createVolumeFromBaseImageAsync(volume, templateOnPrimaryStoreObj, dataStore, future); @@ -588,7 +588,7 @@ public class VolumeServiceImpl implements VolumeService { s_logger.info("lock is acquired for VMTemplateStoragePool " + templatePoolRefId); } try { - if (templatePoolRef.getState() == ObjectInDataStoreStateMachine.State.Ready && !template.isDeployAsIs()) { + if (templatePoolRef.getState() == ObjectInDataStoreStateMachine.State.Ready) { s_logger.info("Template " + template.getUniqueName() + " is already copied to primary storage, skip copying"); createVolumeFromBaseImageAsync(volume, templateOnPrimaryStoreObj, dataStore, future); return; diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java index d48a5d9b101..6e301985f83 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java @@ -598,7 +598,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co private VMTemplateVO createVMTemplateRecord(String vmInternalName, long guestOsId, long accountId) { Long nextTemplateId = vmTemplateDao.getNextInSequence(Long.class, "id"); VMTemplateVO templateVO = new VMTemplateVO(nextTemplateId, "Imported-from-" + vmInternalName, Storage.ImageFormat.OVA, false, false, false, Storage.TemplateType.USER, null, - false, 64, accountId, null, "Template imported from VM " + vmInternalName, false, guestOsId, false, HypervisorType.VMware, null, null, false, false, false, false); + false, 64, accountId, null, "Template imported from VM " + vmInternalName, false, guestOsId, false, HypervisorType.VMware, null, null, false, false, false); return vmTemplateDao.persist(templateVO); } diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VmwareVmImplementer.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VmwareVmImplementer.java index c12c5c20e2d..6638d769df8 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VmwareVmImplementer.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VmwareVmImplementer.java @@ -105,7 +105,7 @@ class VmwareVmImplementer { VirtualMachineTO implement(VirtualMachineProfile vm, VirtualMachineTO to, long clusterId) { to.setBootloader(VirtualMachineTemplate.BootloaderType.HVM); - boolean deployAsIs = vm.getTemplate().isDeployAsIs(); + boolean deployAsIs = vm.getType() == VirtualMachine.Type.User; HostVO host = hostDao.findById(vm.getVirtualMachine().getHostId()); Map details = to.getDetails(); if (details == null) diff --git a/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java index eb99a8eefe3..51d589fcd81 100644 --- a/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java +++ b/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java @@ -561,7 +561,7 @@ StateListener { * Display storage in the logs by default if the template is not deploy-as-is. */ private boolean getDisplayStorageFromVmProfile(VirtualMachineProfile vmProfile) { - return vmProfile == null || vmProfile.getTemplate() == null || !vmProfile.getTemplate().isDeployAsIs(); + return vmProfile.getHypervisorType() != HypervisorType.VMware || vmProfile.getType() != VirtualMachine.Type.User; } @Override diff --git a/server/src/main/java/com/cloud/storage/ImageStoreUploadMonitorImpl.java b/server/src/main/java/com/cloud/storage/ImageStoreUploadMonitorImpl.java index 1ce5b362eb9..5174b2613ab 100755 --- a/server/src/main/java/com/cloud/storage/ImageStoreUploadMonitorImpl.java +++ b/server/src/main/java/com/cloud/storage/ImageStoreUploadMonitorImpl.java @@ -412,7 +412,7 @@ public class ImageStoreUploadMonitorImpl extends ManagerBase implements ImageSto if (tmpTemplate.getFormat().equals(Storage.ImageFormat.OVA)) { final DataStore store = dataStoreManager.getDataStore(templateDataStore.getDataStoreId(), templateDataStore.getDataStoreRole()); final TemplateInfo templateInfo = templateFactory.getTemplate(tmpTemplate.getId(), store); - if (!templateService.createOvaDataDiskTemplates(templateInfo, template.isDeployAsIs())) { + if (!templateService.createOvaDataDiskTemplates(templateInfo, true)) { tmpTemplateDataStore.setDownloadState(VMTemplateStorageResourceAssoc.Status.ABANDONED); tmpTemplateDataStore.setState(State.Failed); stateMachine.transitTo(tmpTemplate, VirtualMachineTemplate.Event.OperationFailed, null, _templateDao); diff --git a/server/src/main/java/com/cloud/storage/TemplateProfile.java b/server/src/main/java/com/cloud/storage/TemplateProfile.java index b90409480bc..304b652a589 100644 --- a/server/src/main/java/com/cloud/storage/TemplateProfile.java +++ b/server/src/main/java/com/cloud/storage/TemplateProfile.java @@ -52,7 +52,6 @@ public class TemplateProfile { Boolean isDynamicallyScalable; TemplateType templateType; Boolean directDownload; - Boolean deployAsIs; Long size; public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm, String url, @@ -96,7 +95,7 @@ public class TemplateProfile { Boolean isPublic, Boolean featured, Boolean isExtractable, ImageFormat format, Long guestOsId, List zoneId, HypervisorType hypervisorType, String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, String templateTag, Map details, - Boolean sshKeyEnabled, Long imageStoreId, Boolean isDynamicallyScalable, TemplateType templateType, Boolean directDownload, Boolean deployAsIs) { + Boolean sshKeyEnabled, Long imageStoreId, Boolean isDynamicallyScalable, TemplateType templateType, Boolean directDownload) { this(templateId, userId, name, @@ -123,7 +122,6 @@ public class TemplateProfile { this.isDynamicallyScalable = isDynamicallyScalable; this.templateType = templateType; this.directDownload = directDownload; - this.deployAsIs = deployAsIs; } public Long getTemplateId() { @@ -333,8 +331,4 @@ public class TemplateProfile { public void setSize(Long size) { this.size = size; } - - public boolean isDeployAsIs() { - return this.deployAsIs; - } } diff --git a/server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java b/server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java index 18d37d0b8ad..c080ffd2f25 100644 --- a/server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java +++ b/server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java @@ -601,10 +601,8 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { // Remove template details templateDetailsDao.removeDetails(template.getId()); - // Remove deploy-as-is details - if (template.isDeployAsIs()) { - templateDeployAsIsDetailsDao.removeDetails(template.getId()); - } + // Remove deploy-as-is details (if any) + templateDeployAsIsDetailsDao.removeDetails(template.getId()); } return success; diff --git a/server/src/main/java/com/cloud/template/TemplateAdapterBase.java b/server/src/main/java/com/cloud/template/TemplateAdapterBase.java index 45a10a8c4b3..9cd2b6f791c 100644 --- a/server/src/main/java/com/cloud/template/TemplateAdapterBase.java +++ b/server/src/main/java/com/cloud/template/TemplateAdapterBase.java @@ -265,7 +265,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat CallContext.current().setEventDetails("Id: " + id + " name: " + name); return new TemplateProfile(id, userId, name, displayText, bits, passwordEnabled, requiresHVM, url, isPublic, featured, isExtractable, imgfmt, guestOSId, zoneIdList, hypervisorType, templateOwner.getAccountName(), templateOwner.getDomainId(), templateOwner.getAccountId(), chksum, bootable, templateTag, details, - sshkeyEnabled, null, isDynamicallyScalable, templateType, directDownload, deployAsIs); + sshkeyEnabled, null, isDynamicallyScalable, templateType, directDownload); } @@ -376,7 +376,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat new VMTemplateVO(profile.getTemplateId(), profile.getName(), profile.getFormat(), profile.isPublic(), profile.isFeatured(), profile.isExtractable(), profile.getTemplateType(), profile.getUrl(), profile.isRequiresHVM(), profile.getBits(), profile.getAccountId(), profile.getCheckSum(), profile.getDisplayText(), profile.isPasswordEnabled(), profile.getGuestOsId(), profile.isBootable(), profile.getHypervisorType(), - profile.getTemplateTag(), profile.getDetails(), profile.isSshKeyEnabled(), profile.IsDynamicallyScalable(), profile.isDirectDownload(), profile.isDeployAsIs()); + profile.getTemplateTag(), profile.getDetails(), profile.isSshKeyEnabled(), profile.IsDynamicallyScalable(), profile.isDirectDownload()); template.setState(initialState); if (profile.isDirectDownload()) { diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java index c58b2f1ad9a..519072272dd 100755 --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java @@ -1898,7 +1898,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, } privateTemplate = new VMTemplateVO(nextTemplateId, name, ImageFormat.RAW, isPublic, featured, isExtractable, TemplateType.USER, null, requiresHvmValue, bitsValue, templateOwner.getId(), null, description, - passwordEnabledValue, guestOS.getId(), true, hyperType, templateTag, cmd.getDetails(), sshKeyEnabledValue, isDynamicScalingEnabled, false, false); + passwordEnabledValue, guestOS.getId(), true, hyperType, templateTag, cmd.getDetails(), sshKeyEnabledValue, isDynamicScalingEnabled, false); if (sourceTemplateId != null) { if (s_logger.isDebugEnabled()) { diff --git a/server/src/test/java/com/cloud/vm/DeploymentPlanningManagerImplTest.java b/server/src/test/java/com/cloud/vm/DeploymentPlanningManagerImplTest.java index d356570b633..71a6935a7d8 100644 --- a/server/src/test/java/com/cloud/vm/DeploymentPlanningManagerImplTest.java +++ b/server/src/test/java/com/cloud/vm/DeploymentPlanningManagerImplTest.java @@ -29,7 +29,6 @@ import javax.inject.Inject; import javax.naming.ConfigurationException; import com.cloud.host.Host; -import com.cloud.storage.VMTemplateVO; import com.cloud.storage.dao.VMTemplateDao; import org.apache.cloudstack.affinity.dao.AffinityGroupDomainMapDao; import org.junit.Before; @@ -167,10 +166,6 @@ public class DeploymentPlanningManagerImplTest { Mockito.when(_plannerHostReserveDao.findById(Matchers.anyLong())).thenReturn(reservationVO); Mockito.when(_affinityGroupVMMapDao.countAffinityGroupsForVm(Matchers.anyLong())).thenReturn(0L); - VMTemplateVO template = Mockito.mock(VMTemplateVO.class); - Mockito.when(template.isDeployAsIs()).thenReturn(false); - Mockito.when(templateDao.findById(Mockito.anyLong())).thenReturn(template); - VMInstanceVO vm = new VMInstanceVO(); Mockito.when(vmProfile.getVirtualMachine()).thenReturn(vm);