0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-07-01 19:12:59 +00:00

fix(vm): hostpci devices not showing up in refresh plan (#578)

* bug(vm): fix hostpci devices not showing up in refresh plan

Signed-off-by: Michael Iseli <michael.iseli@bsi-software.com>

* fix pci & usb devices set on read, fix test

Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>

---------

Signed-off-by: Michael Iseli <michael.iseli@bsi-software.com>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
Michael Iseli 2023-12-18 04:28:33 +01:00 committed by GitHub
parent 3e0ef1d08b
commit aa939c731f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 9 deletions

View File

@ -133,12 +133,7 @@ func TestCustomPCIDevice_UnmarshalJSON(t *testing.T) {
name: "id only pci device",
line: `"0000:81:00.2"`,
want: &CustomPCIDevice{
DeviceIDs: &[]string{"0000:81:00.2"},
MDev: nil,
PCIExpress: types.BoolPtr(false),
ROMBAR: types.BoolPtr(true),
ROMFile: nil,
XVGA: types.BoolPtr(false),
DeviceIDs: &[]string{"0000:81:00.2"},
},
},
{
@ -176,6 +171,7 @@ func TestCustomPCIDevice_UnmarshalJSON(t *testing.T) {
if err := r.UnmarshalJSON([]byte(tt.line)); (err != nil) != tt.wantErr {
t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr)
}
require.Equal(t, tt.want, r)
})
}
}

View File

@ -4364,7 +4364,7 @@ func vmReadCustom(
if pp.ROMBAR != nil {
pci[mkResourceVirtualEnvironmentVMHostPCIDeviceROMBAR] = *pp.ROMBAR
} else {
pci[mkResourceVirtualEnvironmentVMHostPCIDeviceROMBAR] = false
pci[mkResourceVirtualEnvironmentVMHostPCIDeviceROMBAR] = true
}
if pp.ROMFile != nil {
@ -4388,7 +4388,7 @@ func vmReadCustom(
pciMap[pi] = pci
}
if len(currentPCIList) > 0 {
if len(clone) == 0 || len(currentPCIList) > 0 {
orderedPCIList := orderedListFromMap(pciMap)
err := d.Set(mkResourceVirtualEnvironmentVMHostPCI, orderedPCIList)
diags = append(diags, diag.FromErr(err)...)
@ -4426,7 +4426,7 @@ func vmReadCustom(
usbMap[pi] = usb
}
if len(currentUSBList) > 0 {
if len(clone) == 0 || len(currentUSBList) > 0 {
// todo: reordering of devices by PVE may cause an issue here
orderedUSBList := orderedListFromMap(usbMap)
err := d.Set(mkResourceVirtualEnvironmentVMHostUSB, orderedUSBList)