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:
parent
3db98718c6
commit
6753582e4b
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user