Skip to content

Commit

Permalink
Add warning log message that indicates a user requested a fast clone,…
Browse files Browse the repository at this point in the history
… but that wasn't compatible with their disk template choice
  • Loading branch information
ddelnano committed Jan 15, 2024
1 parent 6793e08 commit 61296f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions client/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ func (c *Client) CreateVm(vmReq Vm, createTime time.Duration) (*Vm, error) {
"high_availability": vmReq.HA,
}

if !params["clone"].(bool) && vmReq.CloneType == CloneTypeFastClone {
fmt.Printf("[WARN] A fast clone was requested but falling back to full due to lack of disk template support\n")
}

destroyCloudConfigVdiAfterBoot := vmReq.DestroyCloudConfigVdiAfterBoot
if destroyCloudConfigVdiAfterBoot {
params["destroyCloudConfigVdiAfterBoot"] = destroyCloudConfigVdiAfterBoot
Expand Down
11 changes: 11 additions & 0 deletions xoa/resource_xenorchestra_vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ func TestAccXenorchestraVm_createWithTags(t *testing.T) {

func TestAccXenorchestraVm_createWithDisklessTemplateAndISO(t *testing.T) {
resourceName := "xenorchestra_vm.bar"
vdiDataSourceName := "data.xenorchestra_vdi.disk"
vmName := fmt.Sprintf("%s - %s", accTestPrefix, t.Name())
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -785,6 +786,16 @@ func TestAccXenorchestraVm_createWithDisklessTemplateAndISO(t *testing.T) {
internal.TestCheckTypeSetElemAttrPair(resourceName, "cdrom.0.*", "data.xenorchestra_vdi.iso", "id"),
),
},
{
Config: testAccVmConfigWithISO(vmName) + testAccVmDiskVDIDataSource(),
Check: resource.ComposeAggregateTestCheckFunc(
testAccVmExists(resourceName),
resource.TestCheckResourceAttrSet(resourceName, "id"),
resource.TestCheckResourceAttr(resourceName, "cdrom.#", "1"),
internal.TestCheckTypeSetElemAttrPair(resourceName, "cdrom.0.*", "data.xenorchestra_vdi.iso", "id"),
resource.TestCheckResourceAttr(vdiDataSourceName, "parent", ""),
),
},
},
})
}
Expand Down

0 comments on commit 61296f8

Please sign in to comment.