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 |
Sean Dague | 5375329 | 2014-12-04 19:38:15 -0500 | [diff] [blame^] | 21 | source $TOP_DIR/openrc |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 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 | |
Dean Troyer | 53ffc71 | 2013-12-17 11:13:40 -0600 | [diff] [blame] | 33 | # Import apache functions |
| 34 | source $TOP_DIR/lib/apache |
| 35 | source $TOP_DIR/lib/ldap |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 36 | |
| 37 | # Import database library |
| 38 | source $TOP_DIR/lib/database |
| 39 | source $TOP_DIR/lib/rpc_backend |
| 40 | |
| 41 | source $TOP_DIR/lib/tls |
Dean Troyer | 53ffc71 | 2013-12-17 11:13:40 -0600 | [diff] [blame] | 42 | |
Sean Dague | 59d9cec | 2014-04-02 18:43:42 -0400 | [diff] [blame] | 43 | source $TOP_DIR/lib/oslo |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 44 | source $TOP_DIR/lib/horizon |
| 45 | source $TOP_DIR/lib/keystone |
| 46 | source $TOP_DIR/lib/glance |
| 47 | source $TOP_DIR/lib/nova |
| 48 | source $TOP_DIR/lib/cinder |
| 49 | source $TOP_DIR/lib/swift |
| 50 | source $TOP_DIR/lib/ceilometer |
| 51 | source $TOP_DIR/lib/heat |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 52 | source $TOP_DIR/lib/neutron |
Dean Troyer | 53ffc71 | 2013-12-17 11:13:40 -0600 | [diff] [blame] | 53 | source $TOP_DIR/lib/ironic |
| 54 | source $TOP_DIR/lib/trove |
| 55 | |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 56 | |
Dean Troyer | cdf3d76 | 2013-10-15 09:42:43 -0500 | [diff] [blame] | 57 | # Extras Source |
| 58 | # -------------- |
| 59 | |
| 60 | # Phase: source |
| 61 | if [[ -d $TOP_DIR/extras.d ]]; then |
| 62 | for i in $TOP_DIR/extras.d/*.sh; do |
| 63 | [[ -r $i ]] && source $i source |
| 64 | done |
| 65 | fi |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 66 | |
| 67 | # See if there is anything running... |
| 68 | # need to adapt when run_service is merged |
| 69 | SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }') |
| 70 | if [[ -n "$SESSION" ]]; then |
| 71 | # Let unstack.sh do its thing first |
| 72 | $TOP_DIR/unstack.sh --all |
| 73 | fi |
| 74 | |
Dean Troyer | cdf3d76 | 2013-10-15 09:42:43 -0500 | [diff] [blame] | 75 | # Run extras |
| 76 | # ========== |
| 77 | |
| 78 | # Phase: clean |
| 79 | if [[ -d $TOP_DIR/extras.d ]]; then |
| 80 | for i in $TOP_DIR/extras.d/*.sh; do |
| 81 | [[ -r $i ]] && source $i clean |
| 82 | done |
| 83 | fi |
| 84 | |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 85 | # Clean projects |
| 86 | cleanup_cinder |
| 87 | cleanup_glance |
| 88 | cleanup_keystone |
| 89 | cleanup_nova |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 90 | cleanup_neutron |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 91 | cleanup_swift |
| 92 | |
Dean Troyer | b9e2513 | 2013-10-01 14:45:04 -0500 | [diff] [blame] | 93 | if is_service_enabled ldap; then |
| 94 | cleanup_ldap |
| 95 | fi |
| 96 | |
Dean Troyer | 2aa2a89 | 2013-08-04 19:53:19 -0500 | [diff] [blame] | 97 | # Do the hypervisor cleanup until this can be moved back into lib/nova |
Dean Troyer | e4fa721 | 2014-01-15 15:04:49 -0600 | [diff] [blame] | 98 | if is_service_enabled nova && [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then |
Dean Troyer | 2aa2a89 | 2013-08-04 19:53:19 -0500 | [diff] [blame] | 99 | cleanup_nova_hypervisor |
| 100 | fi |
| 101 | |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 102 | # Clean out /etc |
Gary Kotton | b00e418 | 2014-05-01 05:16:59 -0700 | [diff] [blame] | 103 | sudo rm -rf /etc/keystone /etc/glance /etc/nova /etc/cinder /etc/swift /etc/heat /etc/neutron |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 104 | |
| 105 | # Clean out tgt |
Dean Troyer | 53ffc71 | 2013-12-17 11:13:40 -0600 | [diff] [blame] | 106 | sudo rm -f /etc/tgt/conf.d/* |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 107 | |
| 108 | # Clean up the message queue |
| 109 | cleanup_rpc_backend |
| 110 | cleanup_database |
| 111 | |
Dean Troyer | 53ffc71 | 2013-12-17 11:13:40 -0600 | [diff] [blame] | 112 | # Clean out data, logs and status |
| 113 | LOGDIR=$(dirname "$LOGFILE") |
| 114 | sudo rm -rf $DATA_DIR $LOGDIR $DEST/status |
| 115 | if [[ -n "$SCREEN_LOGDIR" ]] && [[ -d "$SCREEN_LOGDIR" ]]; then |
| 116 | sudo rm -rf $SCREEN_LOGDIR |
| 117 | fi |
| 118 | |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 119 | # Clean up files |
Sean Dague | 2e2b28b | 2014-02-19 09:02:02 -0500 | [diff] [blame] | 120 | |
ZhiQiang Fan | ecd0563 | 2014-06-28 16:50:22 +0800 | [diff] [blame] | 121 | FILES_TO_CLEAN=".localrc.auto docs/files docs/html shocco/ stack-screenrc test*.conf* test.ini*" |
Sean Dague | 2e2b28b | 2014-02-19 09:02:02 -0500 | [diff] [blame] | 122 | FILES_TO_CLEAN+=".stackenv .prereqs" |
| 123 | |
Shashank Hegde | cb41569 | 2014-02-27 16:46:43 -0800 | [diff] [blame] | 124 | for file in $FILES_TO_CLEAN; do |
ZhiQiang Fan | ecd0563 | 2014-06-28 16:50:22 +0800 | [diff] [blame] | 125 | rm -rf $TOP_DIR/$file |
Sean Dague | 2e2b28b | 2014-02-19 09:02:02 -0500 | [diff] [blame] | 126 | done |