Moving destroyvms function

This commit is contained in:
Guillaume 2023-06-14 23:51:59 +02:00
parent b5734a4b0f
commit 3769192fec
3 changed files with 20 additions and 12 deletions

View File

@ -7,16 +7,6 @@ stopdls() {
fi fi
} }
destroyvms() {
for host in ${!hosts[*]}; do
if test -f $ctxdir/data/$host/pid ; then
pid=$(cat $ctxdir/data/$host/pid)
pinfo "Cleaning VM $host with PID $pid..."
kill $pid && sleep 1
fi
done
}
cleanuppaths() { cleanuppaths() {
PATHS="data secrets kubeconfig cache dist" PATHS="data secrets kubeconfig cache dist"
cd $ctxdir cd $ctxdir
@ -29,6 +19,7 @@ cleanuppaths() {
} }
cleanupssh() { cleanupssh() {
set -x
for host in ${!hosts[*]}; do for host in ${!hosts[*]}; do
ssh-keygen -R ${hosts[$host]} &>/dev/null ssh-keygen -R ${hosts[$host]} &>/dev/null
done done
@ -55,6 +46,6 @@ stopdls
declare -A hosts declare -A hosts
get_hosts get_hosts
destroyvms destroyvms
cleanuppaths #cleanuppaths
cleanupssh cleanupssh
cleanupnetwork #cleanupnetwork

View File

@ -119,3 +119,17 @@ create_kubeconfig() {
} }
destroyvms() {
for host in ${!hosts[*]}; do
if test -f $ctxdir/data/$host/pid ; then
pid=$(cat $ctxdir/data/$host/pid)
if ! test -d /proc/$pid ; then
pinfo "VM $host seems not running"
else
pinfo "Cleaning VM $host with PID $pid..."
kill $pid && sleep 1
fi
fi
done
}

View File

@ -37,6 +37,7 @@ setup_network_qemu() {
echo "allow $QEMU_BR_NAME" >> /etc/qemu/bridge.conf echo "allow $QEMU_BR_NAME" >> /etc/qemu/bridge.conf
fi fi
} }
run_qemu() { run_qemu() {
id=1 id=1
for host in ${!hosts[*]}; do for host in ${!hosts[*]}; do
@ -54,6 +55,8 @@ run_qemu() {
} }
# # # # # # # # # # # # # # # #
source $(dirname $0)/.common source $(dirname $0)/.common
check_root check_root
prereqs prereqs