Skip to content

Commit

Permalink
Merge pull request #3620 from clnperez/libvirt-pool-cleanup
Browse files Browse the repository at this point in the history
maintenance: remove pools and volumes
  • Loading branch information
openshift-merge-robot committed Jan 26, 2021
2 parents 96de17b + 48fe5ed commit 95855a1
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions scripts/maintenance/virsh-cleanup.sh
Expand Up @@ -9,7 +9,6 @@ then
fi

CONNECT="${CONNECT:=qemu:///system}"
POOL="${POOL:=default}"

run()
{
Expand All @@ -23,13 +22,18 @@ do
run virsh -c "${CONNECT}" undefine "${DOMAIN}"
done

virsh -c "${CONNECT}" vol-list "${POOL}" | tail -n +3 | while read -r VOLUME _
for POOL in $(virsh -c "${CONNECT}" pool-list --all --name)
do
if test -z "${VOLUME}"
then
continue
fi
run virsh -c "${CONNECT}" vol-delete --pool "${POOL}" "${VOLUME}"
virsh -c "${CONNECT}" vol-list "${POOL}" | tail -n +3 | while read -r VOLUME _
do
if test -z "${VOLUME}"
then
continue
fi
run virsh -c "${CONNECT}" vol-delete --pool "${POOL}" "${VOLUME}"
done
run virsh -c "${CONNECT}" pool-destroy "${POOL}"
run virsh -c "${CONNECT}" pool-undefine "${POOL}"
done

for NET in $(virsh -c "${CONNECT}" net-list --all --name)
Expand Down

0 comments on commit 95855a1

Please sign in to comment.