Merge "Disable selinux on RHEL case"
[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 if [ $CLEAN_DIB_IMAGES = "true" ]; then
31     rm -rf /httpboot/*
32     rm -rf /tftpboot/*
33 fi
34
35 # remove VM disk images
36 rm -rf /var/lib/libvirt/images/*.qcow2
37
38 echo "restarting services"
39 service libvirtd restart
40 service ironic-api restart
41 service ironic-conductor start
42 service ironic-inspector restart