OpenStack: Volume

openstack volume type list --public --long
openstack volume backend pool list
cinder --os-volume-api-version 3.50 attachment-delete <attachment_id>
 
openstack volume set --non-bootable <VOLUME_ID>

Search for multiple volume attachment ids

# search for double attachments
openstack volume list --all-projects -c ID -c "Attached to" | egrep "Attached.*Attached"
 
# search in DB
DB_PASS=$(grep nova_database_password /etc/kolla/passwords.yml | cut -d " " -f2)
 
mysql -h db.service.example.com --password=${DB_PASS} -P 3306 -u nova -D nova -e "
    select *
    FROM block_device_mapping
    where attachment_id in (
        SELECT attachment_id
        FROM block_device_mapping
        where attachment_id is not null
        and deleted = 0
        group by attachment_id
        having count(*) > 1
    )
"
 
# SQL
mysql -h db.service.example.com --password=${DB_PASS} -P 3306 -u nova -D nova -e "select * from block_device_mapping"  | grep 1234567890-1111-33333-a400-111111111111
mysql -h db.service.example.com --password=${DB_PASS} -P 3306 -u nova -D nova -e "select * from block_device_mapping where volume_id = '1234567890-1111-33333-a400-111111111111"
 
SELECT volume_id
FROM block_device_mapping
where volume_id is not null
and deleted = 0
group by volume_id
having count(*) > 1

(Force) delete volume

cinder reset-state --state available --attach-status detached ${VOLUME_ID}
openstack volume delete ${VOLUME_ID}