Skip to content

Commit

Permalink
Shutdown VMs before destroying them
Browse files Browse the repository at this point in the history
This allows the VM to terminate its work properly.
  • Loading branch information
4censord committed Dec 9, 2022
1 parent 52012be commit c15010d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions xoa/resource_xenorchestra_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,14 @@ func resourceVmUpdate(d *schema.ResourceData, m interface{}) error {
func resourceVmDelete(d *schema.ResourceData, m interface{}) error {
c := m.(client.XOClient)

err := c.DeleteVm(d.Id())

vmReq := client.Vm{
Id: d.Id(),
}
err := c.HaltVm(vmReq)
if err != nil {
return err
}
err = c.DeleteVm(d.Id())
if err != nil {
return err
}
Expand Down

0 comments on commit c15010d

Please sign in to comment.