f092a658af3d3798cb4e113fec42ac44d112b540
[releng.git] / prototypes / bifrost / scripts / destroy-env.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2016 RedHat and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10 virsh destroy jumphost.opnfvlocal || true
11 virsh destroy controller00.opnfvlocal || true
12 virsh destroy compute00.opnfvlocal || true
13 virsh undefine jumphost.opnfvlocal || true
14 virsh undefine controller00.opnfvlocal || true
15 virsh undefine compute00.opnfvlocal || true
16
17 service ironic-conductor stop
18
19 echo "removing from database"
20 mysql -u root ironic --execute "truncate table ports;"
21 mysql -u root ironic --execute "delete from node_tags;"
22 mysql -u root ironic --execute "delete from nodes;"
23 mysql -u root ironic --execute "delete from conductors;"
24 echo "removing leases"
25 > /var/lib/dnsmasq/dnsmasq.leases
26 echo "removing logs"
27 rm -rf /var/log/libvirt/baremetal_logs/*.log
28
29 # clean up dib images only if requested explicitly
30 CLEAN_DIB_IMAGES=${CLEAN_DIB_IMAGES:-false}
31
32 if [ $CLEAN_DIB_IMAGES = "true" ]; then
33     rm -rf /httpboot/*
34     rm -rf /tftpboot/*
35 fi
36
37 # remove VM disk images
38 rm -rf /var/lib/libvirt/images/*.qcow2
39
40 echo "restarting services"
41 service libvirtd restart
42 service ironic-api restart
43 service ironic-conductor start
44 service ironic-inspector restart