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:
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.
|
// Perform a regular reboot in case it's necessary and haven't already been done.
|
||||||
if reboot {
|
if reboot {
|
||||||
rebootTimeout := d.Get(mkResourceVirtualEnvironmentVMTimeoutReboot).(int)
|
vmStatus, err := vmAPI.GetVMStatus(ctx)
|
||||||
|
|
||||||
err := vmAPI.RebootVM(
|
|
||||||
ctx,
|
|
||||||
&vms.RebootRequestBody{
|
|
||||||
Timeout: &rebootTimeout,
|
|
||||||
},
|
|
||||||
rebootTimeout+30,
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
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)
|
return vmRead(ctx, d, m)
|
||||||
|
Loading…
Reference in New Issue
Block a user