Skip to content

Commit

Permalink
Add cinder volume attachment cleanup script
Browse files Browse the repository at this point in the history
  • Loading branch information
dosaboy committed Dec 4, 2024
1 parent 510a665 commit 01ba1d9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tools/cleanup-cinder-attachments.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash -u
for vol in $(openstack volume list| grep juju| grep in-use| awk '{print $2}'); do
echo "Finding attachments for in-use volume $vol"
for server in $(openstack volume attachment list --os-volume-api-version 3.27 --volume-id $vol -c 'Server ID' -f value); do
openstack server show $server && continue
echo "Deleting attachments for volume $vol from (non-existent) server $server"
for id in $(openstack volume attachment list --os-volume-api-version 3.27 --volume-id $vol -c 'ID' -f value); do
openstack volume attachment delete --os-volume-api-version 3.27 $id
done
done
done

0 comments on commit 01ba1d9

Please sign in to comment.