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 virsh vol-delete baremetalbrbm_brbm1_brbm2_brbm3_${i}.qcow2 --pool default 2> /dev/null
38 rm -f /var/lib/libvirt/images/baremetalbrbm_brbm1_brbm2_brbm3_${i}.qcow2 2> /dev/null
41 # Clean off created bridges
42 for bridge in ${ovs_bridges}; do
43 virsh net-destroy ${bridge} 2> /dev/null
44 virsh net-undefine ${bridge} 2> /dev/null
45 if detach_interface_from_ovs ${bridge} 2> /dev/null; then
46 ovs-vsctl del-br ${bridge} 2> /dev/null
50 # clean pub keys from root's auth keys
51 sed -i '/stack@instack.localdomain/d' /root/.ssh/authorized_keys
52 sed -i '/virtual-power-key/d' /root/.ssh/authorized_keys
55 echo "Cleanup Completed"