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

fix(vm): set FileVolume for disks with file_id (#635)

Disks imported using `file_id` argument do not have FileVolume set,
that makes PathInDatastore return an empty string, which makes
IsOwnedBy return fales for any vm id.

The end result is the inability to resize imported disks,
this fixes it.

Signed-off-by: Oto Petřík <oto.petrik@gmail.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
Oto Petřík 2023-10-22 17:15:44 +02:00 committed by GitHub
parent 6753582e4b
commit d1d7bd39c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3053,17 +3053,17 @@ func vmGetDiskDeviceObjects(
} }
if fileID != "" { if fileID != "" {
diskDevice.Enabled = false diskDevice.Enabled = false
} else { }
if pathInDatastore != "" {
if datastoreID != "" { if pathInDatastore != "" {
diskDevice.FileVolume = fmt.Sprintf("%s:%s", datastoreID, pathInDatastore) if datastoreID != "" {
} else { diskDevice.FileVolume = fmt.Sprintf("%s:%s", datastoreID, pathInDatastore)
// FileVolume is absolute path in the host filesystem
diskDevice.FileVolume = pathInDatastore
}
} else { } else {
diskDevice.FileVolume = fmt.Sprintf("%s:%d", datastoreID, size) // FileVolume is absolute path in the host filesystem
diskDevice.FileVolume = pathInDatastore
} }
} else {
diskDevice.FileVolume = fmt.Sprintf("%s:%d", datastoreID, size)
} }
diskDevice.ID = &datastoreID diskDevice.ID = &datastoreID