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

fix(vm): better check for disk ownership (#633)

Storage using .raw or .qcow2 files uses additional element in path,
which is not present in ZFS storage.
Support both patterns when determining disk ownership.

This fixes #632

Signed-off-by: Oto Petřík <oto.petrik@gmail.com>
This commit is contained in:
Oto Petřík 2023-10-22 17:11:19 +02:00 committed by GitHub
parent 3db98718c6
commit 6753582e4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -224,7 +224,17 @@ func (r CustomStorageDevice) IsOwnedBy(vmID int) bool {
return false
}
return strings.HasPrefix(*pathInDatastore, fmt.Sprintf("vm-%d-", vmID))
// ZFS uses "local-zfs:vm-123-disk-0"
if strings.HasPrefix(*pathInDatastore, fmt.Sprintf("vm-%d-", vmID)) {
return true
}
// directory uses "local:123/vm-123-disk-0"
if strings.HasPrefix(*pathInDatastore, fmt.Sprintf("%d/vm-%d-", vmID, vmID)) {
return true
}
return false
}
// CustomStorageDevices handles QEMU SATA device parameters.