Skip to content

Commit

Permalink
Ensure non default high availibility and autopoweron settings for VMs…
Browse files Browse the repository at this point in the history
… work (#252)

* Set the ha and autopoweron options while creating vms

This fixes  #209

* Use non default values first during test that verifies VM modifications without a reboot

---------

Co-authored-by: 4censord <[email protected]>
  • Loading branch information
ddelnano and 4censord authored Jul 19, 2023
1 parent fbf416c commit 2473ebb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions client/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,12 @@ func (c *Client) CreateVm(vmReq Vm, createTime time.Duration) (*Vm, error) {
"existingDisks": existingDisks,
// TODO: (#145) Uncomment this once issues with secure_boot have been figured out
// "secureBoot": vmReq.SecureBoot,
"expNestedHvm": vmReq.ExpNestedHvm,
"VDIs": vdis,
"VIFs": vmReq.VIFsMap,
"tags": vmReq.Tags,
"expNestedHvm": vmReq.ExpNestedHvm,
"VDIs": vdis,
"VIFs": vmReq.VIFsMap,
"tags": vmReq.Tags,
"auto_poweron": vmReq.AutoPoweron,
"high_availability": vmReq.HA,
}

videoram := vmReq.Videoram.Value
Expand Down
2 changes: 2 additions & 0 deletions xoa/resource_xenorchestra_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ func resourceVmCreate(d *schema.ResourceData, m interface{}) error {
Template: d.Get("template").(string),
CloudConfig: d.Get("cloud_config").(string),
ResourceSet: rs,
HA: d.Get("high_availability").(string),
AutoPoweron: d.Get("auto_poweron").(bool),
CPUs: client.CPUs{
Number: d.Get("cpus").(int),
},
Expand Down
8 changes: 4 additions & 4 deletions xoa/resource_xenorchestra_vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1148,12 +1148,12 @@ func TestAccXenorchestraVm_updatesWithoutReboot(t *testing.T) {

origNameLabel := fmt.Sprintf("%s - orig label (%s)", accTestPrefix, t.Name())
origNameDesc := "name label"
origHa := ""
origPowerOn := false
origHa := "restart"
origPowerOn := true
updatedNameLabel := fmt.Sprintf("%s - updated label (%s)", accTestPrefix, t.Name())
updatedNameDesc := "Terraform Updated description"
updatedHa := "restart"
updatedPowerOn := true
updatedHa := ""
updatedPowerOn := false
affinityHost := accTestPool.Master
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down

0 comments on commit 2473ebb

Please sign in to comment.