mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-08-22 19:38:35 +00:00
fix(vm): regression: mac_addresses
list is missing some interfaces (#1049)
* fix(vm): regression: `mac_addresses` list is missing some interfaces Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> * add acceptance test Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --------- Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
079119444d
commit
518e25efaf
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -8,7 +8,7 @@
|
|||||||
"mode": "test",
|
"mode": "test",
|
||||||
"program": "${workspaceFolder}/fwprovider/tests",
|
"program": "${workspaceFolder}/fwprovider/tests",
|
||||||
"envFile": "${workspaceFolder}/testacc.env",
|
"envFile": "${workspaceFolder}/testacc.env",
|
||||||
"args": ["-debug", "-test.v", "-test.timeout", "30s"]
|
"args": ["-debug", "-test.v", "-test.timeout", "120s"]
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -80,6 +80,93 @@ func TestAccResourceVM(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAccResourceVMNetwork(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
step resource.TestStep
|
||||||
|
}{
|
||||||
|
{"network interfaces mac", resource.TestStep{
|
||||||
|
Config: `
|
||||||
|
resource "proxmox_virtual_environment_file" "cloud_config" {
|
||||||
|
content_type = "snippets"
|
||||||
|
datastore_id = "local"
|
||||||
|
node_name = "pve"
|
||||||
|
source_raw {
|
||||||
|
data = <<EOF
|
||||||
|
#cloud-config
|
||||||
|
runcmd:
|
||||||
|
- apt update
|
||||||
|
- apt install -y qemu-guest-agent
|
||||||
|
- systemctl enable qemu-guest-agent
|
||||||
|
- systemctl start qemu-guest-agent
|
||||||
|
EOF
|
||||||
|
file_name = "cloud-config.yaml"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "proxmox_virtual_environment_vm" "test_vm_network1" {
|
||||||
|
node_name = "pve"
|
||||||
|
started = true
|
||||||
|
agent {
|
||||||
|
enabled = true
|
||||||
|
}
|
||||||
|
cpu {
|
||||||
|
cores = 2
|
||||||
|
}
|
||||||
|
memory {
|
||||||
|
dedicated = 2048
|
||||||
|
}
|
||||||
|
disk {
|
||||||
|
datastore_id = "local-lvm"
|
||||||
|
file_id = proxmox_virtual_environment_download_file.ubuntu_cloud_image.id
|
||||||
|
interface = "virtio0"
|
||||||
|
iothread = true
|
||||||
|
discard = "on"
|
||||||
|
size = 20
|
||||||
|
}
|
||||||
|
initialization {
|
||||||
|
ip_config {
|
||||||
|
ipv4 {
|
||||||
|
address = "dhcp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
user_data_file_id = proxmox_virtual_environment_file.cloud_config.id
|
||||||
|
}
|
||||||
|
network_device {
|
||||||
|
bridge = "vmbr0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "proxmox_virtual_environment_download_file" "ubuntu_cloud_image" {
|
||||||
|
content_type = "iso"
|
||||||
|
datastore_id = "local"
|
||||||
|
node_name = "pve"
|
||||||
|
url = "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
|
||||||
|
}`,
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
resource.TestCheckResourceAttr("proxmox_virtual_environment_vm.test_vm_network1", "ipv4_addresses.#", "2"),
|
||||||
|
resource.TestCheckResourceAttr("proxmox_virtual_environment_vm.test_vm_network1", "mac_addresses.#", "2"),
|
||||||
|
),
|
||||||
|
}},
|
||||||
|
}
|
||||||
|
|
||||||
|
accProviders := testAccMuxProviders(context.Background(), t)
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
tt := tt
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
ProtoV6ProviderFactories: accProviders,
|
||||||
|
Steps: []resource.TestStep{tt.step},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestAccResourceVMDisks(t *testing.T) {
|
func TestAccResourceVMDisks(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
@ -518,7 +518,7 @@ func Container() *schema.Resource {
|
|||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
Sensitive: true,
|
Sensitive: true,
|
||||||
Default: dvInitializationUserAccountPassword,
|
Default: dvInitializationUserAccountPassword,
|
||||||
DiffSuppressFunc: func(k, oldVal, newVal string, d *schema.ResourceData) bool {
|
DiffSuppressFunc: func(k, oldVal, _ string, _ *schema.ResourceData) bool {
|
||||||
return len(oldVal) > 0 &&
|
return len(oldVal) > 0 &&
|
||||||
strings.ReplaceAll(oldVal, "*", "") == ""
|
strings.ReplaceAll(oldVal, "*", "") == ""
|
||||||
},
|
},
|
||||||
@ -604,7 +604,7 @@ func Container() *schema.Resource {
|
|||||||
// // PVE strips leading slashes from the path, so we have to do the same
|
// // PVE strips leading slashes from the path, so we have to do the same
|
||||||
// return strings.TrimPrefix(i.(string), "/")
|
// return strings.TrimPrefix(i.(string), "/")
|
||||||
// },
|
// },
|
||||||
DiffSuppressFunc: func(k, oldVal, newVal string, d *schema.ResourceData) bool {
|
DiffSuppressFunc: func(_, oldVal, newVal string, _ *schema.ResourceData) bool {
|
||||||
return "/"+oldVal == newVal
|
return "/"+oldVal == newVal
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -691,7 +691,7 @@ func Container() *schema.Resource {
|
|||||||
Description: "The MAC address",
|
Description: "The MAC address",
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: dvNetworkInterfaceMACAddress,
|
Default: dvNetworkInterfaceMACAddress,
|
||||||
DiffSuppressFunc: func(k, oldVal, newVal string, d *schema.ResourceData) bool {
|
DiffSuppressFunc: func(_, _, newVal string, _ *schema.ResourceData) bool {
|
||||||
return newVal == ""
|
return newVal == ""
|
||||||
},
|
},
|
||||||
ValidateDiagFunc: validator.MACAddress(),
|
ValidateDiagFunc: validator.MACAddress(),
|
||||||
|
@ -5169,6 +5169,9 @@ func vmReadNetworkValues(
|
|||||||
networkInterfaceNames[ri] = rv.Name
|
networkInterfaceNames[ri] = rv.Name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = d.Set(mkMACAddresses, macAddresses)
|
||||||
|
diags = append(diags, diag.FromErr(err)...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user