| 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 | 
 | 59 | cleanup_cinder | 
 | 60 | cleanup_glance | 
 | 61 | cleanup_keystone | 
 | 62 | cleanup_nova | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 63 | cleanup_neutron | 
| Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 64 | cleanup_swift | 
 | 65 |  | 
| JordanP | 51c90b8 | 2013-05-23 10:27:51 +0200 | [diff] [blame] | 66 | # 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] | 67 | # clean it up if it is a loop device | 
 | 68 | VG_DEV=$(sudo losetup -j $DATA_DIR/${VOLUME_GROUP}-backing-file | awk -F':' '/backing-file/ { print $1}') | 
 | 69 | if [[ -n "$VG_DEV" ]]; then | 
 | 70 |     sudo losetup -d $VG_DEV | 
 | 71 | fi | 
 | 72 |  | 
 | 73 | #if mount | grep $DATA_DIR/swift/drives; then | 
 | 74 | #  sudo umount $DATA_DIR/swift/drives/sdb1 | 
 | 75 | #fi | 
 | 76 |  | 
 | 77 |  | 
 | 78 | # Clean out /etc | 
 | 79 | sudo rm -rf /etc/keystone /etc/glance /etc/nova /etc/cinder /etc/swift | 
 | 80 |  | 
 | 81 | # Clean out tgt | 
 | 82 | sudo rm /etc/tgt/conf.d/* | 
 | 83 |  | 
 | 84 | # Clean up the message queue | 
 | 85 | cleanup_rpc_backend | 
 | 86 | cleanup_database | 
 | 87 |  | 
 | 88 | # Clean up networking... | 
 | 89 | # should this be in nova? | 
 | 90 | # FIXED_IP_ADDR in br100 | 
 | 91 |  | 
 | 92 | # Clean up files | 
| Dean Troyer | 58f9cf7 | 2013-06-04 12:51:54 -0500 | [diff] [blame] | 93 | rm -f $TOP_DIR/.stackenv |