mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Revert back deploy as is column on templates but keep it as default for new templates
This commit is contained in:
parent
08c0b07b59
commit
94bebe8792
@ -138,4 +138,6 @@ public interface VirtualMachineTemplate extends ControlledEntity, Identity, Inte
|
|||||||
void incrUpdatedCount();
|
void incrUpdatedCount();
|
||||||
|
|
||||||
Date getUpdated();
|
Date getUpdated();
|
||||||
|
|
||||||
|
boolean isDeployAsIs();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1112,7 +1112,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
|
|
||||||
if (dest != null) {
|
if (dest != null) {
|
||||||
avoids.addHost(dest.getHost().getId());
|
avoids.addHost(dest.getHost().getId());
|
||||||
if (template.getHypervisorType() == HypervisorType.VMware && vm.getType() == VirtualMachine.Type.User) {
|
if (!template.isDeployAsIs()) {
|
||||||
journal.record("Deployment found ", vmProfile, dest);
|
journal.record("Deployment found ", vmProfile, dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -759,7 +759,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||||||
|
|
||||||
Long size = _tmpltMgr.getTemplateSize(template.getId(), vm.getDataCenterId());
|
Long size = _tmpltMgr.getTemplateSize(template.getId(), vm.getDataCenterId());
|
||||||
if (rootDisksize != null) {
|
if (rootDisksize != null) {
|
||||||
if (vm.getHypervisorType() == HypervisorType.VMware) {
|
if (template.isDeployAsIs()) {
|
||||||
// Volume size specified from template deploy-as-is
|
// Volume size specified from template deploy-as-is
|
||||||
size = rootDisksize;
|
size = rootDisksize;
|
||||||
} else {
|
} else {
|
||||||
@ -824,7 +824,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||||||
int volumesNumber = 1;
|
int volumesNumber = 1;
|
||||||
List<DatadiskTO> templateAsIsDisks = null;
|
List<DatadiskTO> templateAsIsDisks = null;
|
||||||
String configurationId = null;
|
String configurationId = null;
|
||||||
if (vm.getHypervisorType() == HypervisorType.VMware && vm.getType() == VirtualMachine.Type.User) {
|
if (template.isDeployAsIs()) {
|
||||||
UserVmDetailVO configurationDetail = userVmDetailsDao.findDetail(vm.getId(), VmDetailConstants.DEPLOY_AS_IS_CONFIGURATION);
|
UserVmDetailVO configurationDetail = userVmDetailsDao.findDetail(vm.getId(), VmDetailConstants.DEPLOY_AS_IS_CONFIGURATION);
|
||||||
if (configurationDetail != null) {
|
if (configurationDetail != null) {
|
||||||
configurationId = configurationDetail.getValue();
|
configurationId = configurationDetail.getValue();
|
||||||
@ -849,7 +849,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||||||
String volumeName = name;
|
String volumeName = name;
|
||||||
Long volumeSize = rootDisksize;
|
Long volumeSize = rootDisksize;
|
||||||
long deviceId = type.equals(Type.ROOT) ? 0L : 1L;
|
long deviceId = type.equals(Type.ROOT) ? 0L : 1L;
|
||||||
if (vm.getHypervisorType() == HypervisorType.VMware && vm.getType() == VirtualMachine.Type.User) {
|
if (template.isDeployAsIs()) {
|
||||||
int volumeNameSuffix = templateAsIsDisks.get(number).getDiskNumber();
|
int volumeNameSuffix = templateAsIsDisks.get(number).getDiskNumber();
|
||||||
volumeName = String.format("%s-%d", volumeName, volumeNameSuffix);
|
volumeName = String.format("%s-%d", volumeName, volumeNameSuffix);
|
||||||
volumeSize = templateAsIsDisks.get(number).getVirtualSize();
|
volumeSize = templateAsIsDisks.get(number).getVirtualSize();
|
||||||
|
|||||||
@ -152,6 +152,9 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
|||||||
@Column(name = "parent_template_id")
|
@Column(name = "parent_template_id")
|
||||||
private Long parentTemplateId;
|
private Long parentTemplateId;
|
||||||
|
|
||||||
|
@Column(name = "deploy_as_is")
|
||||||
|
private boolean deployAsIs;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUniqueName() {
|
public String getUniqueName() {
|
||||||
return uniqueName;
|
return uniqueName;
|
||||||
@ -193,7 +196,8 @@ 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,
|
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<String, String> details, boolean sshKeyEnabled, boolean isDynamicallyScalable, boolean directDownload) {
|
HypervisorType hyperType, String templateTag, Map<String, String> details, boolean sshKeyEnabled, boolean isDynamicallyScalable, boolean directDownload,
|
||||||
|
boolean deployAsIs) {
|
||||||
this(id,
|
this(id,
|
||||||
name,
|
name,
|
||||||
format,
|
format,
|
||||||
@ -218,6 +222,7 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
|||||||
dynamicallyScalable = isDynamicallyScalable;
|
dynamicallyScalable = isDynamicallyScalable;
|
||||||
state = State.Active;
|
state = State.Active;
|
||||||
this.directDownload = directDownload;
|
this.directDownload = directDownload;
|
||||||
|
this.deployAsIs = deployAsIs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VMTemplateVO createPreHostIso(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic, boolean featured, TemplateType type,
|
public static VMTemplateVO createPreHostIso(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic, boolean featured, TemplateType type,
|
||||||
@ -635,4 +640,12 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
|||||||
public void setParentTemplateId(Long parentTemplateId) {
|
public void setParentTemplateId(Long parentTemplateId) {
|
||||||
this.parentTemplateId = parentTemplateId;
|
this.parentTemplateId = parentTemplateId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public boolean isDeployAsIs() {
|
||||||
|
return deployAsIs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeployAsIs(boolean deployAsIs) {
|
||||||
|
this.deployAsIs = deployAsIs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -261,6 +261,116 @@ CREATE VIEW `cloud`.`storage_pool_view` AS
|
|||||||
AND (`async_job`.`instance_type` = 'StoragePool')
|
AND (`async_job`.`instance_type` = 'StoragePool')
|
||||||
AND (`async_job`.`job_status` = 0))));
|
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';
|
||||||
|
|
||||||
|
-- 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
|
-- Add mincpu, maxcpu, minmemory and maxmemory to the view supporting constrained offerings
|
||||||
DROP VIEW IF EXISTS `cloud`.`service_offering_view`;
|
DROP VIEW IF EXISTS `cloud`.`service_offering_view`;
|
||||||
CREATE VIEW `cloud`.`service_offering_view` AS
|
CREATE VIEW `cloud`.`service_offering_view` AS
|
||||||
|
|||||||
@ -412,7 +412,7 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
VirtualMachineTemplate.Event event = VirtualMachineTemplate.Event.OperationSucceeded;
|
VirtualMachineTemplate.Event event = VirtualMachineTemplate.Event.OperationSucceeded;
|
||||||
// For multi-disk OVA, check and create data disk templates
|
// For multi-disk OVA, check and create data disk templates
|
||||||
if (tmplt.getFormat().equals(ImageFormat.OVA)) {
|
if (tmplt.getFormat().equals(ImageFormat.OVA)) {
|
||||||
if (!createOvaDataDiskTemplates(_templateFactory.getTemplate(tmlpt.getId(), store), true)) {
|
if (!createOvaDataDiskTemplates(_templateFactory.getTemplate(tmlpt.getId(), store), tmplt.isDeployAsIs())) {
|
||||||
event = VirtualMachineTemplate.Event.OperationFailed;
|
event = VirtualMachineTemplate.Event.OperationFailed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -710,7 +710,7 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
|
|
||||||
// For multi-disk OVA, check and create data disk templates
|
// For multi-disk OVA, check and create data disk templates
|
||||||
if (template.getFormat().equals(ImageFormat.OVA)) {
|
if (template.getFormat().equals(ImageFormat.OVA)) {
|
||||||
if (!createOvaDataDiskTemplates(template, true)) {
|
if (!createOvaDataDiskTemplates(template, template.isDeployAsIs())) {
|
||||||
template.processEvent(ObjectInDataStoreStateMachine.Event.OperationFailed);
|
template.processEvent(ObjectInDataStoreStateMachine.Event.OperationFailed);
|
||||||
result.setResult(callbackResult.getResult());
|
result.setResult(callbackResult.getResult());
|
||||||
if (parentCallback != null) {
|
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;
|
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(),
|
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,
|
template.requiresHvm(), template.getBits(), template.getAccountId(), null, templateName, false, guestOsId, false, template.getHypervisorType(), null,
|
||||||
null, false, false, false);
|
null, false, false, false, false);
|
||||||
if (dataDiskTemplate.isIso()){
|
if (dataDiskTemplate.isIso()){
|
||||||
templateVO.setUniqueName(templateName);
|
templateVO.setUniqueName(templateName);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -376,10 +376,10 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeployAsIs() {
|
public boolean isDeployAsIs() {
|
||||||
if (getHypervisorType() == HypervisorType.VMware) {
|
if (this.imageVO == null) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return this.imageVO.isDeployAsIs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInstallPath(String installPath) {
|
public void setInstallPath(String installPath) {
|
||||||
|
|||||||
@ -32,7 +32,6 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import com.cloud.hypervisor.Hypervisor;
|
|
||||||
import com.cloud.storage.Upload;
|
import com.cloud.storage.Upload;
|
||||||
import org.apache.cloudstack.storage.image.deployasis.DeployAsIsHelper;
|
import org.apache.cloudstack.storage.image.deployasis.DeployAsIsHelper;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
@ -204,7 +203,7 @@ public abstract class BaseImageStoreDriverImpl implements ImageStoreDriver {
|
|||||||
TemplateDataStoreVO tmpltStoreVO = _templateStoreDao.findByStoreTemplate(store.getId(), obj.getId());
|
TemplateDataStoreVO tmpltStoreVO = _templateStoreDao.findByStoreTemplate(store.getId(), obj.getId());
|
||||||
if (tmpltStoreVO != null) {
|
if (tmpltStoreVO != null) {
|
||||||
if (tmpltStoreVO.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
|
if (tmpltStoreVO.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
|
||||||
if (template.getHypervisorType() == Hypervisor.HypervisorType.VMware) {
|
if (template.isDeployAsIs()) {
|
||||||
boolean persistDeployAsIs = deployAsIsHelper.persistTemplateDeployAsIsDetails(template.getId(), answer, tmpltStoreVO);
|
boolean persistDeployAsIs = deployAsIsHelper.persistTemplateDeployAsIsDetails(template.getId(), answer, tmpltStoreVO);
|
||||||
if (!persistDeployAsIs) {
|
if (!persistDeployAsIs) {
|
||||||
LOGGER.info("Failed persisting deploy-as-is template details for template " + template.getName());
|
LOGGER.info("Failed persisting deploy-as-is template details for template " + template.getName());
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import java.util.Date;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import com.cloud.storage.MigrationOptions;
|
import com.cloud.storage.MigrationOptions;
|
||||||
|
import com.cloud.storage.VMTemplateVO;
|
||||||
import com.cloud.storage.VolumeDetailVO;
|
import com.cloud.storage.VolumeDetailVO;
|
||||||
import com.cloud.storage.dao.VMTemplateDao;
|
import com.cloud.storage.dao.VMTemplateDao;
|
||||||
import com.cloud.storage.dao.VolumeDetailsDao;
|
import com.cloud.storage.dao.VolumeDetailsDao;
|
||||||
@ -445,7 +446,8 @@ public class VolumeObject implements VolumeInfo {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeployAsIs() {
|
public boolean isDeployAsIs() {
|
||||||
return getHypervisorType() == HypervisorType.VMware;
|
VMTemplateVO template = templateDao.findById(getTemplateId());
|
||||||
|
return template != null && template.isDeployAsIs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -598,7 +598,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
|||||||
private VMTemplateVO createVMTemplateRecord(String vmInternalName, long guestOsId, long accountId) {
|
private VMTemplateVO createVMTemplateRecord(String vmInternalName, long guestOsId, long accountId) {
|
||||||
Long nextTemplateId = vmTemplateDao.getNextInSequence(Long.class, "id");
|
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,
|
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, 64, accountId, null, "Template imported from VM " + vmInternalName, false, guestOsId, false, HypervisorType.VMware, null, null, false, false, false, false);
|
||||||
return vmTemplateDao.persist(templateVO);
|
return vmTemplateDao.persist(templateVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -105,7 +105,7 @@ class VmwareVmImplementer {
|
|||||||
|
|
||||||
VirtualMachineTO implement(VirtualMachineProfile vm, VirtualMachineTO to, long clusterId) {
|
VirtualMachineTO implement(VirtualMachineProfile vm, VirtualMachineTO to, long clusterId) {
|
||||||
to.setBootloader(VirtualMachineTemplate.BootloaderType.HVM);
|
to.setBootloader(VirtualMachineTemplate.BootloaderType.HVM);
|
||||||
boolean deployAsIs = true;
|
boolean deployAsIs = vm.getTemplate().isDeployAsIs();
|
||||||
HostVO host = hostDao.findById(vm.getVirtualMachine().getHostId());
|
HostVO host = hostDao.findById(vm.getVirtualMachine().getHostId());
|
||||||
Map<String, String> details = to.getDetails();
|
Map<String, String> details = to.getDetails();
|
||||||
if (details == null)
|
if (details == null)
|
||||||
|
|||||||
@ -253,7 +253,7 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation<Templa
|
|||||||
}
|
}
|
||||||
|
|
||||||
templateResponse.setDirectDownload(template.isDirectDownload());
|
templateResponse.setDirectDownload(template.isDirectDownload());
|
||||||
templateResponse.setDeployAsIs(template.getHypervisorType() == HypervisorType.VMware);
|
templateResponse.setDeployAsIs(template.isDeployAsIs());
|
||||||
templateResponse.setRequiresHvm(template.isRequiresHvm());
|
templateResponse.setRequiresHvm(template.isRequiresHvm());
|
||||||
|
|
||||||
//set template children disks
|
//set template children disks
|
||||||
@ -277,7 +277,7 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation<Templa
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setDeployAsIsDetails(TemplateJoinVO template, TemplateResponse templateResponse) {
|
private void setDeployAsIsDetails(TemplateJoinVO template, TemplateResponse templateResponse) {
|
||||||
if (template.getHypervisorType() == HypervisorType.VMware) {
|
if (template.isDeployAsIs()) {
|
||||||
List<TemplateDeployAsIsDetailVO> deployAsIsDetails = templateDeployAsIsDetailsDao.listDetails(template.getId());
|
List<TemplateDeployAsIsDetailVO> deployAsIsDetails = templateDeployAsIsDetailsDao.listDetails(template.getId());
|
||||||
for (TemplateDeployAsIsDetailVO deployAsIsDetailVO : deployAsIsDetails) {
|
for (TemplateDeployAsIsDetailVO deployAsIsDetailVO : deployAsIsDetails) {
|
||||||
if (deployAsIsDetailVO.getName().startsWith(DeployAsIsConstants.HARDWARE_ITEM_PREFIX)) {
|
if (deployAsIsDetailVO.getName().startsWith(DeployAsIsConstants.HARDWARE_ITEM_PREFIX)) {
|
||||||
|
|||||||
@ -231,6 +231,9 @@ public class TemplateJoinVO extends BaseViewWithTagInformationVO implements Cont
|
|||||||
@Column(name = "direct_download")
|
@Column(name = "direct_download")
|
||||||
private boolean directDownload;
|
private boolean directDownload;
|
||||||
|
|
||||||
|
@Column(name = "deploy_as_is")
|
||||||
|
private boolean deployAsIs;
|
||||||
|
|
||||||
public TemplateJoinVO() {
|
public TemplateJoinVO() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,6 +493,10 @@ public class TemplateJoinVO extends BaseViewWithTagInformationVO implements Cont
|
|||||||
return directDownload;
|
return directDownload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDeployAsIs() {
|
||||||
|
return deployAsIs;
|
||||||
|
}
|
||||||
|
|
||||||
public Object getParentTemplateId() {
|
public Object getParentTemplateId() {
|
||||||
return parentTemplateId;
|
return parentTemplateId;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -561,7 +561,7 @@ StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
|||||||
* Display storage in the logs by default if the template is not deploy-as-is.
|
* Display storage in the logs by default if the template is not deploy-as-is.
|
||||||
*/
|
*/
|
||||||
private boolean getDisplayStorageFromVmProfile(VirtualMachineProfile vmProfile) {
|
private boolean getDisplayStorageFromVmProfile(VirtualMachineProfile vmProfile) {
|
||||||
return vmProfile.getHypervisorType() != HypervisorType.VMware || vmProfile.getType() != VirtualMachine.Type.User;
|
return vmProfile == null || vmProfile.getTemplate() == null || !vmProfile.getTemplate().isDeployAsIs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -412,7 +412,7 @@ public class ImageStoreUploadMonitorImpl extends ManagerBase implements ImageSto
|
|||||||
if (tmpTemplate.getFormat().equals(Storage.ImageFormat.OVA)) {
|
if (tmpTemplate.getFormat().equals(Storage.ImageFormat.OVA)) {
|
||||||
final DataStore store = dataStoreManager.getDataStore(templateDataStore.getDataStoreId(), templateDataStore.getDataStoreRole());
|
final DataStore store = dataStoreManager.getDataStore(templateDataStore.getDataStoreId(), templateDataStore.getDataStoreRole());
|
||||||
final TemplateInfo templateInfo = templateFactory.getTemplate(tmpTemplate.getId(), store);
|
final TemplateInfo templateInfo = templateFactory.getTemplate(tmpTemplate.getId(), store);
|
||||||
if (!templateService.createOvaDataDiskTemplates(templateInfo, true)) {
|
if (!templateService.createOvaDataDiskTemplates(templateInfo, template.isDeployAsIs())) {
|
||||||
tmpTemplateDataStore.setDownloadState(VMTemplateStorageResourceAssoc.Status.ABANDONED);
|
tmpTemplateDataStore.setDownloadState(VMTemplateStorageResourceAssoc.Status.ABANDONED);
|
||||||
tmpTemplateDataStore.setState(State.Failed);
|
tmpTemplateDataStore.setState(State.Failed);
|
||||||
stateMachine.transitTo(tmpTemplate, VirtualMachineTemplate.Event.OperationFailed, null, _templateDao);
|
stateMachine.transitTo(tmpTemplate, VirtualMachineTemplate.Event.OperationFailed, null, _templateDao);
|
||||||
|
|||||||
@ -52,6 +52,7 @@ public class TemplateProfile {
|
|||||||
Boolean isDynamicallyScalable;
|
Boolean isDynamicallyScalable;
|
||||||
TemplateType templateType;
|
TemplateType templateType;
|
||||||
Boolean directDownload;
|
Boolean directDownload;
|
||||||
|
Boolean deployAsIs;
|
||||||
Long size;
|
Long size;
|
||||||
|
|
||||||
public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm, String url,
|
public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm, String url,
|
||||||
@ -95,7 +96,7 @@ public class TemplateProfile {
|
|||||||
Boolean isPublic, Boolean featured, Boolean isExtractable, ImageFormat format, Long guestOsId, List<Long> zoneId,
|
Boolean isPublic, Boolean featured, Boolean isExtractable, ImageFormat format, Long guestOsId, List<Long> zoneId,
|
||||||
|
|
||||||
HypervisorType hypervisorType, String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, String templateTag, Map details,
|
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 sshKeyEnabled, Long imageStoreId, Boolean isDynamicallyScalable, TemplateType templateType, Boolean directDownload, Boolean deployAsIs) {
|
||||||
this(templateId,
|
this(templateId,
|
||||||
userId,
|
userId,
|
||||||
name,
|
name,
|
||||||
@ -122,6 +123,7 @@ public class TemplateProfile {
|
|||||||
this.isDynamicallyScalable = isDynamicallyScalable;
|
this.isDynamicallyScalable = isDynamicallyScalable;
|
||||||
this.templateType = templateType;
|
this.templateType = templateType;
|
||||||
this.directDownload = directDownload;
|
this.directDownload = directDownload;
|
||||||
|
this.deployAsIs = deployAsIs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getTemplateId() {
|
public Long getTemplateId() {
|
||||||
@ -331,4 +333,8 @@ public class TemplateProfile {
|
|||||||
public void setSize(Long size) {
|
public void setSize(Long size) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDeployAsIs() {
|
||||||
|
return this.deployAsIs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -265,7 +265,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
|
|||||||
CallContext.current().setEventDetails("Id: " + id + " name: " + name);
|
CallContext.current().setEventDetails("Id: " + id + " name: " + name);
|
||||||
return new TemplateProfile(id, userId, name, displayText, bits, passwordEnabled, requiresHVM, url, isPublic, featured, isExtractable, imgfmt, guestOSId, zoneIdList,
|
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,
|
hypervisorType, templateOwner.getAccountName(), templateOwner.getDomainId(), templateOwner.getAccountId(), chksum, bootable, templateTag, details,
|
||||||
sshkeyEnabled, null, isDynamicallyScalable, templateType, directDownload);
|
sshkeyEnabled, null, isDynamicallyScalable, templateType, directDownload, deployAsIs);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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(),
|
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.getTemplateType(), profile.getUrl(), profile.isRequiresHVM(), profile.getBits(), profile.getAccountId(), profile.getCheckSum(),
|
||||||
profile.getDisplayText(), profile.isPasswordEnabled(), profile.getGuestOsId(), profile.isBootable(), profile.getHypervisorType(),
|
profile.getDisplayText(), profile.isPasswordEnabled(), profile.getGuestOsId(), profile.isBootable(), profile.getHypervisorType(),
|
||||||
profile.getTemplateTag(), profile.getDetails(), profile.isSshKeyEnabled(), profile.IsDynamicallyScalable(), profile.isDirectDownload());
|
profile.getTemplateTag(), profile.getDetails(), profile.isSshKeyEnabled(), profile.IsDynamicallyScalable(), profile.isDirectDownload(), profile.isDeployAsIs());
|
||||||
template.setState(initialState);
|
template.setState(initialState);
|
||||||
|
|
||||||
if (profile.isDirectDownload()) {
|
if (profile.isDirectDownload()) {
|
||||||
|
|||||||
@ -1898,7 +1898,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
|||||||
}
|
}
|
||||||
privateTemplate = new VMTemplateVO(nextTemplateId, name, ImageFormat.RAW, isPublic, featured, isExtractable,
|
privateTemplate = new VMTemplateVO(nextTemplateId, name, ImageFormat.RAW, isPublic, featured, isExtractable,
|
||||||
TemplateType.USER, null, requiresHvmValue, bitsValue, templateOwner.getId(), null, description,
|
TemplateType.USER, null, requiresHvmValue, bitsValue, templateOwner.getId(), null, description,
|
||||||
passwordEnabledValue, guestOS.getId(), true, hyperType, templateTag, cmd.getDetails(), sshKeyEnabledValue, isDynamicScalingEnabled, false);
|
passwordEnabledValue, guestOS.getId(), true, hyperType, templateTag, cmd.getDetails(), sshKeyEnabledValue, isDynamicScalingEnabled, false, false);
|
||||||
|
|
||||||
if (sourceTemplateId != null) {
|
if (sourceTemplateId != null) {
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
|||||||
@ -29,6 +29,7 @@ import javax.inject.Inject;
|
|||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
import com.cloud.host.Host;
|
import com.cloud.host.Host;
|
||||||
|
import com.cloud.storage.VMTemplateVO;
|
||||||
import com.cloud.storage.dao.VMTemplateDao;
|
import com.cloud.storage.dao.VMTemplateDao;
|
||||||
import org.apache.cloudstack.affinity.dao.AffinityGroupDomainMapDao;
|
import org.apache.cloudstack.affinity.dao.AffinityGroupDomainMapDao;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -166,6 +167,10 @@ public class DeploymentPlanningManagerImplTest {
|
|||||||
Mockito.when(_plannerHostReserveDao.findById(Matchers.anyLong())).thenReturn(reservationVO);
|
Mockito.when(_plannerHostReserveDao.findById(Matchers.anyLong())).thenReturn(reservationVO);
|
||||||
Mockito.when(_affinityGroupVMMapDao.countAffinityGroupsForVm(Matchers.anyLong())).thenReturn(0L);
|
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();
|
VMInstanceVO vm = new VMInstanceVO();
|
||||||
Mockito.when(vmProfile.getVirtualMachine()).thenReturn(vm);
|
Mockito.when(vmProfile.getVirtualMachine()).thenReturn(vm);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user