Skip to content

Commit

Permalink
Merge pull request #280 from dosaboy/add-cinder-attachment-cleanup
Browse files Browse the repository at this point in the history
Add cinder volume attachment cleanup script
  • Loading branch information
rodrigogansobarbieri authored Dec 10, 2024
2 parents 3066940 + 4dc970d commit 8bd2196
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 8bd2196

Please sign in to comment.