dustin
/
zdotdir
Archived
1
0
Fork 0
This repository has been archived on 2023-11-14. You can view files and clone it, but cannot push or open issues/pull-requests.
zdotdir/functions/@testvm::cleanup

28 lines
627 B
Bash

# vim: set ft=zsh sw=4 ts=4 sts=4 et :
@testvm::cleanup() {
local destroy=false
local pattern='^fmos-[a-f0-9]{8}$'
while [ $# -gt 0 ]; do
case "$1" in
--destroy)
destroy=true
;;
*)
pattern="${1}"
;;
esac
shift
done
if ${destroy}; then
virsh list --name \
| awk "/${pattern}/{print}" \
| xargs -r -n1 virsh destroy
fi
virsh list --inactive --name \
| awk "/${pattern}/{print}" \
| xargs -r -n1 virsh undefine --remove-all-storage --nvram
}
@testvm::cleanup "$@"