blob: fea1230c7b59182ebffe0dee82d0389bfb1ee2ef [file] [log] [blame]
Sean Dague9a413ab2015-02-04 12:44:18 -05001#!/bin/bash
Dean Troyer995eb922013-03-07 16:11:40 -06002
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.
13TOP_DIR=$(cd $(dirname "$0") && pwd)
14
15# Import common functions
16source $TOP_DIR/functions
17
Dean Troyerb9e25132013-10-01 14:45:04 -050018FILES=$TOP_DIR/files
19
Dean Troyer995eb922013-03-07 16:11:40 -060020# Load local configuration
Sean Dague53753292014-12-04 19:38:15 -050021source $TOP_DIR/openrc
Dean Troyer995eb922013-03-07 16:11:40 -060022
23# Get the variables that are set in stack.sh
Dean Troyer58f9cf72013-06-04 12:51:54 -050024if [[ -r $TOP_DIR/.stackenv ]]; then
25 source $TOP_DIR/.stackenv
26fi
Dean Troyer995eb922013-03-07 16:11:40 -060027
28# Determine what system we are running on. This provides ``os_VENDOR``,
29# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
30# and ``DISTRO``
31GetDistro
32
Dean Troyer53ffc712013-12-17 11:13:40 -060033# Import apache functions
34source $TOP_DIR/lib/apache
35source $TOP_DIR/lib/ldap
Dean Troyer995eb922013-03-07 16:11:40 -060036
37# Import database library
38source $TOP_DIR/lib/database
39source $TOP_DIR/lib/rpc_backend
40
41source $TOP_DIR/lib/tls
Dean Troyer53ffc712013-12-17 11:13:40 -060042
Sean Dague59d9cec2014-04-02 18:43:42 -040043source $TOP_DIR/lib/oslo
Dean Troyer995eb922013-03-07 16:11:40 -060044source $TOP_DIR/lib/horizon
45source $TOP_DIR/lib/keystone
46source $TOP_DIR/lib/glance
47source $TOP_DIR/lib/nova
48source $TOP_DIR/lib/cinder
49source $TOP_DIR/lib/swift
50source $TOP_DIR/lib/ceilometer
51source $TOP_DIR/lib/heat
Mark McClainb05c8762013-07-06 23:29:39 -040052source $TOP_DIR/lib/neutron
Dean Troyer53ffc712013-12-17 11:13:40 -060053source $TOP_DIR/lib/ironic
54source $TOP_DIR/lib/trove
55
Dean Troyer995eb922013-03-07 16:11:40 -060056
Dean Troyercdf3d762013-10-15 09:42:43 -050057# Extras Source
58# --------------
59
60# Phase: source
61if [[ -d $TOP_DIR/extras.d ]]; then
62 for i in $TOP_DIR/extras.d/*.sh; do
63 [[ -r $i ]] && source $i source
64 done
65fi
Dean Troyer995eb922013-03-07 16:11:40 -060066
67# See if there is anything running...
68# need to adapt when run_service is merged
69SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
70if [[ -n "$SESSION" ]]; then
71 # Let unstack.sh do its thing first
72 $TOP_DIR/unstack.sh --all
73fi
74
Dean Troyercdf3d762013-10-15 09:42:43 -050075# Run extras
76# ==========
77
78# Phase: clean
79if [[ -d $TOP_DIR/extras.d ]]; then
80 for i in $TOP_DIR/extras.d/*.sh; do
81 [[ -r $i ]] && source $i clean
82 done
83fi
84
Dean Troyer995eb922013-03-07 16:11:40 -060085# Clean projects
Sean Dague9a413ab2015-02-04 12:44:18 -050086
87# BUG: cinder tgt doesn't exit cleanly if it's not running.
88cleanup_cinder || /bin/true
89
Dean Troyer995eb922013-03-07 16:11:40 -060090cleanup_glance
91cleanup_keystone
92cleanup_nova
Mark McClainb05c8762013-07-06 23:29:39 -040093cleanup_neutron
Dean Troyer995eb922013-03-07 16:11:40 -060094cleanup_swift
95
Dean Troyerb9e25132013-10-01 14:45:04 -050096if is_service_enabled ldap; then
97 cleanup_ldap
98fi
99
Dean Troyer2aa2a892013-08-04 19:53:19 -0500100# Do the hypervisor cleanup until this can be moved back into lib/nova
Dean Troyere4fa7212014-01-15 15:04:49 -0600101if is_service_enabled nova && [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then
Dean Troyer2aa2a892013-08-04 19:53:19 -0500102 cleanup_nova_hypervisor
103fi
104
Dean Troyer995eb922013-03-07 16:11:40 -0600105# Clean out /etc
Gary Kottonb00e4182014-05-01 05:16:59 -0700106sudo rm -rf /etc/keystone /etc/glance /etc/nova /etc/cinder /etc/swift /etc/heat /etc/neutron
Dean Troyer995eb922013-03-07 16:11:40 -0600107
108# Clean out tgt
Dean Troyer53ffc712013-12-17 11:13:40 -0600109sudo rm -f /etc/tgt/conf.d/*
Dean Troyer995eb922013-03-07 16:11:40 -0600110
111# Clean up the message queue
112cleanup_rpc_backend
113cleanup_database
114
Dean Troyer53ffc712013-12-17 11:13:40 -0600115# Clean out data, logs and status
116LOGDIR=$(dirname "$LOGFILE")
117sudo rm -rf $DATA_DIR $LOGDIR $DEST/status
118if [[ -n "$SCREEN_LOGDIR" ]] && [[ -d "$SCREEN_LOGDIR" ]]; then
119 sudo rm -rf $SCREEN_LOGDIR
120fi
121
Dean Troyerb1d8e8e2015-02-16 13:58:35 -0600122# Clean up venvs
123DIRS_TO_CLEAN="$WHEELHOUSE"
124rm -rf $DIRS_TO_CLEAN
125
Dean Troyer995eb922013-03-07 16:11:40 -0600126# Clean up files
Sean Dague2e2b28b2014-02-19 09:02:02 -0500127
ZhiQiang Fanecd05632014-06-28 16:50:22 +0800128FILES_TO_CLEAN=".localrc.auto docs/files docs/html shocco/ stack-screenrc test*.conf* test.ini*"
Sean Dague2e2b28b2014-02-19 09:02:02 -0500129FILES_TO_CLEAN+=".stackenv .prereqs"
130
Shashank Hegdecb415692014-02-27 16:46:43 -0800131for file in $FILES_TO_CLEAN; do
ZhiQiang Fanecd05632014-06-28 16:50:22 +0800132 rm -rf $TOP_DIR/$file
Sean Dague2e2b28b2014-02-19 09:02:02 -0500133done