blob: f6eca4e3192b6ea32d2284edc18e476b8aba48de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#!/bin/bash
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2016 RedHat and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
# We need to execute everything as root
if [[ $(whoami) != "root" ]]; then
echo "Error: This script must be run as root!"
exit 1
fi
# Start fresh
rm -rf /opt/stack
# HOME is normally set by sudo -H
rm -rf ${HOME}/.config/openstack
# bifrost installs everything on venv so we need to look there if virtualbmc is not installed on the host.
if which vbmc &>/dev/null || { [[ -e /opt/stack/bifrost/bin/activate ]] && source /opt/stack/bifrost/bin/activate; }; then
# Delete all libvirt VMs and hosts from vbmc (look for a port number)
for vm in $(vbmc list | awk '/[0-9]/{{ print $2 }}'); do
virsh destroy $vm || true
virsh undefine $vm || true
vbmc delete $vm
done
which vbmc &>/dev/null || { [[ -e /opt/stack/bifrost/bin/activate ]] && deactivate; }
fi
# Destroy all XCI VMs if the previous operation failed
[[ -n ${XCI_FLAVOR} ]] && \
for vm in ${TEST_VM_NODE_NAMES}; do
virsh destroy $vm || true
virsh undefine $vm || true
done
service ironic-conductor stop || true
echo "removing inventory files created by previous builds"
rm -rf /tmp/baremetal.*
echo "removing ironic database"
if $(which mysql &> /dev/null); then
mysql -u root ironic --execute "drop database ironic;"
fi
echo "removing leases"
[[ -e /var/lib/misc/dnsmasq/dnsmasq.leases ]] && > /var/lib/misc/dnsmasq/dnsmasq.leases
echo "removing logs"
rm -rf /var/log/libvirt/baremetal_logs/*
# clean up dib images only if requested explicitly
CLEAN_DIB_IMAGES=${CLEAN_DIB_IMAGES:-false}
if [ $CLEAN_DIB_IMAGES = "true" ]; then
rm -rf /httpboot /tftpboot
mkdir /httpboot /tftpboot
chmod -R 755 /httpboot /tftpboot
fi
# remove VM disk images
rm -rf /var/lib/libvirt/images/*.qcow2
echo "restarting services"
service dnsmasq restart || true
service libvirtd restart
service ironic-api restart || true
service ironic-conductor start || true
service ironic-inspector restart || true
|