diff --git a/src/components/CreateVmWizard/CreateVmWizard.js b/src/components/CreateVmWizard/CreateVmWizard.js index 21de29357d..0b1df2e53f 100644 --- a/src/components/CreateVmWizard/CreateVmWizard.js +++ b/src/components/CreateVmWizard/CreateVmWizard.js @@ -362,10 +362,16 @@ class CreateVmWizard extends React.Component { const canUserUseStorageDomain = !!dataCenterStorageDomainsList.find(sd => sd.id === disk.get('storageDomainId')) + /* + * To be consistent with webadmin VM creation from a template: + * - desktop: diskType forced to 'thin' (match storage allocation = Thin) + * - server: diskType as defined in the template (match storage allocation = Clone) + * - any other optimizedFor: follow server's logic + */ const diskType = // constrain to values from createDiskTypeList() - this.state.steps.basic.optimizedFor === 'desktop' + this.state.steps.basic.optimizedFor !== 'desktop' ? disk.get('sparse') ? 'thin' : 'pre' - : 'pre' + : 'thin' return { id: disk.get('attachmentId'), diff --git a/src/sagas/vmChanges.js b/src/sagas/vmChanges.js index 034995d679..446feb701f 100644 --- a/src/sagas/vmChanges.js +++ b/src/sagas/vmChanges.js @@ -198,23 +198,23 @@ function* composeProvisionSourceTemplate ({ vm, basic, disks }) { id: disk.id, } + // did the diskType change? 'thin' === sparse, 'pre' === !sparse + const templateDiskType = templateDisk.get('sparse') ? 'thin' : 'pre' + if (disk.diskType !== templateDiskType) { + changesToTemplateDisk.sparse = disk.diskType === 'thin' + changesToTemplateDisk.format = disk.diskType === 'thin' ? 'cow' : 'sparse' + } + // did the storage domain change? if (disk.storageDomainId !== templateDisk.get('storageDomainId')) { + vmRequiresClone = true changesToTemplateDisk.format = 'raw' changesToTemplateDisk.storage_domains = { storage_domain: [{ id: disk.storageDomainId }], } } - // did the diskType (disk's sparse ) change? 'thin' === sparse, 'pre' === !sparse - const templateDiskType = templateDisk.get('sparse') ? 'thin' : 'pre' - if (disk.diskType !== templateDiskType) { - changesToTemplateDisk.sparse = disk.diskType === 'thin' - } - if (Object.keys(changesToTemplateDisk).length > 1) { - vmRequiresClone = true - if (vmUpdates.disk_attachments) { // add another disk to clone vmUpdates.disk_attachments.disk_attachment.push({ disk: changesToTemplateDisk })