mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-05 13:33:58 +00:00
fix(vm): do not reboot VM on config change if it is not running (#430)
This commit is contained in:
parent
a1d76441d5
commit
0281bc83e2
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user