Filter volumes per availability zone
# Using openstack-cli with jq (Since openstack-cli isn't able to filter or show the az)
AZ="zone" ; for volume_id in $(openstack volume list -fvalue --quote=none --all-projects --sort-column=ID -cID); do openstack volume show -fjson "${volume_id}" | jq -r '. | select(.availability_zone == "'"${AZ}"'") | "\(.id)"'; done
# Using cinder-cli which has the option to show the az, but can't filter if using volumev2
AZ="zone" ; cinder --os-volume-api-version=2 list --all-tenants --sort id:asc --fields id,availability_zone | grep "${AZ}" | awk '{print $2}'
# Get all instance ID's which are using an ephemeral image
openstack server list --all-projects --limit -1 --no-name-lookup --sort-column ID -fjson | jq -r '.[] | select(.Image != "") | "\(.ID)"'
Some useful links for scripting
https://github.com/stedolan/jq/wiki/Cookbook
https://lzone.de/cheat-sheet/jq