mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-04 04:22:59 +00:00
fix(vm): cloned VM with efi_disk
got re-created at re-apply (#447)
Also fixes for startup order (not released yet).
This commit is contained in:
parent
a3b95c8053
commit
c1e7cea21e
@ -1225,15 +1225,6 @@ func VM() *schema.Resource {
|
|||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Description: "Defines startup and shutdown behavior of the VM",
|
Description: "Defines startup and shutdown behavior of the VM",
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: func() (interface{}, error) {
|
|
||||||
return []interface{}{
|
|
||||||
map[string]interface{}{
|
|
||||||
mkResourceVirtualEnvironmentVMStartupOrder: dvResourceVirtualEnvironmentVMStartupOrder,
|
|
||||||
mkResourceVirtualEnvironmentVMVGAMemory: dvResourceVirtualEnvironmentVMVGAMemory,
|
|
||||||
mkResourceVirtualEnvironmentVMVGAType: dvResourceVirtualEnvironmentVMVGAType,
|
|
||||||
},
|
|
||||||
}, nil
|
|
||||||
},
|
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
mkResourceVirtualEnvironmentVMStartupOrder: {
|
mkResourceVirtualEnvironmentVMStartupOrder: {
|
||||||
@ -3657,9 +3648,11 @@ func vmReadCustom(
|
|||||||
|
|
||||||
currentEfiDisk := d.Get(mkResourceVirtualEnvironmentVMEFIDisk).([]interface{})
|
currentEfiDisk := d.Get(mkResourceVirtualEnvironmentVMEFIDisk).([]interface{})
|
||||||
|
|
||||||
if len(clone) > 0 && len(currentEfiDisk) > 0 {
|
if len(clone) > 0 {
|
||||||
|
if len(currentEfiDisk) > 0 {
|
||||||
err := d.Set(mkResourceVirtualEnvironmentVMEFIDisk, []interface{}{efiDisk})
|
err := d.Set(mkResourceVirtualEnvironmentVMEFIDisk, []interface{}{efiDisk})
|
||||||
diags = append(diags, diag.FromErr(err)...)
|
diags = append(diags, diag.FromErr(err)...)
|
||||||
|
}
|
||||||
} else if len(currentEfiDisk) > 0 ||
|
} else if len(currentEfiDisk) > 0 ||
|
||||||
efiDisk[mkResourceVirtualEnvironmentVMEFIDiskDatastoreID] != dvResourceVirtualEnvironmentVMEFIDiskDatastoreID ||
|
efiDisk[mkResourceVirtualEnvironmentVMEFIDiskDatastoreID] != dvResourceVirtualEnvironmentVMEFIDiskDatastoreID ||
|
||||||
efiDisk[mkResourceVirtualEnvironmentVMEFIDiskType] != dvResourceVirtualEnvironmentVMEFIDiskType ||
|
efiDisk[mkResourceVirtualEnvironmentVMEFIDiskType] != dvResourceVirtualEnvironmentVMEFIDiskType ||
|
||||||
@ -4145,10 +4138,12 @@ func vmReadCustom(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compare the startup order to the one stored in the state.
|
// Compare the startup order to the one stored in the state.
|
||||||
startup := map[string]interface{}{}
|
var startup map[string]interface{}
|
||||||
|
|
||||||
//nolint:nestif
|
//nolint:nestif
|
||||||
if vmConfig.StartupOrder != nil {
|
if vmConfig.StartupOrder != nil {
|
||||||
|
startup = map[string]interface{}{}
|
||||||
|
|
||||||
if vmConfig.StartupOrder.Order != nil {
|
if vmConfig.StartupOrder.Order != nil {
|
||||||
startup[mkResourceVirtualEnvironmentVMStartupOrder] = *vmConfig.StartupOrder.Order
|
startup[mkResourceVirtualEnvironmentVMStartupOrder] = *vmConfig.StartupOrder.Order
|
||||||
} else {
|
} else {
|
||||||
@ -4166,10 +4161,6 @@ func vmReadCustom(
|
|||||||
} else {
|
} else {
|
||||||
startup[mkResourceVirtualEnvironmentVMStartupDownDelay] = dvResourceVirtualEnvironmentVMStartupDownDelay
|
startup[mkResourceVirtualEnvironmentVMStartupDownDelay] = dvResourceVirtualEnvironmentVMStartupDownDelay
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
startup[mkResourceVirtualEnvironmentVMStartupOrder] = dvResourceVirtualEnvironmentVMStartupOrder
|
|
||||||
startup[mkResourceVirtualEnvironmentVMStartupUpDelay] = dvResourceVirtualEnvironmentVMStartupUpDelay
|
|
||||||
startup[mkResourceVirtualEnvironmentVMStartupDownDelay] = dvResourceVirtualEnvironmentVMStartupDownDelay
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentStartup := d.Get(mkResourceVirtualEnvironmentVMStartup).([]interface{})
|
currentStartup := d.Get(mkResourceVirtualEnvironmentVMStartup).([]interface{})
|
||||||
@ -4964,6 +4955,10 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
|
|||||||
rebootRequired = true
|
rebootRequired = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if d.HasChange(mkResourceVirtualEnvironmentVMStartup) {
|
||||||
|
updateBody.StartupOrder = vmGetStartupOrder(d)
|
||||||
|
}
|
||||||
|
|
||||||
// Prepare the new VGA configuration.
|
// Prepare the new VGA configuration.
|
||||||
if d.HasChange(mkResourceVirtualEnvironmentVMVGA) {
|
if d.HasChange(mkResourceVirtualEnvironmentVMVGA) {
|
||||||
updateBody.VGADevice, e = vmGetVGADeviceObject(d)
|
updateBody.VGADevice, e = vmGetVGADeviceObject(d)
|
||||||
|
Loading…
Reference in New Issue
Block a user