|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# **clean.sh** |
| 4 | + |
| 5 | +# ``clean.sh`` does its best to eradicate traces of a Grenade |
| 6 | +# run except for the following: |
| 7 | +# - both base and target code repos are left alone |
| 8 | +# - packages (system and pip) are left alone |
| 9 | + |
| 10 | +# This means that all data files are removed. More?? |
| 11 | + |
| 12 | +# Keep track of the current devstack directory. |
| 13 | +TOP_DIR=$(cd $(dirname "$0") && pwd) |
| 14 | + |
| 15 | +# Import common functions |
| 16 | +source $TOP_DIR/functions |
| 17 | + |
| 18 | +# Load local configuration |
| 19 | +source $TOP_DIR/stackrc |
| 20 | + |
| 21 | +# Get the variables that are set in stack.sh |
| 22 | +source $TOP_DIR/.stackenv |
| 23 | + |
| 24 | +# Determine what system we are running on. This provides ``os_VENDOR``, |
| 25 | +# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME`` |
| 26 | +# and ``DISTRO`` |
| 27 | +GetDistro |
| 28 | + |
| 29 | + |
| 30 | +# Import database library |
| 31 | +source $TOP_DIR/lib/database |
| 32 | +source $TOP_DIR/lib/rpc_backend |
| 33 | + |
| 34 | +source $TOP_DIR/lib/tls |
| 35 | +source $TOP_DIR/lib/horizon |
| 36 | +source $TOP_DIR/lib/keystone |
| 37 | +source $TOP_DIR/lib/glance |
| 38 | +source $TOP_DIR/lib/nova |
| 39 | +source $TOP_DIR/lib/cinder |
| 40 | +source $TOP_DIR/lib/swift |
| 41 | +source $TOP_DIR/lib/ceilometer |
| 42 | +source $TOP_DIR/lib/heat |
| 43 | +source $TOP_DIR/lib/quantum |
| 44 | +source $TOP_DIR/lib/baremetal |
| 45 | +source $TOP_DIR/lib/ldap |
| 46 | + |
| 47 | + |
| 48 | +# See if there is anything running... |
| 49 | +# need to adapt when run_service is merged |
| 50 | +SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }') |
| 51 | +if [[ -n "$SESSION" ]]; then |
| 52 | + # Let unstack.sh do its thing first |
| 53 | + $TOP_DIR/unstack.sh --all |
| 54 | +fi |
| 55 | + |
| 56 | +# Clean projects |
| 57 | +cleanup_cinder |
| 58 | +cleanup_glance |
| 59 | +cleanup_keystone |
| 60 | +cleanup_nova |
| 61 | +cleanup_quantum |
| 62 | +cleanup_swift |
| 63 | + |
| 64 | +# cinder doesn't clean up the volume group as it might be used elsewhere... |
| 65 | +# clean it up if it is a loop device |
| 66 | +VG_DEV=$(sudo losetup -j $DATA_DIR/${VOLUME_GROUP}-backing-file | awk -F':' '/backing-file/ { print $1}') |
| 67 | +if [[ -n "$VG_DEV" ]]; then |
| 68 | + sudo losetup -d $VG_DEV |
| 69 | +fi |
| 70 | + |
| 71 | +#if mount | grep $DATA_DIR/swift/drives; then |
| 72 | +# sudo umount $DATA_DIR/swift/drives/sdb1 |
| 73 | +#fi |
| 74 | + |
| 75 | + |
| 76 | +# Clean out /etc |
| 77 | +sudo rm -rf /etc/keystone /etc/glance /etc/nova /etc/cinder /etc/swift |
| 78 | + |
| 79 | +# Clean out tgt |
| 80 | +sudo rm /etc/tgt/conf.d/* |
| 81 | + |
| 82 | +# Clean up the message queue |
| 83 | +cleanup_rpc_backend |
| 84 | +cleanup_database |
| 85 | + |
| 86 | +# Clean up networking... |
| 87 | +# should this be in nova? |
| 88 | +# FIXED_IP_ADDR in br100 |
| 89 | + |
| 90 | +# Clean up files |
| 91 | +#rm -f .stackenv |
0 commit comments