mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-01 11:02:59 +00:00
Fields `network_interface_names`, `ipv4_addresses` and `ipv6_addresses` are sometimes be marked `computed` again, using `CustomizeDiff`. Changes in `VMStarted` or `VMNetworkDevice` attributes invalidate those values. Marking fields `computed` again avoids stale values. `network_device` configuration block without `mac_address` results in MAC address set to its default value (an empty string). Terraform state expects `mac_address` to be an empty string, server provides the actual (random) MAC address of the network device. Terraform detects there are changes to be made, but because of `DiffSuppressFunc` on `mac_address` they are hidden from the user, but not from d.HasChange(mkResourceVirtualEnvironmentVMNetworkDevice) By making `mac_address` also `computed`, the server-generated MAC address is stored locally, avoiding spurious changes that trigger re-computation of `network_interface_names`, `ipv4_addresses` and `ipv6_addresses`.
This commit is contained in:
parent
ab54aa1092
commit
e15c4a6784
@ -84,7 +84,6 @@ const (
|
||||
dvResourceVirtualEnvironmentVMNetworkDeviceBridge = "vmbr0"
|
||||
dvResourceVirtualEnvironmentVMNetworkDeviceEnabled = true
|
||||
dvResourceVirtualEnvironmentVMNetworkDeviceFirewall = false
|
||||
dvResourceVirtualEnvironmentVMNetworkDeviceMACAddress = ""
|
||||
dvResourceVirtualEnvironmentVMNetworkDeviceModel = "virtio"
|
||||
dvResourceVirtualEnvironmentVMNetworkDeviceRateLimit = 0
|
||||
dvResourceVirtualEnvironmentVMNetworkDeviceVLANID = 0
|
||||
@ -994,13 +993,10 @@ func VM() *schema.Resource {
|
||||
Default: dvResourceVirtualEnvironmentVMNetworkDeviceFirewall,
|
||||
},
|
||||
mkResourceVirtualEnvironmentVMNetworkDeviceMACAddress: {
|
||||
Type: schema.TypeString,
|
||||
Description: "The MAC address",
|
||||
Optional: true,
|
||||
Default: dvResourceVirtualEnvironmentVMNetworkDeviceMACAddress,
|
||||
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
|
||||
return new == ""
|
||||
},
|
||||
Type: schema.TypeString,
|
||||
Description: "The MAC address",
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ValidateDiagFunc: getMACAddressValidator(),
|
||||
},
|
||||
mkResourceVirtualEnvironmentVMNetworkDeviceModel: {
|
||||
|
Loading…
Reference in New Issue
Block a user