Is it possible to filter for volumes that are not attached to any instance and list them? For example, if I have a volume that looks like this:
config:
size: 5GiB
description: ""
name: testing-disk01
type: custom
used_by: []
location: none
content_type: block
project: default
created_at: 2023-11-25T00:34:45.159711339Z
I can see this volume when filtering on fields like content_type
and type
.
$ incus storage volume list default -fcompact 'content_type=block' 'type=custom'
TYPE NAME DESCRIPTION CONTENT-TYPE USED BY
custom testing-disk01 block 0
custom testing-disk02 block 1
custom testing-disk03 block 1
But trying to filter by the used_by
field doesnât appear to be supported.
$ incus storage volume list default -fcompact used_by=0
Error: Invalid type "slice" for field "used_by"
Which makes sense since the values for used_by
in the volumeâs config is indeed a slice/array. It looks like the filter (here) simply doesnât allow matching on slices. Only strings, integers, and booleans.
What Iâm trying to achieve is to get just the names of volumes that are not attached to an instance (something like used_by == []
). I can get what I want with awk:
$ incus storage volume list default -cnu -fcsv 'content_type=block' 'type=custom' | awk 'BEGIN { FS="," } $2==0 { print $1 }'
testing-disk01
But it would be nice if I can just add something like used_by=?
in the same incus command instead. Or if thereâs another subcommand that can do this with instead Iâd really appreciate any tips.
Thanks!