From d1d7bd39c741d99b2395ef858bf739cb067f0542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oto=20Pet=C5=99=C3=ADk?= Date: Sun, 22 Oct 2023 17:15:44 +0200 Subject: [PATCH] fix(vm): set FileVolume for disks with file_id (#635) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --- proxmoxtf/resource/vm.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/proxmoxtf/resource/vm.go b/proxmoxtf/resource/vm.go index 802a76ba..0d981239 100644 --- a/proxmoxtf/resource/vm.go +++ b/proxmoxtf/resource/vm.go @@ -3053,17 +3053,17 @@ func vmGetDiskDeviceObjects( } if fileID != "" { diskDevice.Enabled = false - } else { - if pathInDatastore != "" { - if datastoreID != "" { - diskDevice.FileVolume = fmt.Sprintf("%s:%s", datastoreID, pathInDatastore) - } else { - // FileVolume is absolute path in the host filesystem - diskDevice.FileVolume = pathInDatastore - } + } + + if pathInDatastore != "" { + if datastoreID != "" { + diskDevice.FileVolume = fmt.Sprintf("%s:%s", datastoreID, pathInDatastore) } 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