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)
15 # Use default if no param passed
16 CONFIG=${CONFIG:-'/var/opt/opnfv'}
17 RESOURCES=${RESOURCES:-"$CONFIG/images"}
18 LIB=${LIB:-"$CONFIG/lib"}
21 source $LIB/common-functions.sh
24 ovs_bridges="br-admin br-private br-public br-storage"
26 # Clean off instack/undercloud VM
27 for vm in instack undercloud; do
28 virsh destroy $vm 2> /dev/null | xargs echo -n
29 virsh undefine $vm 2> /dev/null | xargs echo -n
30 /usr/bin/touch /var/lib/libvirt/images/${vm}.qcow2
31 virsh vol-delete ${vm}.qcow2 --pool default 2> /dev/null | xargs echo -n
32 rm -f /var/lib/libvirt/images/${vm}.qcow2 2> /dev/null
35 # Clean off baremetal VMs in case they exist
36 for i in $(seq 0 $vm_index); do
37 virsh destroy baremetal$i 2> /dev/null | xargs echo -n
38 virsh undefine baremetal$i 2> /dev/null | xargs echo -n
39 /usr/bin/touch /var/lib/libvirt/images/baremetal${i}.qcow2
40 virsh vol-delete baremetal${i}.qcow2 --pool default 2> /dev/null | xargs echo -n
41 rm -f /var/lib/libvirt/images/baremetal${i}.qcow2 2> /dev/null
44 # Clean off created bridges
45 for bridge in ${ovs_bridges}; do
46 virsh net-destroy ${bridge} 2> /dev/null | xargs echo -n
47 virsh net-undefine ${bridge} 2> /dev/null | xargs echo -n
48 if detach_interface_from_ovs ${bridge} 2> /dev/null; then
49 ovs-vsctl del-br ${bridge} 2> /dev/null
53 # clean pub keys from root's auth keys
54 sed -i '/stack@undercloud.localdomain/d' /root/.ssh/authorized_keys
55 sed -i '/virtual-power-key/d' /root/.ssh/authorized_keys
58 # force storage cleanup
59 virsh pool-refresh default
61 echo "Cleanup Completed"