Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 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 |
Dean Troyer | 58f9cf7 | 2013-06-04 12:51:54 -0500 | [diff] [blame] | 22 | if [[ -r $TOP_DIR/.stackenv ]]; then |
| 23 | source $TOP_DIR/.stackenv |
| 24 | fi |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 25 | |
| 26 | # Determine what system we are running on. This provides ``os_VENDOR``, |
| 27 | # ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME`` |
| 28 | # and ``DISTRO`` |
| 29 | GetDistro |
| 30 | |
| 31 | |
| 32 | # Import database library |
| 33 | source $TOP_DIR/lib/database |
| 34 | source $TOP_DIR/lib/rpc_backend |
| 35 | |
| 36 | source $TOP_DIR/lib/tls |
| 37 | source $TOP_DIR/lib/horizon |
| 38 | source $TOP_DIR/lib/keystone |
| 39 | source $TOP_DIR/lib/glance |
| 40 | source $TOP_DIR/lib/nova |
| 41 | source $TOP_DIR/lib/cinder |
| 42 | source $TOP_DIR/lib/swift |
| 43 | source $TOP_DIR/lib/ceilometer |
| 44 | source $TOP_DIR/lib/heat |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 45 | source $TOP_DIR/lib/neutron |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 46 | source $TOP_DIR/lib/baremetal |
| 47 | source $TOP_DIR/lib/ldap |
| 48 | |
| 49 | |
| 50 | # See if there is anything running... |
| 51 | # need to adapt when run_service is merged |
| 52 | SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }') |
| 53 | if [[ -n "$SESSION" ]]; then |
| 54 | # Let unstack.sh do its thing first |
| 55 | $TOP_DIR/unstack.sh --all |
| 56 | fi |
| 57 | |
| 58 | # Clean projects |
Sean Dague | db5fadb | 2013-08-09 13:41:33 -0400 | [diff] [blame] | 59 | cleanup_oslo |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 60 | cleanup_cinder |
| 61 | cleanup_glance |
| 62 | cleanup_keystone |
| 63 | cleanup_nova |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 64 | cleanup_neutron |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 65 | cleanup_swift |
| 66 | |
Dean Troyer | 2aa2a89 | 2013-08-04 19:53:19 -0500 | [diff] [blame^] | 67 | # Do the hypervisor cleanup until this can be moved back into lib/nova |
| 68 | if [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then |
| 69 | cleanup_nova_hypervisor |
| 70 | fi |
| 71 | |
JordanP | 51c90b8 | 2013-05-23 10:27:51 +0200 | [diff] [blame] | 72 | # cinder doesn't always clean up the volume group as it might be used elsewhere... |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 73 | # clean it up if it is a loop device |
| 74 | VG_DEV=$(sudo losetup -j $DATA_DIR/${VOLUME_GROUP}-backing-file | awk -F':' '/backing-file/ { print $1}') |
| 75 | if [[ -n "$VG_DEV" ]]; then |
| 76 | sudo losetup -d $VG_DEV |
| 77 | fi |
| 78 | |
| 79 | #if mount | grep $DATA_DIR/swift/drives; then |
| 80 | # sudo umount $DATA_DIR/swift/drives/sdb1 |
| 81 | #fi |
| 82 | |
| 83 | |
| 84 | # Clean out /etc |
| 85 | sudo rm -rf /etc/keystone /etc/glance /etc/nova /etc/cinder /etc/swift |
| 86 | |
| 87 | # Clean out tgt |
| 88 | sudo rm /etc/tgt/conf.d/* |
| 89 | |
| 90 | # Clean up the message queue |
| 91 | cleanup_rpc_backend |
| 92 | cleanup_database |
| 93 | |
| 94 | # Clean up networking... |
| 95 | # should this be in nova? |
| 96 | # FIXED_IP_ADDR in br100 |
| 97 | |
| 98 | # Clean up files |
Dean Troyer | 58f9cf7 | 2013-06-04 12:51:54 -0500 | [diff] [blame] | 99 | rm -f $TOP_DIR/.stackenv |