2 ##############################################################################
3 # Copyright (c) 2015 Tim Rozet (Red Hat), Dan Radez (Red Hat) 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 ##############################################################################
11 #Clean script to uninstall provisioning server for Apex
12 #author: Dan Radez (dradez@redhat.com)
13 #author: Tim Rozet (trozet@redhat.com)
17 source $CONFIG/lib/common-functions.sh
20 ovs_bridges="brbm brbm1 brbm2 brbm3"
21 # Clean off instack VM
22 virsh destroy instack 2> /dev/null || echo -n ''
23 virsh undefine instack --remove-all-storage 2> /dev/null || echo -n ''
24 if ! virsh vol-delete instack.qcow2 --pool default 2> /dev/null; then
25 if [ ! -e /var/lib/libvirt/images/instack.qcow2 ]; then
26 /usr/bin/touch /var/lib/libvirt/images/instack.qcow2
27 virsh vol-delete instack.qcow2 --pool default
31 rm -f /var/lib/libvirt/images/instack.qcow2 2> /dev/null
33 # Clean off baremetal VMs in case they exist
34 for i in $(seq 0 $vm_index); do
35 virsh destroy baremetalbrbm_brbm1_brbm2_brbm3_$i 2> /dev/null || echo -n ''
36 virsh undefine baremetalbrbm_brbm1_brbm2_brbm3_$i --remove-all-storage 2> /dev/null || echo -n ''
37 /usr/bin/touch /var/lib/libvirt/images/baremetalbrbm_brbm1_brbm2_brbm3_${i}.qcow2
38 virsh vol-delete baremetalbrbm_brbm1_brbm2_brbm3_${i}.qcow2 --pool default 2> /dev/null
39 rm -f /var/lib/libvirt/images/baremetalbrbm_brbm1_brbm2_brbm3_${i}.qcow2 2> /dev/null
42 # Clean off created bridges
43 for bridge in ${ovs_bridges}; do
44 virsh net-destroy ${bridge} 2> /dev/null
45 virsh net-undefine ${bridge} 2> /dev/null
46 if detach_interface_from_ovs ${bridge} 2> /dev/null; then
47 ovs-vsctl del-br ${bridge} 2> /dev/null
51 # clean pub keys from root's auth keys
52 sed -i '/stack@instack.localdomain/d' /root/.ssh/authorized_keys
53 sed -i '/virtual-power-key/d' /root/.ssh/authorized_keys
56 echo "Cleanup Completed"