Skip to content

Commit

Permalink
Fix VM selection in clean-e2e.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
mquhuy committed Feb 1, 2024
1 parent 53281e6 commit 84dcd85
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
13 changes: 1 addition & 12 deletions hack/clean-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,10 @@ REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
cd "${REPO_ROOT}" || exit 1

minikube delete
docker rm -f vbmc
docker rm -f image-server-e2e
docker rm -f sushy-tools

virsh_vms=$(virsh list --name --all)

for vm in ${virsh_vms}; do
if [[ "${vm}" =~ "bmo-e2e-" ]]; then
virsh -c qemu:///system destroy --domain "${vm}"
virsh -c qemu:///system undefine --domain "${vm}" --nvram --remove-all-storage
fi
done

virsh -c qemu:///system net-destroy baremetal-e2e
virsh -c qemu:///system net-undefine baremetal-e2e
"${REPO_ROOT}/tools/bmh_test/clean_local_bmh_test_setup.sh" "^bmo-e2e-"

rm -rf "${REPO_ROOT}/test/e2e/_artifacts"
rm -rf "${REPO_ROOT}"/artifacts-*
Expand Down
10 changes: 5 additions & 5 deletions tools/bmh_test/clean_local_bmh_test_setup.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#!/usr/bin/env bash

set -eux
set -ux

BMH_NAME_REGEX="${1:-^bmh-test-}"
# Get a list of all virtual machines
VM_LIST=$(virsh -c qemu:///system list --all --name | grep '^bmh-test-') || true
VM_LIST=$(virsh -c qemu:///system list --all --name | grep "${BMH_NAME_REGEX}")

if [[ -n "${VM_LIST}" ]]; then
# Loop through the list and delete each virtual machine
for vm_name in ${VM_LIST}; do
virsh -c qemu:///system destroy --domain "${vm_name}"
virsh -c qemu:///system undefine --domain "${vm_name}" --remove-all-storage
kubectl delete baremetalhost "${vm_name}" || true
kubectl delete baremetalhost "${vm_name}"
done
else
echo "No virtual machines found. Skipping..."
fi

# Clear vbmc
docker stop vbmc
docker rm vbmc
docker rm -f vbmc

# Clear network
virsh -c qemu:///system net-destroy baremetal-e2e
Expand Down

0 comments on commit 84dcd85

Please sign in to comment.