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