0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-07-05 21:43:59 +00:00

fix(vm): do not reboot VM on config change if it is not running (#430)

This commit is contained in:
Pavel Boldyrev 2023-07-16 14:12:17 -04:00 committed by GitHub
parent a1d76441d5
commit 0281bc83e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5035,18 +5035,25 @@ func vmUpdateDiskLocationAndSize(
// Perform a regular reboot in case it's necessary and haven't already been done.
if reboot {
rebootTimeout := d.Get(mkResourceVirtualEnvironmentVMTimeoutReboot).(int)
err := vmAPI.RebootVM(
ctx,
&vms.RebootRequestBody{
Timeout: &rebootTimeout,
},
rebootTimeout+30,
)
vmStatus, err := vmAPI.GetVMStatus(ctx)
if err != nil {
return diag.FromErr(err)
}
if vmStatus.Status != "stopped" {
rebootTimeout := d.Get(mkResourceVirtualEnvironmentVMTimeoutReboot).(int)
err := vmAPI.RebootVM(
ctx,
&vms.RebootRequestBody{
Timeout: &rebootTimeout,
},
rebootTimeout+30,
)
if err != nil {
return diag.FromErr(err)
}
}
}
return vmRead(ctx, d, m)